Skip to content

Commit

Permalink
Add image view to ForecastView
Browse files Browse the repository at this point in the history
  • Loading branch information
kantacky committed Feb 19, 2024
1 parent 5d01d7d commit e965bc8
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions YumemiTraining/ForecastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ import SwiftUI

struct ForecastView<ViewModel: ForecastViewModel>: View {
@StateObject var viewModel: ViewModel

@State private var buttonsSize: CGSize = .zero

var body: some View {
VStack(spacing: .init(80)) {
VStack {
// Image
Color.gray
.aspectRatio(1, contentMode: .fit)
.containerRelativeFrame(
.horizontal,
count: 2,
spacing: .zero
)

Group {
if let weatherCondition = self.viewModel.weatherCondition {
weatherCondition.image
.scaledToFit()
} else {
Color.gray
}
}
.aspectRatio(1, contentMode: .fit)
.containerRelativeFrame(
.horizontal,
count: 2,
spacing: .zero
)

// Labels
HStack(spacing: .zero) {
Text("--")
Expand All @@ -33,7 +40,7 @@ struct ForecastView<ViewModel: ForecastViewModel>: View {
count: 4,
spacing: .zero
)

Text("--")
.foregroundStyle(.red)
.containerRelativeFrame(
Expand All @@ -43,7 +50,7 @@ struct ForecastView<ViewModel: ForecastViewModel>: View {
)
}
}

// Buttons
HStack(spacing: 0) {
Button {
Expand All @@ -58,7 +65,7 @@ struct ForecastView<ViewModel: ForecastViewModel>: View {
spacing: .zero,
alignment: .center
)

Button {
// Reload Action
self.viewModel.reload()
Expand Down

0 comments on commit e965bc8

Please sign in to comment.