Skip to content

Commit

Permalink
Pressure and wind
Browse files Browse the repository at this point in the history
  • Loading branch information
garthvh committed Jul 12, 2024
1 parent 7e212cb commit aea6fe0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -8094,6 +8094,9 @@
}
}
}
},
"Gusts %@" : {

},
"Hardware" : {

Expand Down Expand Up @@ -16593,6 +16596,9 @@
},
"Press Pin" : {

},
"PRESSURE" : {

},
"Primary" : {

Expand Down Expand Up @@ -22403,6 +22409,9 @@
},
"WiFi Options" : {

},
"WIND" : {

},
"x" : {

Expand Down
57 changes: 57 additions & 0 deletions Meshtastic/Views/Helpers/Weather/LocalWeatherConditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ struct LocalWeatherConditions: View {
@State private var dewPoint: String = ""
@State private var humidity: Int?
@State private var pressure: Measurement<UnitPressure>?
@State private var windSpeed: String = ""
@State private var windGust: String = ""
@State private var windDirection: Measurement<UnitAngle>?
@State private var windCompassDirection: String = ""
@State private var symbolName: String = "cloud.fill"
@State private var attributionLink: URL?
@State private var attributionLogo: URL?
Expand All @@ -30,6 +34,8 @@ struct LocalWeatherConditions: View {
LazyVGrid(columns: gridItemLayout) {
WeatherConditionsCompactWidget(temperature: temperature, symbolName: symbolName, description: condition?.description.uppercased() ?? "??")
HumidityCompactWidget(humidity: humidity ?? 0, dewPoint: dewPoint)
PressureCompactWidget(pressure: String(pressure?.value ?? 0.0 / 100), unit: pressure?.unit.symbol ?? "??")
WindCompactWidget(speed: windSpeed, gust: windGust, direction: windCompassDirection)
}
}
.task {
Expand All @@ -47,6 +53,10 @@ struct LocalWeatherConditions: View {
dewPoint = measurementFormatter.string(from: weather.currentWeather.dewPoint)
humidity = Int(weather.currentWeather.humidity * 100)
pressure = weather.currentWeather.pressure
windSpeed = measurementFormatter.string(from: weather.currentWeather.wind.speed)//weather.currentWeather.wind.speed
windGust = measurementFormatter.string(from: weather.currentWeather.wind.gust ?? Measurement(value: 0.0, unit: weather.currentWeather.wind.gust!.unit))
windDirection = weather.currentWeather.wind.direction
windCompassDirection = weather.currentWeather.wind.compassDirection.description
symbolName = weather.currentWeather.symbolName
let attribution = try await WeatherService.shared.attribution
attributionLink = attribution.legalPageURL
Expand Down Expand Up @@ -120,3 +130,50 @@ struct HumidityCompactWidget: View {
}
}
}

struct PressureCompactWidget: View {
let pressure: String
let unit: String
var body: some View {
ZStack(alignment: .topLeading) {
VStack(alignment: .leading) {
Label { Text("PRESSURE") } icon: { Image(systemName: "gauge").symbolRenderingMode(.multicolor) }
.font(.caption2)
Text(pressure)
.font(.system(size: 35))
.padding(.bottom)
Text(unit)
.padding(.top)
}
.padding(.horizontal)
.frame(maxWidth: .infinity)
.frame(height: 175)
.background(.tertiary, in: RoundedRectangle(cornerRadius: 20, style: .continuous))
}
}
}


struct WindCompactWidget: View {
let speed: String
let gust: String
let direction: String
var body: some View {
ZStack(alignment: .topLeading) {
VStack(alignment: .leading) {
Label { Text("WIND") } icon: { Image(systemName: "wind").symbolRenderingMode(.multicolor) }
.font(.caption)
Text("\(direction)")
.font(.caption)
.padding(.bottom, 10)
Text(speed)
.font(.system(size: 35))
Text("Gusts \(gust)")
}
.padding(.horizontal)
.frame(maxWidth: .infinity)
.frame(height: 175)
.background(.tertiary, in: RoundedRectangle(cornerRadius: 20, style: .continuous))
}
}
}

0 comments on commit aea6fe0

Please sign in to comment.