This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct CityView : View { | |
| @ObjectBinding var city = City(name: "Chambéry") | |
| var body: some View { | |
| List { | |
| Section(header: Text("Now")) { | |
| CityHeaderView(city: city) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct CityHeaderView: View { | |
| @ObjectBinding var city: City | |
| var temperature: String { | |
| guard let temperature = city.weather?.current.temperature else { | |
| return "-ºC" | |
| } | |
| return temperature.formattedTemperature | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct CityHourlyView : View { | |
| @ObjectBinding var city: City | |
| private let rowHeight: CGFloat = 110 | |
| var body: some View { | |
| ScrollView(alwaysBounceHorizontal: true, showsHorizontalIndicator: false) { | |
| HStack(spacing: 16) { | |
| ForEach(city.weather?.hours.list ?? []) { hour in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct CityDailyView : View { | |
| @State var day: DailyWeather | |
| var body: some View { | |
| ZStack { | |
| HStack(alignment: .center) { | |
| Text(day.time.formattedDay) | |
| Spacer() | |
| HStack(spacing: 16) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import Combine | |
| import MapKit | |
| class CityFinder: NSObject, BindableObject { | |
| var didChange = PassthroughSubject<CityFinder, Never>() | |
| var results: [String] = [] { | |
| didSet { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct NewCityView : View { | |
| @Binding var isAddingCity: Bool | |
| @State private var search: String = "" | |
| @ObjectBinding var cityFinder: CityFinder = CityFinder() | |
| @EnvironmentObject var cityStore: CityStore | |
| var body: some View { | |
| NavigationView { |
OlderNewer