Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions Weather/Networking/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@
import SwiftUI
import Combine

class NetworkManager: BindableObject {
var didChange = PassthroughSubject<NetworkManager, Never>()
class NetworkManager: ObservableObject {

var currentWeather = CurrentWeatherViewModel() {
didSet {
didChange.send(self)
}
}
@Published var currentWeather = CurrentWeatherViewModel()

var dailyWeather = DailyWeatherViewModel() {
didSet {
didChange.send(self)
}
}
@Published var dailyWeather = DailyWeatherViewModel()

let client = DarkSkyAPIClient()

Expand Down
15 changes: 9 additions & 6 deletions Weather/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).

// Use a UIHostingController as window root view controller
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()

let contentView = ContentView()

if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}

func sceneDidDisconnect(_ scene: UIScene) {
Expand Down
2 changes: 1 addition & 1 deletion Weather/View/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
import Combine

struct ContentView: View {
@State var networkManager = NetworkManager()
@ObservedObject var networkManager = NetworkManager()

var body: some View {
ZStack {
Expand Down
1 change: 1 addition & 0 deletions Weather/View/CurrentWeatherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct CurrentWeatherView: View {
Text(data.temperature)
.font(.system(size: 150))
.fontWeight(.ultraLight)
.layoutPriority(1)

VStack(alignment: .leading) {
HStack {
Expand Down
8 changes: 4 additions & 4 deletions Weather/View/DailyWeatherView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ struct DailyWeatherView: View {
VStack {
HStack {
Text("5-Day Forecast")
.color(.gray)
.foregroundColor(.gray)

Spacer()
}.padding(.leading)

Divider()
.padding([.leading, .trailing])

ForEach(data.data.identified(by: \.day)) { data in
ForEach(data.data, id: \.day) { data in
ZStack {
HStack {
Text(data.day)
Spacer()
Text(data.temperatureHigh).padding(8)
Text(data.temperatureLow).color(.gray)
}.padding([.leading, .trailing])
Text(data.temperatureLow).foregroundColor(.gray)
}.padding([.leading, .trailing])

Image(data.icon)
.resizable()
Expand Down
2 changes: 1 addition & 1 deletion Weather/View/HeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct HeaderView: View {
var body: some View {
VStack {
Text("NEW YORK CITY").font(.title).fontWeight(.light)
Text(data.time).color(.gray)
Text(data.time).foregroundColor(.gray)
}
}
}