A self-educational iOS app to track coin prices.
https://www.coingecko.com/en/api
Swift - SwiftUI - Combine -> ...
- Customised color themes and app icon were added to the Assets of the project.
- A reusable button was created to be used for the header of the home screen.
- MVVM files of "Home" screen were added to the project. //Add the prior steps
- CoinDataService:
- CoinImageService: To firstly download and save images in Filemanager and afterwards to retrieve the saved images.
- NetworkingManager in Utilities
- DataService in Services
- ViewModel
To keep the app and its services reusable, I have used 3 layers: 1st Service, which is responsible for downloading from internet and after returning the data, appends the data to a published property. 2nd ViewModel, which is responsible for subscribing to the data appended to the published property of the Service. 3rd View, which is responsible for referencing to the ViewModel and at the end put the recevied data on screen.
-
NetworkingManager: This utility class consists of 3 static methods of download, handleCompletion and handleResponse. Plus an NetworkingError enum. Being static func allows us to simply call like NetworkingManager.download every where in our app.
-
LocalFileManager: This utility class is used to SAVE images instead of redownloading them again and again. Therefore, the 2 main funcs inside of this class will be saveImages to the fileManger and getImages back from the fileManager. Moreover, we will have 3 more funcs: getURLForFolder, getURLForImage, createFolderIfNeeded.
The searchText published var in HomeViewModel will be binded to SearchBarView. Therefore, whenever we type something in the searchBar, this published var will be updated. Hence, if we subscribe to this publisher, we can use its value.
We wanted to combine $searchText and $allCoins publishers and map them to a new array CoinsModel and also filter them.
So far 2 models have been used:
- CoinsModel: which consists of ALL data related to the coins, coming from the URL.
- StatisticModel: which consists of selected data related to the coins which then will be needed to create the HomeStatView.
Saving data, like downloading data, needs a Service class. The difference will be that, in downloading the end point is a URL but in Saving, it will be coreData of the currentPortfolio in this specific case. Before we start working with CoreData, we need to setup a coreData Entity, that we will be storing in CoreData. For organizing purposes, remember to save the entity file in Model folder as it's really a model.
- Create a model file in model folder which consists of the desired properties.
- Make a view in component folder which consists of a reusable view with all the necessary data in that view.
- Make another view in its appropriate folder like Home. This one should consists of the final look of our desire view.
- Transfer all NOT view related data to a ViewModel.
- Finally call the View of 3rd step inside the final View of the app.
Add UnitTests for all the VMs Add UITests for all the Views Make a separated repo out of LocalFileManager.
On 05.09:
- Save the holdings on coreData