diff --git a/InfiniLink/Assets.xcassets/AppIcon-1.appiconset/Contents.json b/InfiniLink/Assets.xcassets/AppIcon-1.appiconset/Contents.json deleted file mode 100644 index 8121323..0000000 --- a/InfiniLink/Assets.xcassets/AppIcon-1.appiconset/Contents.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "60x60" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "60x60" - }, - { - "idiom" : "ios-marketing", - "scale" : "1x", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/InfiniLink/Assets.xcassets/BabyBlue.colorset/Contents.json b/InfiniLink/Assets.xcassets/BabyBlue.colorset/Contents.json new file mode 100644 index 0000000..e488822 --- /dev/null +++ b/InfiniLink/Assets.xcassets/BabyBlue.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.647", + "red" : "0.049" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.647", + "red" : "0.049" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/DarkGreen.colorset/Contents.json b/InfiniLink/Assets.xcassets/DarkGreen.colorset/Contents.json new file mode 100644 index 0000000..f944f00 --- /dev/null +++ b/InfiniLink/Assets.xcassets/DarkGreen.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.294", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.294", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/Green.colorset/Contents.json b/InfiniLink/Assets.xcassets/Green.colorset/Contents.json new file mode 100644 index 0000000..f5cfa2f --- /dev/null +++ b/InfiniLink/Assets.xcassets/Green.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.530", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "0.530", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/LightBlue.colorset/Contents.json b/InfiniLink/Assets.xcassets/LightBlue.colorset/Contents.json new file mode 100644 index 0000000..92c9b13 --- /dev/null +++ b/InfiniLink/Assets.xcassets/LightBlue.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.635", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "0.635", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/LightGreen.colorset/Contents.json b/InfiniLink/Assets.xcassets/LightGreen.colorset/Contents.json new file mode 100644 index 0000000..87dd681 --- /dev/null +++ b/InfiniLink/Assets.xcassets/LightGreen.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "1.000", + "red" : "0.509" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.000", + "green" : "1.000", + "red" : "0.509" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/LightestGreen.colorset/Contents.json b/InfiniLink/Assets.xcassets/LightestGreen.colorset/Contents.json new file mode 100644 index 0000000..1ad788c --- /dev/null +++ b/InfiniLink/Assets.xcassets/LightestGreen.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.610", + "green" : "1.000", + "red" : "0.779" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.608", + "green" : "1.000", + "red" : "0.780" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/Navy.colorset/Contents.json b/InfiniLink/Assets.xcassets/Navy.colorset/Contents.json new file mode 100644 index 0000000..8df4be0 --- /dev/null +++ b/InfiniLink/Assets.xcassets/Navy.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.465", + "green" : "0.210", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.465", + "green" : "0.210", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/NordBlue.colorset/Contents.json b/InfiniLink/Assets.xcassets/NordBlue.colorset/Contents.json new file mode 100644 index 0000000..5920173 --- /dev/null +++ b/InfiniLink/Assets.xcassets/NordBlue.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.575", + "green" : "0.329", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.575", + "green" : "0.329", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/Assets.xcassets/NordGreen.colorset/Contents.json b/InfiniLink/Assets.xcassets/NordGreen.colorset/Contents.json new file mode 100644 index 0000000..49f3332 --- /dev/null +++ b/InfiniLink/Assets.xcassets/NordGreen.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.443", + "green" : "0.562", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.443", + "green" : "0.561", + "red" : "0.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/InfiniLink/BLE/BLEManager.swift b/InfiniLink/BLE/BLEManager.swift index 4ddff48..942c41c 100644 --- a/InfiniLink/BLE/BLEManager.swift +++ b/InfiniLink/BLE/BLEManager.swift @@ -82,7 +82,6 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate { // Selecting and connecting variables @Published var peripherals = [Peripheral]() @Published var newPeripherals: [CBPeripheral] = [] // used to print human-readable device names to UI in selection process - // @Published var deviceToConnect: Int! // When the user selects a device from the UI, that peripheral's ID goes in this var, which is passed to the peripheralDictionary @Published var peripheralDictionary: [Int: CBPeripheral] = [:] // this is the dictionary that relates human-readable peripheral names to the CBPeripheral class that CoreBluetooth actually interacts with @Published var infiniTime: CBPeripheral! // variable to save the CBPeripheral that you're connecting to // @Published var autoconnectPeripheral: CBPeripheral! @@ -90,10 +89,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate { @Published var bleLogger = DebugLogManager.shared // MARK: logging - var firstConnect: Bool = true // makes iOS connected message only show up on first connect, not if device drops connection and reconnects + var firstConnect: Bool = true // makes iOS connected message only show up on first connect, not if device drops connection and reconnects var disconnected: Bool = false - var heartChartReconnect: Bool = true // skip first HRM transmission on every fresh connection to prevent saving of BS data - // var batChartReconnect: Bool = true // skip first HRM transmission on every fresh connection to prevent saving of BS data + var heartChartReconnect: Bool = true // declare some CBUUIDs for easier reference @Published var autoconnectToDevice: Bool = false diff --git a/InfiniLink/BLE/BLEManagerVariables.swift b/InfiniLink/BLE/BLEManagerVariables.swift index bf61b2e..2a8b342 100644 --- a/InfiniLink/BLE/BLEManagerVariables.swift +++ b/InfiniLink/BLE/BLEManagerVariables.swift @@ -36,14 +36,13 @@ class BLEManagerVal: NSObject, ObservableObject { @Published var watchFace: Int = -1 @Published var pineTimeStyleData: PineTimeStyleData? - @Published var infineatWatchface: WatchFaceInfineat? @Published var timeFormat: ClockType? + @Published var infineatColorIndex: UInt8 = 0 @Published var weatherInformation = WeatherInformation() @Published var loadingWeather = true - // UI flag variables - @Published var heartBPM: Double = 0 // published var to communicate the HRM data to the UI. + @Published var heartBPM: Double = 0 @Published var firmwareVersion: String = "" @@ -55,10 +54,4 @@ class BLEManagerVal: NSObject, ObservableObject { @Published var lastWeatherUpdateWAPI: Int = 0 @Published var latitude: Double = 0.0 @Published var longitude: Double = 0.0 - - // Selecting and connecting variables - @Published var deviceToConnect: Int! // When the user selects a device from the UI, that peripheral's ID goes in this var, which is passed to the peripheralDictionary - @Published var autoconnectPeripheral: CBPeripheral! - - var batChartReconnect: Bool = true // skip first HRM transmission on every fresh connection to prevent saving of BS data } diff --git a/InfiniLink/Core/Home/DFU/DFUWithBLE.swift b/InfiniLink/Core/Home/DFU/DFUWithBLE.swift index 205581a..bdc5f21 100644 --- a/InfiniLink/Core/Home/DFU/DFUWithBLE.swift +++ b/InfiniLink/Core/Home/DFU/DFUWithBLE.swift @@ -290,10 +290,10 @@ struct NoUpdate: View { Spacer() VStack { VStack(alignment: .center , spacing: 20) { - VStack(alignment: .center , spacing: 6) { + VStack(alignment: .center , spacing: 7) { Text("InfiniTime \(deviceInfo.firmware)") .foregroundColor(.gray) - .font(.title2.weight(.semibold)) + .font(.system(size: 24).weight(.semibold)) Text("InfiniTime " + NSLocalizedString("up_to_date", comment: "")) .foregroundColor(.gray) } diff --git a/InfiniLink/Core/Home/DeviceView.swift b/InfiniLink/Core/Home/DeviceView.swift index ed0ac40..31f07f9 100644 --- a/InfiniLink/Core/Home/DeviceView.swift +++ b/InfiniLink/Core/Home/DeviceView.swift @@ -423,11 +423,12 @@ struct CustomScrollView: View { DispatchQueue.main.async { BLEFSHandler.shared.readSettings { settings in self.settings = settings + print(settings) self.stepCountGoal = Int(settings.stepsGoal) self.bleManagerVal.watchFace = Int(settings.watchFace) self.bleManagerVal.pineTimeStyleData = settings.pineTimeStyle self.bleManagerVal.timeFormat = settings.clockType - self.bleManagerVal.infineatWatchface = settings.watchFaceInfineat + self.bleManagerVal.infineatColorIndex = settings.watchFaceInfineat.colorIndex switch settings.weatherFormat { case .Metric: self.deviceDataForSettings.chosenWeatherMode = "Metric" diff --git a/InfiniLink/Core/Home/WatchFace.swift b/InfiniLink/Core/Home/WatchFace.swift index 3e61381..d230678 100644 --- a/InfiniLink/Core/Home/WatchFace.swift +++ b/InfiniLink/Core/Home/WatchFace.swift @@ -330,45 +330,122 @@ struct InfineatWF: View { return true } } - func infineatColor(from color: Colors) -> Color { - switch color { - case .White: - return Color.white - case .Silver: - return Color.gray - case .Gray: - return Color.gray - case .Black: - return Color.black - case .Red: - return Color("Red") - case .Maroon: - return Color("Maroon") - case .Yellow: - return Color("Yellow") - case .Olive: - return Color.green - case .Green: - return Color.green - case .Cyan: - return Color.cyan - case .Teal: - return Color.teal - case .Blue: - return Color.blue - case .Navy: - return Color.blue - case .Magenta: - return Color.purple - case .Purple: - return Color.purple - case .Orange: - return Color("Orange") - case .Pink: - return Color.pink - default: - return Color.red + func infineatColor(for item: InfineatItem) -> Color { + /* + 0. orange + 1. blue + 2. green + 3. rainbow + 4. gray + 5. nordBlue + 6. nordGreen + + TODO: Add colors from watch face source + */ + + switch item { + case .base: + switch bleManagerVal.infineatColorIndex { + case 0: + return Color("Maroon") + case 1, 5: + return Color("Navy") + case 2, 6: + return Color("DarkGreen") + case 3: + return Color(.red) + case 4: + return Color.darkestGray + default: + break + } + case .bottom: + switch bleManagerVal.infineatColorIndex { + case 0: + return Color("Orange").opacity(0.9) + case 1: + return Color.blue.opacity(0.9) + case 2: + return Color("LightGreen").opacity(0.9) + case 3: + return Color.purple + case 4: + return Color.gray + case 5: + return Color("BabyBlue").opacity(0.9) + case 6: + return Color.mint.opacity(0.9) + default: + break + } + case .topTop: + switch bleManagerVal.infineatColorIndex { + case 0: + return Color("Orange") + case 1: + return Color("LightBlue") + case 2: + return Color("LightGreen") + case 3: + return Color("Yellow") + case 4: + return Color.gray + case 5: + return Color("BabyBlue") + case 6: + return Color.mint + default: + break + } + case .topBottom: + switch bleManagerVal.infineatColorIndex { + case 0: + return Color("Red") + case 1: + return Color.blue + case 2: + return Color("Green") + case 3: + return Color("Orange") + case 4: + return Color(.darkGray) + case 5: + return Color("NordBlue") + case 6: + return Color("NordGreen") + default: + break + } + case .midBottom: + switch bleManagerVal.infineatColorIndex { + case 0: + return Color("Yellow") + case 1, 4, 5, 6: + // 5 and 6 aren't perfectly white on the watch + return Color.white + case 2: + return Color("LightestGreen") + case 3: + return Color.blue + default: + break + } + case .midTop: + switch bleManagerVal.infineatColorIndex { + case 0: + return Color("Yellow") + case 1, 4, 5, 6: + // 5 and 6 aren't perfectly white on the watch + return Color.white + case 2: + return Color("LightestGreen") + case 3: + return Color("Green") + default: + break + } } + return .clear } var body: some View { @@ -422,57 +499,56 @@ struct InfineatWF: View { .foregroundColor(.gray) .frame(width: geometry.size.width, height: geometry.size.height, alignment: .bottom) .padding(.bottom, -16) - if bleManagerVal.infineatWatchface?.showSideCover ?? true { - ZStack { - Rectangle() - .frame(width: 19) - .frame(height: geometry.size.height / 1.5, alignment: .topLeading) - .frame(maxHeight: .infinity, alignment: .topLeading) - .foregroundColor(infineatColor(from: .Yellow)) - .rotationEffect(Angle(degrees: 49)) - .offset(x: -36, y: -44) - Rectangle() - .frame(width: 19) - .frame(height: geometry.size.height / 1.5, alignment: .bottomLeading) - .frame(maxHeight: .infinity, alignment: .bottomLeading) - .foregroundColor(infineatColor(from: .Orange)) - .opacity(0.8) - .rotationEffect(Angle(degrees: -16)) - .offset(x: -6, y: 12) - Rectangle() - .frame(width: 26, alignment: .leading) - .offset(x: -5) - .foregroundColor(infineatColor(from: .Maroon)) - Rectangle() - .frame(width: 26) - .frame(height: geometry.size.height / 1.5, alignment: .topLeading) - .frame(maxHeight: .infinity, alignment: .bottomLeading) - .foregroundColor(infineatColor(from: .Yellow)) - .rotationEffect(Angle(degrees: -38)) - .offset(x: -26, y: 30) - Rectangle() - .frame(width: 38) - .frame(height: geometry.size.height / 1.3, alignment: .topLeading) - .frame(maxHeight: .infinity, alignment: .topLeading) - .foregroundColor(infineatColor(from: .Orange)) - .rotationEffect(Angle(degrees: 18)) - .offset(x: -28, y: -16) - Rectangle() - .frame(width: 38) - .frame(height: geometry.size.height / 1.3, alignment: .topLeading) - .frame(maxHeight: .infinity, alignment: .bottomLeading) - .foregroundColor(infineatColor(from: .Red)) - .rotationEffect(Angle(degrees: -18)) - .offset(x: -28, y: 16) - } - .frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading) + ZStack { + Rectangle() + .frame(width: 19) + .frame(height: geometry.size.height / 1.5, alignment: .topLeading) + .frame(maxHeight: .infinity, alignment: .topLeading) + .foregroundColor(infineatColor(for: .midTop)) + .rotationEffect(Angle(degrees: 49)) + .offset(x: -36, y: -44) + Rectangle() + .frame(width: 19) + .frame(height: geometry.size.height / 1.5, alignment: .bottomLeading) + .frame(maxHeight: .infinity, alignment: .bottomLeading) + .foregroundColor(infineatColor(for: .bottom)) + .opacity(0.8) + .rotationEffect(Angle(degrees: -16)) + .offset(x: -6, y: 12) + Rectangle() + .frame(width: 26, alignment: .leading) + .offset(x: -5) + .foregroundColor(infineatColor(for: .base)) + Rectangle() + .frame(width: 26) + .frame(height: geometry.size.height / 1.5, alignment: .topLeading) + .frame(maxHeight: .infinity, alignment: .bottomLeading) + .foregroundColor(infineatColor(for: .midBottom)) + .rotationEffect(Angle(degrees: -38)) + .offset(x: -26, y: 30) + Rectangle() + .frame(width: 38) + .frame(height: geometry.size.height / 1.3, alignment: .topLeading) + .frame(maxHeight: .infinity, alignment: .topLeading) + .foregroundColor(infineatColor(for: .topTop)) + .rotationEffect(Angle(degrees: 18)) + .offset(x: -28, y: -16) + Rectangle() + .frame(width: 38) + .frame(height: geometry.size.height / 1.3, alignment: .topLeading) + .frame(maxHeight: .infinity, alignment: .bottomLeading) + .foregroundColor(infineatColor(for: .topBottom)) + .rotationEffect(Angle(degrees: -18)) + .offset(x: -28, y: 16) } + .frame(width: geometry.size.width, height: geometry.size.height, alignment: .leading) Image("pine_logo") .resizable() .frame(width: 20, height: 26) .frame(width: geometry.size.width / 1.15, height: geometry.size.height, alignment: .leading) } .frame(width: geometry.size.width, height: geometry.size.height, alignment: .center) + .clipped() } } @@ -681,6 +757,15 @@ struct CustomTextView: View { } } +enum InfineatItem { + case base + case bottom + case topTop + case topBottom + case midBottom + case midTop +} + #Preview { NavigationView { GeometryReader { geometry in @@ -688,6 +773,9 @@ struct CustomTextView: View { .padding(22) .frame(width: geometry.size.width / 1.65, height: geometry.size.width / 1.65, alignment: .center) .clipped(antialiased: true) + .onAppear { + BLEManagerVal.shared.infineatColorIndex = 6 + } } } }