-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeatherView.swift
More file actions
103 lines (83 loc) · 3.71 KB
/
WeatherView.swift
File metadata and controls
103 lines (83 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// WeatherView.swift
// Weather101
//
// Created by Cami🦋 on 9/17/22.
//
import SwiftUI
struct WeatherView: View {
var weather: ResponseBody
var body: some View {
ZStack(alignment: .leading){
VStack{
VStack(alignment: .leading,spacing: 5){
Text(weather.name)
.bold().font(.title)
Text("Today, \(Date().formatted(.dateTime.month().day().hour().minute().second()))")
.fontWeight(.light)
}
.frame(maxWidth: .infinity, alignment: .leading)
Spacer()
VStack{
HStack{
VStack(spacing:20){
Image(systemName: "sun.max")
.font(.system(size: 40))
Text(weather.weather[0].main)
}
.frame(width: 150, alignment: .leading)
Spacer()
Text(weather.main.feelsLike.roundedDouble() + "°")
.font(.system(size: 100))
.fontWeight(.bold)
.padding()
}
Spacer()
.frame(height:0)
AsyncImage(url:URL( string: "https://www.pngkey.com/png/full/905-9055849_atmosphere-of-earth-m-transparent-background-earth.png")){ image in image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 350)
} placeholder: {
ProgressView()
}
Spacer()
}
.frame(maxWidth: .infinity)
}
.padding()
.frame(maxWidth: .infinity, alignment: .leading)
VStack{
Spacer()
VStack(alignment: .leading, spacing: 20){
Text("Weather now")
.bold().padding(.bottom )
HStack{
WeatherRow(logo: "thermometer", name: "min temp", value: weather.main.tempMin.roundedDouble() + "°")
Spacer()
WeatherRow(logo: "thermometer", name: "max temp", value: weather.main.tempMax.roundedDouble() + "°")
}
HStack{
WeatherRow(logo: "wind", name: "wind speed", value: weather.wind.speed.roundedDouble() + "m/s")
Spacer()
WeatherRow(logo: "humidity", name: "humidity", value: weather.main.humidity.roundedDouble() + "%")
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.padding(.bottom ,20)
.foregroundColor(Color(hue: 0.656, saturation: 0.787, brightness: 0.354))
.background(Color(hue: 0.58, saturation: 0.12, brightness: 0.53))
.cornerRadius( 20, corners: [.topLeft, .topRight])
}
}
.edgesIgnoringSafeArea(.bottom)
.background(Color(hue: 0.94, saturation: 0.04, brightness: 0.71))
.preferredColorScheme(.dark)
}
}
struct WeatherView_Previews: PreviewProvider {
static var previews: some View {
WeatherView(weather: previewWeather)
}
}