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 { |
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 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
| 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 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
| 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
| import UIKit | |
| import SwiftUI | |
| class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| var window: UIWindow? | |
| func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
| // Use a UIHostingController as window root view controller | |
| let window = UIWindow(frame: UIScreen.main.bounds) |
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 CityListView : View { | |
| @EnvironmentObject var cityStore: CityStore | |
| @State var isAddingCity: Bool = false | |
| @State private var isEditing: Bool = false | |
| var body: some View { |
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 | |
| class CityStore: BindableObject { | |
| let didChange = PassthroughSubject<CityStore, Never>() | |
| var cities: [City] = [City(name: "Chambery")] { | |
| didSet { | |
| didChange.send(self) |
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 | |
| class City: BindableObject { | |
| var didChange = PassthroughSubject<City, Never>() | |
| let name: String | |
| var weather: Weather? { | |
| didSet { |
NewerOlder