diff --git a/InfiniLink/Core/Home/DeviceView.swift b/InfiniLink/Core/Home/DeviceView.swift index a1239ab..0ff4c6c 100644 --- a/InfiniLink/Core/Home/DeviceView.swift +++ b/InfiniLink/Core/Home/DeviceView.swift @@ -257,18 +257,20 @@ struct DeviceView: View { }) Spacer() .frame(height: 6) - NavigationLink(destination: FileSystemView()) { - HStack { - Text(NSLocalizedString("file_system", comment: "")) - .frame(maxWidth: .infinity, alignment: .leading) - Spacer() - Image(systemName: "chevron.right") - .foregroundColor(.gray) + if bleManager.blefsTransfer != nil { + NavigationLink(destination: FileSystemView()) { + HStack { + Text(NSLocalizedString("file_system", comment: "")) + .frame(maxWidth: .infinity, alignment: .leading) + Spacer() + Image(systemName: "chevron.right") + .foregroundColor(.gray) + } + .modifier(RowModifier(style: .capsule)) } - .modifier(RowModifier(style: .capsule)) + Spacer() + .frame(height: 6) } - Spacer() - .frame(height: 6) VStack { if bleManager.isConnectedToPinetime { Toggle(isOn: $bleManager.autoconnectToDevice) { diff --git a/InfiniLink/Core/Home/WatchFace.swift b/InfiniLink/Core/Home/WatchFace.swift index 0411a53..0ca12d3 100644 --- a/InfiniLink/Core/Home/WatchFace.swift +++ b/InfiniLink/Core/Home/WatchFace.swift @@ -662,7 +662,7 @@ struct TerminalWF: View { .foregroundColor(.white) .font(.custom("JetBrainsMono-Bold", size: geometry.size.width * 0.085)) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) - .position(x: geometry.size.width / 2.0, y: geometry.size.height / 6.9) + .position(x: geometry.size.width / 2.0, y: geometry.size.height / 6.5) if !hour24 { Group { 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 { .foregroundColor(.white) .font(.custom("JetBrainsMono-Bold", size: geometry.size.width * 0.085)) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) - .position(x: geometry.size.width / 2.0, y: geometry.size.height / 1.27) + .position(x: geometry.size.width / 2.0, y: geometry.size.height / 1.28) } .frame(width: geometry.size.width, height: geometry.size.height, alignment: .center) } @@ -789,13 +789,13 @@ struct CasioWF: View { CustomTextView(text: { let currentHour = Calendar.current.component(.hour, from: Date()) var hourString = "" + if hour24 { - hourString = String(format: "%02d", currentHour) + hourString = String(format: "%d", currentHour) } else { let hour12 = currentHour > 12 ? currentHour - 12 : currentHour - hourString = String(format: "%02d", hour12) + hourString = "\(hour12)" } - let minuteString = String(format: "%02d", Calendar.current.component(.minute, from: Date())) return "\(hourString):\(minuteString)" @@ -861,7 +861,7 @@ enum InfineatItem { #Preview { NavigationView { GeometryReader { geometry in - WatchFaceView(watchface: .constant(4)) + WatchFaceView(watchface: .constant(3)) .padding(22) .frame(width: geometry.size.width / 1.65, height: geometry.size.width / 1.65, alignment: .center) .clipped(antialiased: true) diff --git a/InfiniLink/Core/Weather/Views/WeatherDetailView.swift b/InfiniLink/Core/Weather/Views/WeatherDetailView.swift index 0032877..bf53fda 100644 --- a/InfiniLink/Core/Weather/Views/WeatherDetailView.swift +++ b/InfiniLink/Core/Weather/Views/WeatherDetailView.swift @@ -10,6 +10,10 @@ import SwiftUI struct WeatherDetailView: View { @ObservedObject var bleManagerVal = BLEManagerVal.shared + var celsius: Bool { + (UnitTemperature.current == .celsius && deviceData.chosenWeatherMode == "System") || deviceData.chosenWeatherMode == "Metric" + } + func getIcon(icon: Int) -> String { switch icon { case 0: @@ -30,9 +34,12 @@ struct WeatherDetailView: View { return "slash.circle" } } - - var celsius: Bool { - (UnitTemperature.current == .celsius && deviceData.chosenWeatherMode == "System") || deviceData.chosenWeatherMode == "Metric" + func temp(_ temp: Double) -> String { + if self.celsius { + return String(Int(round(temp))) + "°" + "C" + } else { + return String(Int(round(temp * 1.8 + 32))) + "°" + "F" + } } let deviceData: DeviceData = DeviceData() @@ -45,7 +52,7 @@ struct WeatherDetailView: View { } var body: some View { - VStack { + VStack(spacing: 0) { HStack { Text(NSLocalizedString("weather", comment: "")) .font(.title.bold()) @@ -61,72 +68,56 @@ struct WeatherDetailView: View { ProgressView(NSLocalizedString("loading_weather", comment: "")) Spacer() } else { - VStack(spacing: 8) { - Image(systemName: getIcon(icon: bleManagerVal.weatherInformation.icon)) - .font(.system(size: 45).weight(.medium)) - HStack { - Group { - if celsius { - Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature))) + "°" + "C") - } else { - Text(String(Int(round(bleManagerVal.weatherInformation.minTemperature * 1.8 + 32))) + "°" + "F") - } - } - .foregroundColor(.gray) - Group { - if celsius { - Text(String(Int(round(bleManagerVal.weatherInformation.temperature))) + "°" + "C") - } else { - Text(String(Int(round(bleManagerVal.weatherInformation.temperature * 1.8 + 32))) + "°" + "F") - } + ScrollView { + VStack(spacing: 8) { + Image(systemName: getIcon(icon: bleManagerVal.weatherInformation.icon)) + .font(.system(size: 45).weight(.medium)) + HStack { + Text(temp(bleManagerVal.weatherInformation.minTemperature)) + .foregroundColor(.gray) + Text(temp(bleManagerVal.weatherInformation.temperature)) + .font(.system(size: 35).weight(.semibold)) + Text(temp(bleManagerVal.weatherInformation.maxTemperature)) + .foregroundColor(.gray) } - .font(.system(size: 35).weight(.semibold)) - Group { - if celsius { - Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature))) + "°" + "C") - } else { - Text(String(Int(round(bleManagerVal.weatherInformation.maxTemperature * 1.8 + 32))) + "°" + "F") - } - } - .foregroundColor(.gray) + Text(bleManagerVal.weatherInformation.shortDescription) + .foregroundColor(.gray) + .font(.body.weight(.semibold)) } - Text(bleManagerVal.weatherInformation.shortDescription) - .foregroundColor(.gray) - .font(.body.weight(.semibold)) - } - .padding() - Divider() - VStack { - ScrollView(.horizontal, showsIndicators: false) { - HStack(spacing: 10) { - ForEach(bleManagerVal.weatherForecastDays, id: \.name) { day in - VStack(spacing: 6) { - Text(day.name) - .foregroundColor(.gray) - .font(.system(size: 14).weight(.medium)) - Image(systemName: getIcon(icon: Int(day.icon))) - .imageScale(.large) - .font(.system(size: 18).weight(.medium)) - VStack { - if celsius { - Text(String(Int(round(day.maxTemperature))) + "°") - Text(String(Int(round(day.minTemperature))) + "°") - } else { - Text(String(Int(round(day.maxTemperature * 1.8 + 32))) + "°") - Text(String(Int(round(day.minTemperature * 1.8 + 32))) + "°") - } - } + .padding() + VStack(spacing: 10) { + ForEach(bleManagerVal.weatherForecastDays, id: \.name) { day in + HStack(spacing: 6) { + Text(day.name) + .font(.body.weight(.medium)) + Image(systemName: getIcon(icon: Int(day.icon))) + .imageScale(.large) + .font(.body.weight(.medium)) + Spacer() + HStack(spacing: 6) { + Text(temp(day.maxTemperature)) + .foregroundColor(.lightGray) + Rectangle() + .frame(height: 3) + .frame(width: { + let temperatureRange = day.maxTemperature - day.minTemperature + let relativeWidth = CGFloat(temperatureRange) / 40.0 * 60 + return relativeWidth + }()) + .cornerRadius(30) + .background(Material.thin) + Text(temp(day.minTemperature)) + .foregroundColor(.lightGray) } - .padding(12) - .frame(width: 95) - .background(Color.gray.opacity(0.3)) - .cornerRadius(12) } + .frame(maxWidth: .infinity) + .padding() + .background(Color.gray.opacity(0.3)) + .cornerRadius(15) } - .padding() } + .padding() } - Spacer() } } } @@ -142,5 +133,7 @@ struct WeatherDetailView: View { BLEManagerVal.shared.weatherInformation.maxTemperature = 3 BLEManagerVal.shared.weatherInformation.maxTemperature = 5 BLEManagerVal.shared.weatherForecastDays.append(WeatherForecastDay(maxTemperature: 3, minTemperature: 2, icon: 2, name: "Sat")) + BLEManagerVal.shared.weatherForecastDays.append(WeatherForecastDay(maxTemperature: 1.6, minTemperature: 1.3, icon: 6, name: "Sun")) + BLEManagerVal.shared.weatherForecastDays.append(WeatherForecastDay(maxTemperature: 2.6, minTemperature: 1.9, icon: 3, name: "Mon")) } } diff --git a/InfiniLink/Core/Weather/WeatherController.swift b/InfiniLink/Core/Weather/WeatherController.swift index 3697e89..110ae21 100644 --- a/InfiniLink/Core/Weather/WeatherController.swift +++ b/InfiniLink/Core/Weather/WeatherController.swift @@ -197,6 +197,11 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate { let currentDate = Date() for idx in 1...json["forecast"]["forecastday"][0].count { + bleManagerVal.weatherInformation.forecastIcon = [] + bleManagerVal.weatherInformation.forecastMaxTemperature = [] + bleManagerVal.weatherInformation.forecastMinTemperature = [] + bleManagerVal.weatherForecastDays = [] + bleManagerVal.weatherInformation.forecastIcon.append(getIcon_WAPI(description: json["forecast"]["forecastday"][idx]["day"]["condition"]["text"].stringValue)) bleManagerVal.weatherInformation.forecastMaxTemperature.append(json["forecast"]["forecastday"][idx]["day"]["maxtemp_c"].doubleValue) bleManagerVal.weatherInformation.forecastMinTemperature.append(json["forecast"]["forecastday"][idx]["day"]["mintemp_c"].doubleValue) @@ -340,7 +345,7 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate { return 0 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": return 1 - case "Cloudy", "Mostly Cloudy", "Mostly Cloudy with Haze", "Mostly Cloudy and Breezy", "Mostly Cloudy and Wind": + case "Cloudy", "Mostly Cloudy", "Mostly Cloudy with Haze", "Mostly Cloudy and Breezy", "Mostly Cloudy and Wind", "Cloudy and Windy": return 2 case "Overcast", "Overcast with Haze", "Overcast and Breezy", "Overcast and Windy", "Hurricane Watch", "Funnel Cloud", "Funnel Cloud in Vicinity", "Tornado/Water Spout", "Tornado": return 3 @@ -389,8 +394,10 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate { bleManagerVal.weatherInformation.maxTemperature = json["properties"]["maxTemperature"]["values"][0]["value"].doubleValue bleManagerVal.weatherInformation.minTemperature = json["properties"]["minTemperature"]["values"][0]["value"].doubleValue + bleManagerVal.weatherInformation.forecastIcon = [] bleManagerVal.weatherInformation.forecastMaxTemperature = [] bleManagerVal.weatherInformation.forecastMinTemperature = [] + bleManagerVal.weatherForecastDays = [] let currentDate = Date() let calendar = Calendar.current