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
| extension Weather { | |
| enum Icon: String, Codable { | |
| case clearDay = "clear-day" | |
| case clearNight = "clear-night" | |
| case rain = "rain" | |
| case snow = "snow" | |
| case sleet = "sleet" | |
| case wind = "wind" |
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
| class WeatherManager { | |
| static let key: String = "" // Enter your darkSky API Key here | |
| static let baseURL: String = "https://api.darksky.net/forecast/\(key)/" | |
| } |
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 HourlyWeather: Codable, Identifiable { | |
| var id: Date { | |
| return time | |
| } | |
| var time: Date | |
| var temperature: Double | |
| var icon: Weather.Icon | |
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 DailyWeather: Codable, Identifiable { | |
| var id: Date { | |
| return time | |
| } | |
| var time: Date | |
| var maxTemperature: Double | |
| var minTemperature: Double | |
| var icon: Weather.Icon |
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
| extension Weather { | |
| struct List<T: Codable & Identifiable>: Codable { | |
| var list: [T] | |
| enum CodingKeys: String, CodingKey { | |
| case list = "data" | |
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 Weather: Codable { | |
| var current: HourlyWeather | |
| var hours: Weather.List<HourlyWeather> | |
| var week: Weather.List<DailyWeather> | |
| enum CodingKeys: String, CodingKey { | |
| case current = "currently" | |
| case hours = "hourly" |
NewerOlder