payfrit-beacon-ios/PayfritBeacon/RootView.swift
John Pinkyfloyd 8c2320da44 Add ios-marketing idiom, iPad orientations, launch screen
- Fixed App Store icon display with ios-marketing idiom
- Added iPad orientation support for multitasking
- Added UILaunchScreen for iPad requirements
- Removed unused BLE permissions and files from build

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 19:38:11 -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
ServicePointListView(
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
}
}
}