Skip to content

Instantly share code, notes, and snippets.

@bpisano
Created June 18, 2019 09:49
Show Gist options
  • Select an option

  • Save bpisano/3c0855cd70ed523418ac93cd099939c8 to your computer and use it in GitHub Desktop.

Select an option

Save bpisano/3c0855cd70ed523418ac93cd099939c8 to your computer and use it in GitHub Desktop.
Embedded code in my Weather article on Medium
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