ironOS native ios app
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: better scanning

+36 -29
ios/PinecilTime.xcodeproj/project.xcworkspace/xcuserdata/kierank.xcuserdatad/UserInterfaceState.xcuserstate

This is a binary file and will not be displayed.

+9 -8
ios/PinecilTime/BLEManager.swift
··· 28 28 private var centralManager: CBCentralManager! 29 29 private var discoveredCharacteristics: [CBUUID: CBCharacteristic] = [:] 30 30 private var pollTimer: Timer? 31 + private var scanTimer: Timer? 31 32 32 33 // MARK: - Init 33 34 ··· 55 56 func startScanning() { 56 57 guard centralManager.state == .poweredOn else { return } 57 58 59 + scanTimer?.invalidate() 58 60 discoveredDevices.removeAll() 59 61 connectionState = .scanning 60 62 ··· 64 66 ) 65 67 66 68 isScanning = true 69 + 70 + // Timeout after 10 seconds 71 + scanTimer = Timer.scheduledTimer(withTimeInterval: 10, repeats: false) { [weak self] _ in 72 + self?.stopScanning() 73 + } 67 74 } 68 75 69 76 func stopScanning() { 77 + scanTimer?.invalidate() 78 + scanTimer = nil 70 79 centralManager.stopScan() 71 80 isScanning = false 72 81 if connectionState == .scanning { ··· 229 238 error: Error?) { 230 239 connectionState = .error(error?.localizedDescription ?? "Connection failed") 231 240 connectedPeripheral = nil 232 - 233 - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in 234 - self?.startScanning() 235 - } 236 241 } 237 242 238 243 func centralManager(_ central: CBCentralManager, ··· 242 247 connectionState = .disconnected 243 248 connectedPeripheral = nil 244 249 discoveredCharacteristics.removeAll() 245 - 246 - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in 247 - self?.startScanning() 248 - } 249 250 } 250 251 } 251 252
+27 -21
ios/PinecilTime/ContentView.swift
··· 207 207 // MARK: - Scanning View 208 208 209 209 private var scanningView: some View { 210 - VStack(spacing: 24) { 211 - Spacer() 210 + ZStack { 211 + Color.black.opacity(0.4) 212 + .ignoresSafeArea() 212 213 213 - if bleManager.isScanning || bleManager.connectionState == .connecting { 214 - ProgressView() 215 - .scaleEffect(1.5) 214 + VStack(spacing: 20) { 215 + if bleManager.isScanning || bleManager.connectionState == .connecting { 216 + ProgressView() 217 + .scaleEffect(1.2) 218 + .padding(.bottom, 4) 216 219 217 - Text(bleManager.connectionState == .connecting ? "Connecting..." : "Scanning...") 218 - .font(.headline) 220 + Text(bleManager.connectionState == .connecting ? "Connecting..." : "Scanning...") 221 + .font(.headline) 219 222 220 - Text("Looking for your Pinecil") 221 - .font(.subheadline) 222 - .foregroundStyle(.secondary) 223 - } else { 224 - Image(systemName: "antenna.radiowaves.left.and.right.slash") 225 - .font(.system(size: 48)) 226 - .foregroundStyle(.secondary) 223 + Text("Looking for your Pinecil") 224 + .font(.subheadline) 225 + .foregroundStyle(.secondary) 226 + } else { 227 + Image(systemName: "antenna.radiowaves.left.and.right.slash") 228 + .font(.system(size: 36)) 229 + .foregroundStyle(.secondary) 230 + .padding(.bottom, 4) 227 231 228 - Text("No Device Found") 229 - .font(.headline) 232 + Text("No Device Found") 233 + .font(.headline) 230 234 231 - Button("Scan Again") { 232 - bleManager.startScanning() 235 + Button("Scan Again") { 236 + bleManager.startScanning() 237 + } 238 + .buttonStyle(.borderedProminent) 233 239 } 234 - .buttonStyle(.borderedProminent) 235 240 } 236 - 237 - Spacer() 241 + .padding(32) 242 + .background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 24)) 243 + .shadow(color: .black.opacity(0.2), radius: 20) 238 244 } 239 245 } 240 246 }