Weather is a simple app that displays weather in SwiftUI. I saw a lot of tutorials on the web, that shows very basic feature of SwiftUI. I tried to combine all of them in one simple app to demonstrate how SwiftUI works. It shows asynchronous data fetch, binding and how to build user interfaces with SwiftUI.
Weather use the Dark Sky API to fetch weather data. To run this app, you'll need a Dark Sky API key. This is entirely free. To do so :
- Create your account here and get your Dark Sky API key.
- Open the project, and go to the
WeatherManager.swift
file. - Replace
static let key: String = ""
by your key.
Weather require Xcode 11.0
.
This app have some issues probably due to SwiftUI as it is in beta. Here are the bugs I can list here. Feel free to correct them if you find how to.
Closing a modal view doesn't seems to work. In the NewCityView.swift
I tried to use a binding variable to close the modal view :
struct NewCityView : View {
@Binding var isAddingCity: Bool
}
This variable doesn't have any effect on the modal presentation.
There are some layout issues in the hourly weather ScrollView. The text is wrapped where it should not be. I'm also using icons from the SF Symbols. But some of them are not working and they seems not to be all correctly aligned.
This app does not fetch weather for the city you add. It is configured to fetch weather from a hard coded location. This is not really a bug but a missing feature. I'll probably add it later.
Feel free to give some contribution to this very basic project. This will help us to better understand SwiftUI and how to use it to get started.
This app was made by me, Benjamin Pisano. If you want to contact me, you can send me DM on Twitter @benjamin_pisano. You can also see my app on the Mac AppStore.