Skip to content

Commit

Permalink
General: clean up, make connect sheet dismiss on connect, minor impro…
Browse files Browse the repository at this point in the history
…vements
  • Loading branch information
liamcharger committed Jul 12, 2024
1 parent 32cd805 commit 0a6ef49
Show file tree
Hide file tree
Showing 28 changed files with 16 additions and 36 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions InfiniLink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@
isa = PBXGroup;
children = (
E0C0E8632B96D4E90021E4AE /* Home */,
E0C0E8672B96D5610021E4AE /* Steps */,
E0C0E8692B96D5BB0021E4AE /* DFU */,
E0C0E86A2B96D5DD0021E4AE /* Heart */,
E0C0E8702B96D6850021E4AE /* Battery */,
E0C0E87B2B96E9310021E4AE /* Settings */,
E03544142B59648D00FEA7AA /* Weather */,
E0C0E8652B96D5260021E4AE /* Welcome */,
Expand All @@ -469,10 +473,6 @@
E0C0E8632B96D4E90021E4AE /* Home */ = {
isa = PBXGroup;
children = (
E0C0E8702B96D6850021E4AE /* Battery */,
E0C0E86A2B96D5DD0021E4AE /* Heart */,
E0C0E8692B96D5BB0021E4AE /* DFU */,
E0C0E8672B96D5610021E4AE /* Steps */,
E515FB14284C56070040B582 /* DeviceView.swift */,
E5EEB1D32803438200FB0C11 /* RenameView.swift */,
E0F599402B76CABF00BE96A3 /* FileSystemView.swift */,
Expand Down
27 changes: 9 additions & 18 deletions InfiniLink/BLE/BLEManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,14 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate {
let lengthTrack = CBUUID(string: "00000007-78FC-48FE-8E23-433B3A1942D0")
}

// let cbuuidList = cbuuidList()
// var musicChars = musicCharacteristics()
//
// let settings = UserDefaults.standard


// UI flag variables
@Published var isSwitchedOn = false // for now this is used to display if bluetooth is on in the main app screen. maybe an alert in the future?
@Published var isScanning = false // another UI flag. Probably not necessary for anything but debugging. I dunno maybe a little swirly animation or something could be triggered by this
@Published var isConnectedToPinetime = false // another flag published to update UI stuff. Can probably be implemented better in the future
// @Published var heartBPM: Double = 0 // published var to communicate the HRM data to the UI.
@Published var batteryLevel: Double = 0 // Same as heartBPM but for battery data
// @Published var firmwareVersion: String = "Disconnected"
@Published var isSwitchedOn = false
@Published var isScanning = false
@Published var isConnectedToPinetime = false
@Published var rssi: Int = 0
@Published var batteryLevel: Double = 0
@Published var setTimeError = false
@Published var blePermissions: Bool!

// @Published var stepCount: Int = 0
// @Published var stepCounting: Int = 0

// Selecting and connecting variables
@Published var peripherals = [Peripheral]()
@Published var newPeripherals: [CBPeripheral] = [] // used to print human-readable device names to UI in selection process
Expand All @@ -87,7 +76,7 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate {
// @Published var autoconnectPeripheral: CBPeripheral!
@Published var setAutoconnectUUID: String = "" // placeholder for now while I figure out how to save the whole device in UserDefaults to save "favorite" devices

@Published var bleLogger = DebugLogManager.shared // MARK: logging
@Published var bleLogger = DebugLogManager.shared

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
Expand Down Expand Up @@ -185,6 +174,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate {
DeviceInfoManager().setDeviceName(uuid: peripheral.identifier.uuidString)
UptimeManager.shared.connectTime = Date()
bleLogger.debug(error: "Successfully connected to \(peripheral.name!)", log: .ble, date: Date())
if SheetManager.shared.sheetSelection == .connect {
SheetManager.shared.showSheet = false
}
ChartManager.shared.addItem(dataPoint: DataPoint(date: Date(), value: 1, chart: ChartsAsInts.connected.rawValue))
}

Expand All @@ -204,7 +196,6 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate {
}

func centralManagerDidUpdateState(_ central: CBCentralManager) {

if central.state == .poweredOn {
isSwitchedOn = true
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 1 addition & 13 deletions InfiniLink/Core/Home/DeviceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ struct DeviceView: View {
Image(systemName: "chevron.right")
.font(.body.weight(.medium))
}
.aspectRatio(1, contentMode: .fill)
.padding()
.background(Color.green)
.foregroundColor(.white)
Expand All @@ -76,14 +75,13 @@ struct DeviceView: View {
NavigationLink(destination: DFUView()) {
ZStack(alignment: .topTrailing) {
HStack {
Text(NSLocalizedString("software_update", comment: ""))
Text(NSLocalizedString("software_update_w/n", comment: ""))
.multilineTextAlignment(.leading)
.font(.title3.weight(.semibold))
Spacer()
Image(systemName: "chevron.right")
.font(.body.weight(.medium))
}
.aspectRatio(1, contentMode: .fill)
.padding()
.background(Material.regular)
.foregroundColor(.primary)
Expand All @@ -109,7 +107,6 @@ struct DeviceView: View {
Image(systemName: "chevron.right")
.font(.body.weight(.medium))
}
.aspectRatio(1, contentMode: .fill)
.padding()
.background(Color.blue)
.foregroundColor(.white)
Expand All @@ -126,7 +123,6 @@ struct DeviceView: View {
Image(systemName: "chevron.right")
.font(.body.weight(.medium))
}
.aspectRatio(1, contentMode: .fill)
.padding()
.background(Color.red)
.foregroundColor(.white)
Expand Down Expand Up @@ -172,14 +168,6 @@ struct DeviceView: View {
}
.disabled(!networkManager.getNetworkState())
.opacity(!networkManager.getNetworkState() ? 0.4 : 1.0)
.overlay {
if !networkManager.getNetworkState() {
Image(systemName: "wifi.slash")
.foregroundColor(.white)
.font(.system(size: 35).weight(.semibold))
.frame(maxWidth: .infinity, alignment: .center)
}
}
Spacer()
.frame(height: 6)
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion InfiniLink/Core/Weather/WeatherController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class WeatherController: NSObject, ObservableObject, CLLocationManagerDelegate {
return 0
case "Partly cloudly":
return 1
case "Cloudly", "Overcast", "Patchy rain possible", "Patchy sleet possible", "Patchy freezing drizzle possible", "Thundery outbreaks possible":
case "Cloudly", "Overcast", "Patchy rain possible", "Patchy sleet possible", "Patchy rain nearby", "Patchy freezing drizzle possible", "Thundery outbreaks possible":
return 2
case "Patchy light drizzle", "Heavy freezing drizzle", "Drizzle", "Light rain", "Moderate rain", "Moderate rain at times", "Heavy rain at times", "Heavy rain", "Light freezing rain", "Moderate or heavy freezing rain", "Ice pellets", "Light rain shower", "Moderate or heavy rain shower", "Torrential rain shower", "Light sleet showers", "Moderate or heavy sleet showers", "Light showers of ice pellets", "Moderate or heavy showers of ice pellets":
return 4
Expand Down
1 change: 1 addition & 0 deletions InfiniLink/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
"downloads" = "Downloads";
"learn_more" = "Learn More";
"software_update" = "Software Update";
"software_update_w/n" = "Software\nUpdate";
"local_file_info" = "This is a local file and may not work with your PineTime.";
"install_older_version" = "Install Older Version";
"up_to_date" = "is up to date";
Expand Down

0 comments on commit 0a6ef49

Please sign in to comment.