Skip to content

Instantly share code, notes, and snippets.

@alpennec
Created November 27, 2022 07:32
Show Gist options
  • Select an option

  • Save alpennec/37e03d758196cf1fc8923a4bfda7777b to your computer and use it in GitHub Desktop.

Select an option

Save alpennec/37e03d758196cf1fc8923a4bfda7777b to your computer and use it in GitHub Desktop.
//
// Created by Axel Le Pennec on 26/01/2022.
// Copyright © 2022 Axel Le Pennec. All rights reserved.
//
import Foundation
import WeatherKit
public enum DayNightTime {
case day
case night
}
extension WeatherCondition: Identifiable {
public static func random() -> WeatherCondition {
return WeatherCondition.allCases.randomElement()!
}
public var id: String { return self.rawValue }
public func systemSymbolName(for time: DayNightTime) -> String {
switch self {
case .blizzard:
return "wind.snow"
case .blowingDust:
return "wind"
case .blowingSnow:
return "wind.snow"
case .breezy:
return "wind"
case .clear:
switch time {
case .day:
return "sun.max"
case .night:
return "moon.stars"
}
case .cloudy:
switch time {
case .day:
return "cloud"
case .night:
return "cloud.moon"
}
case .drizzle:
return "cloud.drizzle"
case .flurries:
return "cloud.snow"
case .foggy:
return "cloud.fog"
case .freezingDrizzle:
return "cloud.sleet"
case .freezingRain:
return "cloud.sleet"
case .frigid:
return "thermometer.snowflake"
case .hail:
return "cloud.hail"
case .haze:
switch time {
case .day:
return "sun.haze"
case .night:
return "moon.haze"
}
case .heavyRain:
return "cloud.heavyrain"
case .heavySnow:
return "cloud.snow"
case .hot:
return "thermometer.high"
case .hurricane:
return "hurricane"
case .isolatedThunderstorms:
switch time {
case .day:
return "cloud.sun.bolt"
case .night:
return "cloud.moon.bolt"
}
case .mostlyClear:
switch time {
case .day:
return "cloud"
case .night:
return "cloud.moon"
}
case .mostlyCloudy:
switch time {
case .day:
return "cloud"
case .night:
return "cloud.moon"
}
case .partlyCloudy:
switch time {
case .day:
return "cloud.sun"
case .night:
return "cloud.moon"
}
case .rain:
switch time {
case .day:
return "cloud.sun.rain"
case .night:
return "cloud.moon.rain"
}
case .scatteredThunderstorms:
switch time {
case .day:
return "cloud.bolt"
case .night:
return "cloud.moon.bolt"
}
case .sleet:
return "cloud.sleet"
case .smoky:
return "smoke"
case .snow:
return "snowflake"
case .strongStorms:
return "cloud.bolt.rain"
case .sunFlurries:
return "snowflake"
case .sunShowers:
switch time {
case .day:
return "cloud.rain"
case .night:
return "cloud.moon.rain"
}
case .thunderstorms:
return "cloud.bolt.rain"
case .tropicalStorm:
return "tropicalstorm"
case .windy:
return "wind"
case .wintryMix:
switch time {
case .day:
return "cloud.rain"
case .night:
return "cloud.moon.rain"
}
}
}
}
// WeatherKit symbols used according to Ask Apple Slack: https://appledeveloper.slack.com/archives/C0432CSG760/p1666109450387029?thread_ts=1666109382.257379&cid=C0432CSG760
//"cloud"
//"cloud.bolt"
//"cloud.bolt.rain"
//"cloud.drizzle"
//"cloud.fog"
//"cloud.hail"
//"cloud.heavyrain"
//"cloud.moon"
//"cloud.moon.bolt"
//"cloud.moon.rain"
//"cloud.rain"
//"cloud.sleet"
//"cloud.snow"
//"cloud.sun"
//"cloud.sun.rain"
//"hurricane"
//"moon.haze"
//"moon.stars"
//"snow"
//"sun.dust"
//"sun.haze"
//"sun.max"
//"thermometer.snowflake"
//"tropicalstorm"
//"wind"
//"wind.snow"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment