Created
June 18, 2019 09:49
-
-
Save bpisano/3c0855cd70ed523418ac93cd099939c8 to your computer and use it in GitHub Desktop.
Embedded code in my Weather article on Medium
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) { | |
| verticalTemperatureView(min: true) | |
| verticalTemperatureView(min: false) | |
| } | |
| } | |
| HStack(alignment: .center) { | |
| Spacer() | |
| day.icon.image | |
| .font(.body) | |
| Spacer() | |
| } | |
| } | |
| } | |
| func verticalTemperatureView(min: Bool) -> some View { | |
| VStack(alignment: .trailing) { | |
| Text(min ? "min" : "max") | |
| .font(.footnote) | |
| .color(.gray) | |
| Text(min ? day.minTemperature.formattedTemperature : day.maxTemperature.formattedTemperature) | |
| .font(.headline) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment