-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abstacted diffent views to make code readable
- Loading branch information
1 parent
77130bb
commit e8c5590
Showing
9 changed files
with
401 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+20.3 KB
(150%)
...deproj/project.xcworkspace/xcuserdata/amanbind.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// CloudinessVisibilityCard.swift | ||
// Weather Varta | ||
// | ||
// Created by Aman Bind on 23/02/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CloudinessVisibilityCard: View { | ||
var body: some View { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Image(systemName: "eye") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 20) | ||
|
||
VStack(alignment: .leading) { | ||
HStack { | ||
Text("6.0") | ||
.font(.title2) | ||
Text("km") | ||
.font(.footnote) | ||
.offset(x: -5, y: 2) | ||
} | ||
|
||
Text("VISIBILITY") | ||
.font(.caption2) | ||
} | ||
}.offset(x: 25) | ||
|
||
Divider() | ||
HStack { | ||
Image(systemName: "cloud") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 20) | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Text("50") | ||
.font(.title2) | ||
Text("%") | ||
.font(.footnote) | ||
.offset(x: -5, y: 2) | ||
} | ||
Text("CLOUDINESS") | ||
.font(.caption2) | ||
} | ||
} | ||
.offset(x: 25) | ||
} | ||
.frame(width: 173, height: 140) | ||
.background(Color("background_card")) | ||
.clipShape(RoundedRectangle(cornerRadius: 20)) | ||
} | ||
} | ||
|
||
#Preview { | ||
CloudinessVisibilityCard() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// HumidityPressureCard.swift | ||
// Weather Varta | ||
// | ||
// Created by Aman Bind on 23/02/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct HumidityPressureCard: View { | ||
var body: some View { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Image(systemName: "humidity") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 20) | ||
|
||
VStack(alignment: .leading) { | ||
HStack { | ||
Text("50") | ||
.font(.title2) | ||
Text("%") | ||
.font(.footnote) | ||
.offset(x: -5, y: 2) | ||
} | ||
|
||
Text("HUMIDITY") | ||
.font(.caption2) | ||
} | ||
}.offset(x: 25) | ||
|
||
Divider() | ||
HStack { | ||
Image(systemName: "gauge") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 20) | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Text("1,019") | ||
.font(.title2) | ||
Text("hPa") | ||
.font(.footnote) | ||
.offset(x: -5, y: 2) | ||
} | ||
Text("PRESSURE") | ||
.font(.caption2) | ||
} | ||
} | ||
.offset(x: 25) | ||
} | ||
.frame(width: 173, height: 140) | ||
.background(Color("background_card")) | ||
.clipShape(RoundedRectangle(cornerRadius: 20)) | ||
} | ||
} | ||
|
||
#Preview { | ||
HumidityPressureCard() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// SearchBarView.swift | ||
// Weather Varta | ||
// | ||
// Created by Aman Bind on 23/02/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SearchBarView: View { | ||
|
||
@Binding var searchCity: String | ||
@Binding var networkManager: NetworkManager | ||
@Binding var locationManager: LocationDataManager | ||
|
||
var body: some View { | ||
HStack { | ||
RoundedRectangle(cornerRadius: 25) | ||
.frame(width: 320, height: 40) | ||
.foregroundColor(Color.backgroundCard) | ||
.overlay { | ||
HStack { | ||
Image(systemName: "map.fill") | ||
.padding() | ||
TextField("Enter your City", text: $searchCity) | ||
.textFieldStyle(.plain) | ||
.font(.title3) | ||
.autocorrectionDisabled() | ||
.textInputAutocapitalization(.never) | ||
.submitLabel(.search) | ||
.onSubmit { | ||
networkManager.fetchWeatherByName(city: searchCity) | ||
} | ||
} | ||
} | ||
.padding(1) | ||
|
||
Button(action: { | ||
locationManager.requestLocation() | ||
networkManager.fetchWeatherByLocation(coordinate: locationManager.location!) | ||
}, label: { | ||
Image(systemName: "location.circle.fill") | ||
.resizable() | ||
.scaledToFit() | ||
.foregroundStyle(.blue) | ||
|
||
}) | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
SearchBarView(searchCity: .constant(""), networkManager: .constant(NetworkManager()), locationManager: .constant(LocationDataManager())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// SunriseSunsetCard.swift | ||
// Weather Varta | ||
// | ||
// Created by Aman Bind on 23/02/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SunriseSunsetCard: View { | ||
var body: some View { | ||
HStack { | ||
VStack { | ||
Image(systemName: "sunrise.fill") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 25) | ||
|
||
HStack { | ||
Text("5:30") | ||
.font(.title3) | ||
.offset(y: -5) | ||
Text("PM") | ||
.font(.caption2) | ||
.offset(x: -5, y: -5) | ||
} | ||
|
||
Text("SUNRISE") | ||
.font(.caption2) | ||
} | ||
|
||
Divider() | ||
|
||
VStack { | ||
Image(systemName: "sunset.fill") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 25) | ||
|
||
HStack { | ||
Text("5:30") | ||
.font(.title3) | ||
.offset(y: -5) | ||
Text("PM") | ||
.font(.caption2) | ||
.offset(x: -5, y: -5) | ||
} | ||
Text("SUNSET") | ||
.font(.caption2) | ||
} | ||
} | ||
.frame(width: 173, height: 140) | ||
.background(Color("background_card")) | ||
.clipShape(RoundedRectangle(cornerRadius: 20)) | ||
} | ||
} | ||
|
||
#Preview { | ||
SunriseSunsetCard() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// WeatherCard.swift | ||
// Weather Varta | ||
// | ||
// Created by Aman Bind on 23/02/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct WeatherCard: View { | ||
var body: some View { | ||
VStack { | ||
HStack(alignment: .top, spacing: 20, content: { | ||
Image(systemName: "sun.max.trianglebadge.exclamationmark") | ||
.symbolRenderingMode(.monochrome) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(width: 80, height: 80) | ||
.offset(y: 10) | ||
|
||
Text("25") | ||
.font(.system(size: 80)) | ||
.offset(x: 15) | ||
|
||
Text("℃") | ||
.offset(y: 15) | ||
|
||
}) | ||
.offset(y: 20) | ||
|
||
Text("Clear") | ||
.offset(y: 10) | ||
|
||
HStack { | ||
Spacer() | ||
VStack { | ||
HStack { | ||
Text("MAX:") | ||
Text("25℃") | ||
} | ||
|
||
HStack { | ||
Text("MIN:") | ||
Text("25℃") | ||
} | ||
} | ||
.offset(y: 5) | ||
|
||
Spacer() | ||
HStack { | ||
Image(systemName: "thermometer.medium") | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 25) | ||
|
||
VStack { | ||
Text("25℃") | ||
.font(.largeTitle) | ||
.offset(y: 5) | ||
Text("FEELS LIKE") | ||
.font(.caption2) | ||
} | ||
} | ||
Spacer() | ||
} | ||
} | ||
.frame(width: 356, height: 250) | ||
.background(Color("background_card_big")) | ||
.clipShape(RoundedRectangle(cornerRadius: 20)) | ||
} | ||
} | ||
|
||
#Preview { | ||
WeatherCard() | ||
} |
Oops, something went wrong.