WeatherProvider / NationalWeatherService-Swift

A multi-platform Swift wrapper for the National Weather Service's weather.gov API.
10 stars 10 forks source link

minor bug fix, allows for periods to be Listed in SwiftUI #7

Closed xt0fer closed 2 years ago

xt0fer commented 2 years ago

adding a id field and implementing Identifiable, allows the items in the Period to listed in a SwiftUI List or a ForEach iterator. Also fixed a minor bug where latitude was being sent instead of longitude,

xt0fer commented 2 years ago

to be more clear, the id field and Identifiable adherence in the Forecast.Period lets you do something like

struct FutureView: View {
    var forecast: Forecast

    // For formatting the forecast periods.
    var body: some View {
        ForEach(forecast.periods) { period in
            VStack(alignment: .leading){
                Text("\(period.name!)")
                    .font(.title2)
                Text("\(period.detailedForecast!)")
                    .font(.body)
                HStack{
                    Text("Temp: \(period.temperature.formatted())")
                    Text("Wind: \(period.windSpeed.description)")
                }
                .font(.body.bold())
            }
            .padding(.bottom, 1)
        }
    }
}
ualch9 commented 2 years ago

I will review this hopefully sometime soon, thank you for the PR!

xt0fer commented 2 years ago

restored to orig metric unit request

xt0fer commented 2 years ago

wait, I should not have closed the PR.

ualch9 commented 2 years ago

CI is failing because Actions' secrets are not given to PRs. Tested on my own machine (simulator & macOS) and tests pass.

ualch9 commented 2 years ago

thank you very much, @xt0fer, for your pr. I really appreciate it!!