Files
Reflect/Shared/Views/DayView/WeatherCardView.swift
Trey t 6a8a66546b Enrich test data, fix multi-page PDF export, and polish UI
- Populate debug test data with random notes, guided reflections, and weather
- Fix PDF export to use UIPrintPageRenderer for proper multi-page pagination
- Add journal/reflection indicator icons to day list entry cells
- Fix weather card icon contrast by using secondarySystemBackground
- Align Generate Report and Export PDF button widths in ReportsView

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 18:19:01 -05:00

71 lines
2.1 KiB
Swift

//
// WeatherCardView.swift
// Reflect
//
// Visual weather card shown in EntryDetailView.
//
import SwiftUI
struct WeatherCardView: View {
let weatherData: WeatherData
private var highTemp: String {
formatTemperature(weatherData.highTemperature)
}
private var lowTemp: String {
formatTemperature(weatherData.lowTemperature)
}
private var humidityPercent: String {
"\(Int(weatherData.humidity * 100))%"
}
var body: some View {
HStack(spacing: 14) {
Image(systemName: weatherData.conditionSymbol)
.font(.system(size: 36))
.symbolRenderingMode(.multicolor)
.frame(width: 44)
VStack(alignment: .leading, spacing: 4) {
Text(weatherData.condition)
.font(.subheadline)
.fontWeight(.medium)
HStack(spacing: 8) {
Label(String(localized: "H: \(highTemp)"), systemImage: "thermometer.high")
Label(String(localized: "L: \(lowTemp)"), systemImage: "thermometer.low")
Label(humidityPercent, systemImage: "humidity")
}
.font(.caption)
.foregroundStyle(.secondary)
.labelStyle(.titleOnly)
}
Spacer()
}
.padding()
.background(
RoundedRectangle(cornerRadius: 16)
.fill(Color(.secondarySystemBackground))
)
}
private func formatTemperature(_ celsius: Double) -> String {
let measurement = Measurement(value: celsius, unit: UnitTemperature.celsius)
let formatter = MeasurementFormatter()
formatter.unitOptions = .providedUnit
formatter.numberFormatter.maximumFractionDigits = 0
formatter.unitStyle = .short
// Use locale-aware conversion
let locale = Locale.current
if locale.measurementSystem == .us {
let fahrenheit = measurement.converted(to: .fahrenheit)
return formatter.string(from: fahrenheit)
}
return formatter.string(from: measurement)
}
}