payfrit-beacon-ios/PayfritBeacon/RootView.swift
John Pinkyfloyd 962a767863 Rewrite app: simplified architecture, CoreLocation beacon scanning, UI fixes
- Flatten project structure: remove Models/, Services/, ViewModels/, Views/ subdirs
- Replace APIService actor with simpler Api class, IS_DEV flag controls dev vs prod URL
- Rewrite BeaconScanner to use CoreLocation (CLBeaconRegion ranging) instead of
  CoreBluetooth — iOS blocks iBeacon data from CBCentralManager
- Add SVG logo on login page with proper scaling (was showing green square)
- Make login page scrollable, add "enter 6-digit code" OTP instruction
- Fix text input visibility (white on white) with .foregroundColor(.primary)
- Add diagonal orange DEV ribbon banner (lower-left corner), gated on Api.IS_DEV
- Update app icon: logo 10% larger, wifi icon closer
- Add en.lproj/InfoPlist.strings for display name localization
- Fix scan flash: keep isScanning=true until enrichment completes
- Add Podfile with SVGKit, Kingfisher, CocoaLumberjack dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 22:07:39 -08:00

58 lines
1.8 KiB
Swift

import SwiftUI
struct RootView: View {
@State private var isAuthenticated = false
@State private var isCheckingAuth = true
@State private var userId: Int = 0
@State private var selectedBusiness: Business?
@State private var hasAutoSelected = false
var body: some View {
Group {
if isCheckingAuth {
VStack {
ProgressView()
}
} else if !isAuthenticated {
LoginView { token, uid in
userId = uid
isAuthenticated = true
}
} else {
BusinessListView(
hasAutoSelected: $hasAutoSelected,
onBusinessSelected: { business in
selectedBusiness = business
},
onLogout: {
isAuthenticated = false
selectedBusiness = nil
hasAutoSelected = false
}
)
.fullScreenCover(item: $selectedBusiness) { business in
ScanView(
businessId: business.businessId,
businessName: business.name,
onBack: { selectedBusiness = nil }
)
}
}
}
.modifier(DevBanner())
.onAppear {
checkAuth()
}
}
private func checkAuth() {
let token = UserDefaults.standard.string(forKey: "token")
let savedUserId = UserDefaults.standard.integer(forKey: "userId")
if let token = token, !token.isEmpty, savedUserId > 0 {
isCheckingAuth = false
} else {
isCheckingAuth = false
}
}
}