Showing Weather forecast using SwiftUI + Combine.framework.
Select a area, and show daily forecasts, using OpenWeather API
- SwiftUI.framework
- Combine.framework
- used in network-access and state - manegemnt
- Clean Architecture
- View - ViewModel - Repository
- NetworkImageView
- MKMapView with CoreLocation
- GPS with Combine.framework
- detect tap and add pin at tap position
- Sample implementation of
MainThreadScheduler
- but, this won't work with delay-call.
- Adapt dark mode with asset-catalog-colors
- Install Xcode11.0 beta
- you need not install MacBeta (but you can't use preview)
- Build and Run
By default, this app will access local-json file.
If you want to use network-api, please do as following
- sign in OpenWeather and create Api Key
- rename
Config-sample.plist
toConfig.plist
- Write your Api Key in
Constants.plist
city_list.json from Openweather is too big (20MB!). So I shrinked it. Please check city_json/
- /
+- Config-sample.plist : config base file. rename and set your key +- RootView.swift : view at app-launching
+- Theme.swift : Color list
+- asset/ : cities and sample json
+- Entity/
+- Network/
+- PartsView/ : common views
+- Repository/
+- Utils/
+- View
+= ViewModel
- Use Clean Architecture,
- avoid using
@State
in view.(except TextField, it requires state) - use ViewModel for view state management.
- use Repository for fetching data
Basic Structure
Fragment - View - ViewModel - Repository
- Fragment
- create ViewModel and put it to the environment.
- create View with ViewModel
- manage lifecycle-related-operation
- View
- render view, created by Fragment
- bind with
ViewModel
and call its functions.
- ViewModel
- Manage View-State
BindableObject
- Repostiroy
- Fetch data
- OpenWeather
- Many repositories using SwiftUI and authors.
- MainThreadScheduler won't work with delay-time
- when I call action() an
DispatchQueue.main.async
, nothing happens.
- when I call action() an
- Weather5DayView causes memory-leaks
- I found that
List
causes it. But I can't find the way to fix this.
- I found that