Compare commits

..

No commits in common. "a6ba88803cef7bb97ae5ed025be4a619a0312700" and "1624e0e59d7baa33d7813f8d6bb7852182d557d8" have entirely different histories.

4 changed files with 16 additions and 41 deletions

View file

@ -14,9 +14,6 @@ final class AppState: ObservableObject {
@Published var token: String?
@Published var userId: String?
/// When true, skip auto-navigation in BusinessListView (user explicitly went back)
var skipAutoNav = false
init() {
// Restore saved session
if let saved = SecureStorage.loadSession() {
@ -39,8 +36,6 @@ final class AppState: ObservableObject {
}
func backToBusinessList() {
AppPrefs.lastBusinessId = nil
skipAutoNav = true
currentScreen = .businessList
}

View file

@ -22,8 +22,6 @@
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Payfrit Beacon needs camera access to scan QR codes on beacon labels for provisioning.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Payfrit Beacon needs Bluetooth to detect and configure nearby beacons.</string>
<key>NSBluetoothPeripheralUsageDescription</key>

View file

@ -94,22 +94,18 @@ struct BusinessListView: View {
let list = try await APIClient.shared.listBusinesses(token: token)
businesses = list
// Skip auto-navigation if user explicitly tapped Back
if !appState.skipAutoNav {
// Auto-navigate if only one business (like Android)
if list.count == 1, let only = list.first {
appState.selectBusiness(only)
return
}
// Auto-navigate to last used business
if let lastId = AppPrefs.lastBusinessId,
let last = list.first(where: { $0.id == lastId }) {
appState.selectBusiness(last)
return
}
// Auto-navigate if only one business (like Android)
if list.count == 1, let only = list.first {
appState.selectBusiness(only)
return
}
// Auto-navigate to last used business
if let lastId = AppPrefs.lastBusinessId,
let last = list.first(where: { $0.id == lastId }) {
appState.selectBusiness(last)
return
}
appState.skipAutoNav = false
} catch let e as APIError where e.errorDescription == APIError.unauthorized.errorDescription {
appState.logout()
} catch {

View file

@ -241,31 +241,17 @@ final class CameraPreviewUIView: UIView {
func setFlash(_ on: Bool) {
guard let device = AVCaptureDevice.default(for: .video),
device.hasTorch else { return }
do {
try device.lockForConfiguration()
device.torchMode = on ? .on : .off
device.unlockForConfiguration()
} catch {
NSLog("[QRScanner] Failed to set torch: \(error.localizedDescription)")
}
try? device.lockForConfiguration()
device.torchMode = on ? .on : .off
device.unlockForConfiguration()
}
private func setupCamera() {
let session = AVCaptureSession()
session.sessionPreset = .high
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else {
NSLog("[QRScanner] ERROR: No back camera available")
return
}
let input: AVCaptureDeviceInput
do {
input = try AVCaptureDeviceInput(device: device)
} catch {
NSLog("[QRScanner] ERROR: Failed to create camera input: \(error.localizedDescription)")
return
}
guard let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back),
let input = try? AVCaptureDeviceInput(device: device) else { return }
if session.canAddInput(input) {
session.addInput(input)