Skip to content

Commit 581af98

Browse files
committed
Minor bug fixes and improvements
1 parent 7a94454 commit 581af98

4 files changed

Lines changed: 82 additions & 80 deletions

File tree

InfiniLink/Core/Home/DeviceView.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,20 @@ struct DeviceView: View {
257257
})
258258
Spacer()
259259
.frame(height: 6)
260-
NavigationLink(destination: FileSystemView()) {
261-
HStack {
262-
Text(NSLocalizedString("file_system", comment: ""))
263-
.frame(maxWidth: .infinity, alignment: .leading)
264-
Spacer()
265-
Image(systemName: "chevron.right")
266-
.foregroundColor(.gray)
260+
if bleManager.blefsTransfer != nil {
261+
NavigationLink(destination: FileSystemView()) {
262+
HStack {
263+
Text(NSLocalizedString("file_system", comment: ""))
264+
.frame(maxWidth: .infinity, alignment: .leading)
265+
Spacer()
266+
Image(systemName: "chevron.right")
267+
.foregroundColor(.gray)
268+
}
269+
.modifier(RowModifier(style: .capsule))
267270
}
268-
.modifier(RowModifier(style: .capsule))
271+
Spacer()
272+
.frame(height: 6)
269273
}
270-
Spacer()
271-
.frame(height: 6)
272274
VStack {
273275
if bleManager.isConnectedToPinetime {
274276
Toggle(isOn: $bleManager.autoconnectToDevice) {

InfiniLink/Core/Home/WatchFace.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ struct TerminalWF: View {
662662
.foregroundColor(.white)
663663
.font(.custom("JetBrainsMono-Bold", size: geometry.size.width * 0.085))
664664
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
665-
.position(x: geometry.size.width / 2.0, y: geometry.size.height / 6.9)
665+
.position(x: geometry.size.width / 2.0, y: geometry.size.height / 6.5)
666666
if !hour24 {
667667
Group {
668668
Text("[TIME]").foregroundColor(.white) + Text("\(String(format: "%02d", (currentHour % 12 == 0) ? 12 : currentHour % 12)):\(String(format: "%02d", currentMinute)):\(String(format: "%02d", currentSecond)) \(currentHour >= 12 ? "PM" : "AM")").foregroundColor(.green)
@@ -713,7 +713,7 @@ struct TerminalWF: View {
713713
.foregroundColor(.white)
714714
.font(.custom("JetBrainsMono-Bold", size: geometry.size.width * 0.085))
715715
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
716-
.position(x: geometry.size.width / 2.0, y: geometry.size.height / 1.27)
716+
.position(x: geometry.size.width / 2.0, y: geometry.size.height / 1.28)
717717
}
718718
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
719719
}
@@ -789,13 +789,13 @@ struct CasioWF: View {
789789
CustomTextView(text: {
790790
let currentHour = Calendar.current.component(.hour, from: Date())
791791
var hourString = ""
792+
792793
if hour24 {
793-
hourString = String(format: "%02d", currentHour)
794+
hourString = String(format: "%d", currentHour)
794795
} else {
795796
let hour12 = currentHour > 12 ? currentHour - 12 : currentHour
796-
hourString = String(format: "%02d", hour12)
797+
hourString = "\(hour12)"
797798
}
798-
799799
let minuteString = String(format: "%02d", Calendar.current.component(.minute, from: Date()))
800800

801801
return "\(hourString):\(minuteString)"
@@ -861,7 +861,7 @@ enum InfineatItem {
861861
#Preview {
862862
NavigationView {
863863
GeometryReader { geometry in
864-
WatchFaceView(watchface: .constant(4))
864+
WatchFaceView(watchface: .constant(3))
865865
.padding(22)
866866
.frame(width: geometry.size.width / 1.65, height: geometry.size.width / 1.65, alignment: .center)
867867
.clipped(antialiased: true)

InfiniLink/Core/Weather/Views/WeatherDetailView.swift

Lines changed: 56 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import SwiftUI
1010
struct WeatherDetailView: View {
1111
@ObservedObject var bleManagerVal = BLEManagerVal.shared
1212

13+
var celsius: Bool {
14+
(UnitTemperature.current == .celsius && deviceData.chosenWeatherMode == "System") || deviceData.chosenWeatherMode == "Metric"
15+
}
16+
1317
func getIcon(icon: Int) -> String {
1418
switch icon {
1519
case 0:
@@ -30,9 +34,12 @@ struct WeatherDetailView: View {
3034
return "slash.circle"
3135
}
3236
}
33-
34-
var celsius: Bool {
35-
(UnitTemperature.current == .celsius && deviceData.chosenWeatherMode == "System") || deviceData.chosenWeatherMode == "Metric"
37+
func temp(_ temp: Double) -> String {
38+
if self.celsius {
39+
return String(Int(round(temp))) + "°" + "C"
40+
} else {
41+
return String(Int(round(temp * 1.8 + 32))) + "°" + "F"
42+
}
3643
}
3744

3845
let deviceData: DeviceData = DeviceData()
@@ -45,7 +52,7 @@ struct WeatherDetailView: View {
4552
}
4653

4754
var body: some View {
48-
VStack {
55+
VStack(spacing: 0) {
4956
HStack {
5057
Text(NSLocalizedString("weather", comment: ""))
5158
.font(.title.bold())
@@ -61,72 +68,56 @@ struct WeatherDetailView: View {
6168
ProgressView(NSLocalizedString("loading_weather", comment: ""))
6269
Spacer()
6370
} else {
64-
VStack(spacing: 8) {
65-
Image(systemName: getIcon(icon: bleManagerVal.weatherInformation.icon))
66-
.font(.system(size: 45).weight(.medium))
67-
HStack {
68-
Group {
69-
if celsius {
70-
Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature))) + "°" + "C")
71-
} else {
72-
Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature * 1.8 + 32))) + "°" + "F")
73-
}
74-
}
75-
.foregroundColor(.gray)
76-
Group {
77-
if celsius {
78-
Text(String(Int(round(bleManagerVal.weatherInformation.temperature))) + "°" + "C")
79-
} else {
80-
Text(String(Int(round(bleManagerVal.weatherInformation.temperature * 1.8 + 32))) + "°" + "F")
81-
}
71+
ScrollView {
72+
VStack(spacing: 8) {
73+
Image(systemName: getIcon(icon: bleManagerVal.weatherInformation.icon))
74+
.font(.system(size: 45).weight(.medium))
75+
HStack {
76+
Text(temp(bleManagerVal.weatherInformation.minTemperature))
77+
.foregroundColor(.gray)
78+
Text(temp(bleManagerVal.weatherInformation.temperature))
79+
.font(.system(size: 35).weight(.semibold))
80+
Text(temp(bleManagerVal.weatherInformation.maxTemperature))
81+
.foregroundColor(.gray)
8282
}
83-
.font(.system(size: 35).weight(.semibold))
84-
Group {
85-
if celsius {
86-
Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature))) + "°" + "C")
87-
} else {
88-
Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature * 1.8 + 32))) + "°" + "F")
89-
}
90-
}
91-
.foregroundColor(.gray)
83+
Text(bleManagerVal.weatherInformation.shortDescription)
84+
.foregroundColor(.gray)
85+
.font(.body.weight(.semibold))
9286
}
93-
Text(bleManagerVal.weatherInformation.shortDescription)
94-
.foregroundColor(.gray)
95-
.font(.body.weight(.semibold))
96-
}
97-
.padding()
98-
Divider()
99-
VStack {
100-
ScrollView(.horizontal, showsIndicators: false) {
101-
HStack(spacing: 10) {
102-
ForEach(bleManagerVal.weatherForecastDays, id: \.name) { day in
103-
VStack(spacing: 6) {
104-
Text(day.name)
105-
.foregroundColor(.gray)
106-
.font(.system(size: 14).weight(.medium))
107-
Image(systemName: getIcon(icon: Int(day.icon)))
108-
.imageScale(.large)
109-
.font(.system(size: 18).weight(.medium))
110-
VStack {
111-
if celsius {
112-
Text(String(Int(round(day.maxTemperature))) + "°")
113-
Text(String(Int(round(day.minTemperature))) + "°")
114-
} else {
115-
Text(String(Int(round(day.maxTemperature * 1.8 + 32))) + "°")
116-
Text(String(Int(round(day.minTemperature * 1.8 + 32))) + "°")
117-
}
118-
}
87+
.padding()
88+
VStack(spacing: 10) {
89+
ForEach(bleManagerVal.weatherForecastDays, id: \.name) { day in
90+
HStack(spacing: 6) {
91+
Text(day.name)
92+
.font(.body.weight(.medium))
93+
Image(systemName: getIcon(icon: Int(day.icon)))
94+
.imageScale(.large)
95+
.font(.body.weight(.medium))
96+
Spacer()
97+
HStack(spacing: 6) {
98+
Text(temp(day.maxTemperature))
99+
.foregroundColor(.lightGray)
100+
Rectangle()
101+
.frame(height: 3)
102+
.frame(width: {
103+
let temperatureRange = day.maxTemperature - day.minTemperature
104+
let relativeWidth = CGFloat(temperatureRange) / 40.0 * 60
105+
return relativeWidth
106+
}())
107+
.cornerRadius(30)
108+
.background(Material.thin)
109+
Text(temp(day.minTemperature))
110+
.foregroundColor(.lightGray)
119111
}
120-
.padding(12)
121-
.frame(width: 95)
122-
.background(Color.gray.opacity(0.3))
123-
.cornerRadius(12)
124112
}
113+
.frame(maxWidth: .infinity)
114+
.padding()
115+
.background(Color.gray.opacity(0.3))
116+
.cornerRadius(15)
125117
}
126-
.padding()
127118
}
119+
.padding()
128120
}
129-
Spacer()
130121
}
131122
}
132123
}
@@ -142,5 +133,7 @@ struct WeatherDetailView: View {
142133
BLEManagerVal.shared.weatherInformation.maxTemperature = 3
143134
BLEManagerVal.shared.weatherInformation.maxTemperature = 5
144135
BLEManagerVal.shared.weatherForecastDays.append(WeatherForecastDay(maxTemperature: 3, minTemperature: 2, icon: 2, name: "Sat"))
136+
BLEManagerVal.shared.weatherForecastDays.append(WeatherForecastDay(maxTemperature: 1.6, minTemperature: 1.3, icon: 6, name: "Sun"))
137+
BLEManagerVal.shared.weatherForecastDays.append(WeatherForecastDay(maxTemperature: 2.6, minTemperature: 1.9, icon: 3, name: "Mon"))
145138
}
146139
}

InfiniLink/Core/Weather/WeatherController.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate {
197197
let currentDate = Date()
198198

199199
for idx in 1...json["forecast"]["forecastday"][0].count {
200+
bleManagerVal.weatherInformation.forecastIcon = []
201+
bleManagerVal.weatherInformation.forecastMaxTemperature = []
202+
bleManagerVal.weatherInformation.forecastMinTemperature = []
203+
bleManagerVal.weatherForecastDays = []
204+
200205
bleManagerVal.weatherInformation.forecastIcon.append(getIcon_WAPI(description: json["forecast"]["forecastday"][idx]["day"]["condition"]["text"].stringValue))
201206
bleManagerVal.weatherInformation.forecastMaxTemperature.append(json["forecast"]["forecastday"][idx]["day"]["maxtemp_c"].doubleValue)
202207
bleManagerVal.weatherInformation.forecastMinTemperature.append(json["forecast"]["forecastday"][idx]["day"]["mintemp_c"].doubleValue)
@@ -340,7 +345,7 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate {
340345
return 0
341346
case "A Few Clouds", "A Few Clouds with Haze", "A Few Clouds and Breezy", "A Few Clouds and Windy", "Partly Cloudy", "Partly Cloudy with Haze", "Partly Cloudy and Breezy", "Partly Cloudy and Windy":
342347
return 1
343-
case "Cloudy", "Mostly Cloudy", "Mostly Cloudy with Haze", "Mostly Cloudy and Breezy", "Mostly Cloudy and Wind":
348+
case "Cloudy", "Mostly Cloudy", "Mostly Cloudy with Haze", "Mostly Cloudy and Breezy", "Mostly Cloudy and Wind", "Cloudy and Windy":
344349
return 2
345350
case "Overcast", "Overcast with Haze", "Overcast and Breezy", "Overcast and Windy", "Hurricane Watch", "Funnel Cloud", "Funnel Cloud in Vicinity", "Tornado/Water Spout", "Tornado":
346351
return 3
@@ -389,8 +394,10 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate {
389394
bleManagerVal.weatherInformation.maxTemperature = json["properties"]["maxTemperature"]["values"][0]["value"].doubleValue
390395
bleManagerVal.weatherInformation.minTemperature = json["properties"]["minTemperature"]["values"][0]["value"].doubleValue
391396

397+
bleManagerVal.weatherInformation.forecastIcon = []
392398
bleManagerVal.weatherInformation.forecastMaxTemperature = []
393399
bleManagerVal.weatherInformation.forecastMinTemperature = []
400+
bleManagerVal.weatherForecastDays = []
394401

395402
let currentDate = Date()
396403
let calendar = Calendar.current

0 commit comments

Comments
 (0)