Files
Kisani/Features/Settings/LANTriggerSection.swift
Robin Kutesa ae38f6e417 feat: Kisani rebrand, step-based onboarding flow, dark mode fixes
- Rename app to Kisani in all UI text and Face ID prompt
- Replace flat 2-state RootView with 5-step flow: ConnectView →
  LoginView → FolderSetupView → PhotoPermissionView → MainTabView
- Remove NavigationStack from LoginView (was causing nested-stack crash);
  drive navigation via ConnectionStore.isSessionActive
- Add FolderSetupView and PhotoPermissionView onboarding screens with
  step indicator (2/3, 3/3), spring entrance animations, and UGreen
  connection chip
- Fix dark mode button invisibility: PrimaryButtonStyle and PillButtonStyle
  now use AppTheme.inkInverse; GhostButtonStyle border uses ink.opacity(0.25)
- Add AppTheme.inkInverse adaptive token (dark bg ink on dark, white on light)
- Add ConnectionStore.isSessionActive (non-persisted) and
  onboardingPhotoShown (UserDefaults-persisted)
- Add os_log logging in LoginViewModel at auth start/success/failure
- Remove dead Help button from ConnectView
- UGreenCompatibilityBadge, KeychainStore, SavedConnections, extensions,
  PrivacyInfo.xcprivacy, unit test target and test stubs
- AppTheme: full UIColor dynamic provider tokens for dark/light adaptive color
- AppearanceMode enum + segmented picker in SettingsView
- BackupView: enlarged ring, removed options card and linear progress bar
- HistoryView: duration and bytes formatting, improved typography hierarchy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:20:53 +03:00

156 lines
6.7 KiB
Swift

import SwiftUI
struct LANTriggerSection: View {
@EnvironmentObject var store: ConnectionStore
@EnvironmentObject var lanMonitor: LANMonitor
var body: some View {
VStack(alignment: .leading, spacing: 8) {
sectionLabel("AUTOMATION")
VStack(spacing: 0) {
// Master toggle row
HStack(spacing: 12) {
ZStack {
RoundedRectangle(cornerRadius: 7, style: .continuous)
.fill(store.lanTriggerEnabled ? AppTheme.ink : AppTheme.surfaceSunken)
.frame(width: 28, height: 28)
Image(systemName: "wifi")
.font(.system(size: 12, weight: .medium))
.foregroundStyle(store.lanTriggerEnabled ? .white : AppTheme.inkTertiary)
}
.animation(.spring(response: 0.25, dampingFraction: 0.8), value: store.lanTriggerEnabled)
VStack(alignment: .leading, spacing: 1) {
Text("Auto-backup on home network")
.font(AppTheme.headline())
.foregroundStyle(AppTheme.ink)
Text("Starts when a trusted Wi-Fi is joined")
.font(AppTheme.caption())
.foregroundStyle(AppTheme.inkTertiary)
}
Spacer()
Toggle("", isOn: $store.lanTriggerEnabled)
.labelsHidden()
.tint(AppTheme.ink)
}
.padding(AppTheme.cardPad)
hairline
// Trusted networks
VStack(alignment: .leading, spacing: 2) {
Text("TRUSTED NETWORKS")
.font(AppTheme.micro(10))
.foregroundStyle(AppTheme.inkTertiary)
.padding(.horizontal, AppTheme.cardPad)
.padding(.top, 10)
ForEach(store.trustedSSIDs, id: \.self) { ssid in
HStack(spacing: 10) {
Circle()
.fill(ssid == lanMonitor.currentSSID ? AppTheme.positive : AppTheme.inkQuaternary)
.frame(width: 6, height: 6)
Text(ssid)
.font(.system(size: 13, weight: .regular))
.foregroundStyle(AppTheme.ink)
if ssid == lanMonitor.currentSSID {
Text("connected")
.font(AppTheme.micro(10))
.foregroundStyle(AppTheme.positive)
}
Spacer()
Button {
withAnimation(.spring(response: 0.25, dampingFraction: 0.8)) {
store.trustedSSIDs.removeAll { $0 == ssid }
}
} label: {
Image(systemName: "xmark")
.font(.system(size: 11, weight: .medium))
.foregroundStyle(AppTheme.inkTertiary)
}
}
.padding(.horizontal, AppTheme.cardPad)
.padding(.vertical, 7)
}
Button {
Task {
if let ssid = await lanMonitor.fetchCurrentSSID(),
!store.trustedSSIDs.contains(ssid) {
withAnimation(.spring(response: 0.3, dampingFraction: 0.8)) {
store.trustedSSIDs.append(ssid)
}
}
}
} label: {
HStack(spacing: 6) {
Image(systemName: "plus")
.font(.system(size: 11, weight: .semibold))
Text("Add current network")
.font(.system(size: 13, weight: .medium))
}
.foregroundStyle(AppTheme.inkSecondary)
}
.buttonStyle(ScaleButtonStyle())
.padding(.horizontal, AppTheme.cardPad)
.padding(.vertical, 8)
}
hairline
// Delay picker
HStack {
Image(systemName: "timer")
.font(.system(size: 13, weight: .regular))
.foregroundStyle(AppTheme.inkSecondary)
.frame(width: 20)
Text("Wait before starting")
.font(AppTheme.body())
.foregroundStyle(AppTheme.ink)
Spacer()
Menu {
ForEach([0, 15, 30, 60, 120], id: \.self) { sec in
Button("\(sec == 0 ? "Immediately" : "\(sec)s")") {
store.startDelaySeconds = sec
}
}
} label: {
HStack(spacing: 4) {
Text(store.startDelaySeconds == 0 ? "Immediately" : "\(store.startDelaySeconds)s")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(AppTheme.inkSecondary)
Image(systemName: "chevron.up.chevron.down")
.font(.system(size: 10, weight: .medium))
.foregroundStyle(AppTheme.inkQuaternary)
}
}
}
.padding(.horizontal, AppTheme.cardPad)
.padding(.vertical, 12)
}
.background(AppTheme.surfaceRaised)
.clipShape(RoundedRectangle(cornerRadius: AppTheme.radius, style: .continuous))
.shadow(color: AppTheme.cardShadow, radius: 12, x: 0, y: 2)
}
}
private var hairline: some View {
Rectangle()
.fill(AppTheme.separator)
.frame(height: 0.5)
.padding(.leading, AppTheme.cardPad)
}
}
// MARK: Shared section header
func sectionLabel(_ text: String) -> some View {
Text(text)
.font(.system(size: 11, weight: .medium))
.foregroundStyle(AppTheme.inkTertiary)
.kerning(0.5)
.padding(.leading, 4)
}