Initial scaffold — NASBackup iOS app
Full project scaffold: XcodeGen project.yml, Core models/protocols/errors,
SMBService (kishikawakatsumi/SMBClient), SFTPService (Citadel 0.9.2),
PhotoLibraryService, LANMonitor, BackupEngine, BackgroundTaskManager,
all feature UIs (Login, Connect, Browse, Backup, History, Settings),
Shared components and theme. Builds clean with zero errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 17:05:04 +03:00
|
|
|
import Foundation
|
|
|
|
|
import Combine
|
|
|
|
|
|
|
|
|
|
private func ud<T: Decodable>(_ type: T.Type, key: String) -> T? {
|
|
|
|
|
guard let data = UserDefaults.standard.data(forKey: key) else { return nil }
|
|
|
|
|
return try? JSONDecoder().decode(type, from: data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func saveUD<T: Encodable>(_ value: T?, key: String) {
|
|
|
|
|
guard let value else { UserDefaults.standard.removeObject(forKey: key); return }
|
|
|
|
|
if let data = try? JSONEncoder().encode(value) { UserDefaults.standard.set(data, forKey: key) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final class ConnectionStore: ObservableObject {
|
|
|
|
|
static let shared = ConnectionStore()
|
|
|
|
|
|
|
|
|
|
@Published var savedConnection: NASConnection? {
|
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
|
|
|
didSet {
|
|
|
|
|
if let conn = savedConnection { SavedConnections.save(conn) }
|
|
|
|
|
else { SavedConnections.delete() }
|
|
|
|
|
}
|
Initial scaffold — NASBackup iOS app
Full project scaffold: XcodeGen project.yml, Core models/protocols/errors,
SMBService (kishikawakatsumi/SMBClient), SFTPService (Citadel 0.9.2),
PhotoLibraryService, LANMonitor, BackupEngine, BackgroundTaskManager,
all feature UIs (Login, Connect, Browse, Backup, History, Settings),
Shared components and theme. Builds clean with zero errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 17:05:04 +03:00
|
|
|
}
|
|
|
|
|
@Published var backupFilter: BackupFilter {
|
|
|
|
|
didSet { saveUD(backupFilter, key: "backupFilter") }
|
|
|
|
|
}
|
|
|
|
|
@Published var trustedSSIDs: [String] {
|
|
|
|
|
didSet { UserDefaults.standard.set(trustedSSIDs, forKey: "trustedSSIDs") }
|
|
|
|
|
}
|
|
|
|
|
@Published var lanTriggerEnabled: Bool {
|
|
|
|
|
didSet { UserDefaults.standard.set(lanTriggerEnabled, forKey: "lanTriggerEnabled") }
|
|
|
|
|
}
|
|
|
|
|
@Published var startDelaySeconds: Int {
|
|
|
|
|
didSet { UserDefaults.standard.set(startDelaySeconds, forKey: "startDelaySeconds") }
|
|
|
|
|
}
|
|
|
|
|
@Published var chargingOnlyMode: Bool {
|
|
|
|
|
didSet { UserDefaults.standard.set(chargingOnlyMode, forKey: "chargingOnlyMode") }
|
|
|
|
|
}
|
|
|
|
|
@Published var quietHoursEnabled: Bool {
|
|
|
|
|
didSet { UserDefaults.standard.set(quietHoursEnabled, forKey: "quietHoursEnabled") }
|
|
|
|
|
}
|
|
|
|
|
@Published var quietHoursStart: Int {
|
|
|
|
|
didSet { UserDefaults.standard.set(quietHoursStart, forKey: "quietHoursStart") }
|
|
|
|
|
}
|
|
|
|
|
@Published var quietHoursEnd: Int {
|
|
|
|
|
didSet { UserDefaults.standard.set(quietHoursEnd, forKey: "quietHoursEnd") }
|
|
|
|
|
}
|
Add cellular data toggle, Tailscale remote access, fix ToggleRow padding
- ToggleRow: fix cramped layout — proper horizontal + vertical card padding
- ConnectionStore: add allowCellularBackup, useTailscaleWhenRemote, tailscaleHost
- LANMonitor: add isOnCellular (NWPath cellular interface), isTailscaleActive
(detects utun interface with 100.x.x.x CGNAT address), openTailscaleApp()
- BackupEngine: gate backup on cellular setting; resolveHost() switches to
tailscaleHost when not on trusted LAN and Tailscale tunnel is active
- SettingsView: CONNECTIVITY section (cellular toggle + live status),
REMOTE ACCESS section (Tailscale toggle, host field, status dot, Open button)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:40:07 +03:00
|
|
|
|
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
|
|
|
// Session — not persisted, resets on every app launch
|
|
|
|
|
@Published var isSessionActive = false
|
|
|
|
|
|
|
|
|
|
// Onboarding — persisted so we only show each step once
|
|
|
|
|
@Published var onboardingPhotoShown: Bool {
|
|
|
|
|
didSet { UserDefaults.standard.set(onboardingPhotoShown, forKey: "onboardingPhotoShown") }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Appearance
|
|
|
|
|
@Published var appearanceMode: AppearanceMode {
|
|
|
|
|
didSet { UserDefaults.standard.set(appearanceMode.rawValue, forKey: "appearanceMode") }
|
|
|
|
|
}
|
|
|
|
|
|
Add cellular data toggle, Tailscale remote access, fix ToggleRow padding
- ToggleRow: fix cramped layout — proper horizontal + vertical card padding
- ConnectionStore: add allowCellularBackup, useTailscaleWhenRemote, tailscaleHost
- LANMonitor: add isOnCellular (NWPath cellular interface), isTailscaleActive
(detects utun interface with 100.x.x.x CGNAT address), openTailscaleApp()
- BackupEngine: gate backup on cellular setting; resolveHost() switches to
tailscaleHost when not on trusted LAN and Tailscale tunnel is active
- SettingsView: CONNECTIVITY section (cellular toggle + live status),
REMOTE ACCESS section (Tailscale toggle, host field, status dot, Open button)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:40:07 +03:00
|
|
|
// Cellular & remote access
|
|
|
|
|
@Published var allowCellularBackup: Bool {
|
|
|
|
|
didSet { UserDefaults.standard.set(allowCellularBackup, forKey: "allowCellularBackup") }
|
|
|
|
|
}
|
|
|
|
|
@Published var useTailscaleWhenRemote: Bool {
|
|
|
|
|
didSet { UserDefaults.standard.set(useTailscaleWhenRemote, forKey: "useTailscaleWhenRemote") }
|
|
|
|
|
}
|
|
|
|
|
@Published var tailscaleHost: String {
|
|
|
|
|
didSet { UserDefaults.standard.set(tailscaleHost, forKey: "tailscaleHost") }
|
|
|
|
|
}
|
|
|
|
|
|
Initial scaffold — NASBackup iOS app
Full project scaffold: XcodeGen project.yml, Core models/protocols/errors,
SMBService (kishikawakatsumi/SMBClient), SFTPService (Citadel 0.9.2),
PhotoLibraryService, LANMonitor, BackupEngine, BackgroundTaskManager,
all feature UIs (Login, Connect, Browse, Backup, History, Settings),
Shared components and theme. Builds clean with zero errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 17:05:04 +03:00
|
|
|
@Published private(set) var historyEntries: [BackupHistoryEntry] = []
|
|
|
|
|
|
|
|
|
|
private init() {
|
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
|
|
|
savedConnection = SavedConnections.load()
|
Add cellular data toggle, Tailscale remote access, fix ToggleRow padding
- ToggleRow: fix cramped layout — proper horizontal + vertical card padding
- ConnectionStore: add allowCellularBackup, useTailscaleWhenRemote, tailscaleHost
- LANMonitor: add isOnCellular (NWPath cellular interface), isTailscaleActive
(detects utun interface with 100.x.x.x CGNAT address), openTailscaleApp()
- BackupEngine: gate backup on cellular setting; resolveHost() switches to
tailscaleHost when not on trusted LAN and Tailscale tunnel is active
- SettingsView: CONNECTIVITY section (cellular toggle + live status),
REMOTE ACCESS section (Tailscale toggle, host field, status dot, Open button)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:40:07 +03:00
|
|
|
backupFilter = ud(BackupFilter.self, key: "backupFilter") ?? BackupFilter()
|
|
|
|
|
trustedSSIDs = UserDefaults.standard.stringArray(forKey: "trustedSSIDs") ?? []
|
|
|
|
|
lanTriggerEnabled = UserDefaults.standard.object(forKey: "lanTriggerEnabled") as? Bool ?? true
|
|
|
|
|
startDelaySeconds = UserDefaults.standard.object(forKey: "startDelaySeconds") as? Int ?? 30
|
|
|
|
|
chargingOnlyMode = UserDefaults.standard.object(forKey: "chargingOnlyMode") as? Bool ?? true
|
|
|
|
|
quietHoursEnabled = UserDefaults.standard.object(forKey: "quietHoursEnabled") as? Bool ?? false
|
|
|
|
|
quietHoursStart = UserDefaults.standard.object(forKey: "quietHoursStart") as? Int ?? 23
|
|
|
|
|
quietHoursEnd = UserDefaults.standard.object(forKey: "quietHoursEnd") as? Int ?? 7
|
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
|
|
|
onboardingPhotoShown = UserDefaults.standard.bool(forKey: "onboardingPhotoShown")
|
|
|
|
|
appearanceMode = AppearanceMode(rawValue: UserDefaults.standard.string(forKey: "appearanceMode") ?? "") ?? .system
|
Add cellular data toggle, Tailscale remote access, fix ToggleRow padding
- ToggleRow: fix cramped layout — proper horizontal + vertical card padding
- ConnectionStore: add allowCellularBackup, useTailscaleWhenRemote, tailscaleHost
- LANMonitor: add isOnCellular (NWPath cellular interface), isTailscaleActive
(detects utun interface with 100.x.x.x CGNAT address), openTailscaleApp()
- BackupEngine: gate backup on cellular setting; resolveHost() switches to
tailscaleHost when not on trusted LAN and Tailscale tunnel is active
- SettingsView: CONNECTIVITY section (cellular toggle + live status),
REMOTE ACCESS section (Tailscale toggle, host field, status dot, Open button)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 11:40:07 +03:00
|
|
|
allowCellularBackup = UserDefaults.standard.object(forKey: "allowCellularBackup") as? Bool ?? false
|
|
|
|
|
useTailscaleWhenRemote = UserDefaults.standard.object(forKey: "useTailscaleWhenRemote") as? Bool ?? false
|
|
|
|
|
tailscaleHost = UserDefaults.standard.string(forKey: "tailscaleHost") ?? ""
|
|
|
|
|
historyEntries = ud([BackupHistoryEntry].self, key: "historyEntries") ?? []
|
Initial scaffold — NASBackup iOS app
Full project scaffold: XcodeGen project.yml, Core models/protocols/errors,
SMBService (kishikawakatsumi/SMBClient), SFTPService (Citadel 0.9.2),
PhotoLibraryService, LANMonitor, BackupEngine, BackgroundTaskManager,
all feature UIs (Login, Connect, Browse, Backup, History, Settings),
Shared components and theme. Builds clean with zero errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 17:05:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func appendHistoryEntry(_ entry: BackupHistoryEntry) {
|
|
|
|
|
historyEntries.insert(entry, at: 0)
|
|
|
|
|
saveUD(historyEntries, key: "historyEntries")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func removeHistoryEntries(at offsets: IndexSet) {
|
|
|
|
|
historyEntries.remove(atOffsets: offsets)
|
|
|
|
|
saveUD(historyEntries, key: "historyEntries")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func clearHistory() {
|
|
|
|
|
historyEntries = []
|
|
|
|
|
UserDefaults.standard.removeObject(forKey: "historyEntries")
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-16 16:59:23 +03:00
|
|
|
/// Locks the screen — keeps the saved connection but requires Face ID again.
|
|
|
|
|
func lock() {
|
|
|
|
|
isSessionActive = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Clears everything: connection, session, and onboarding state. Returns to ConnectView.
|
fix: SMB share enumeration, BrowseView polish, sign out, Login branding
- Fix "Bad Network Name": BrowseView at root "/" for SMB now calls
listShares() instead of listDirectory with empty share name.
SMBClient.listShares() filters IPC/admin/hidden ($) shares.
- Add listShares() to NASTransferProtocol; implement in SMB (filters
ipc/special/$-suffix) and SFTP (returns []).
- BrowseView: premium error state (wifi.exclamationmark icon + Retry
button with ScaleButtonStyle), empty state, safeAreaInset bottom bar
replacing toolbar bottomBar (shows current path chip + compact Select
button), proper disabled state for root selection on SMB.
- FolderRow: replace hardcoded .white with AppTheme.inkInverse for dark
mode correctness; use folder.fill icon; ScaleButtonStyle for tap feedback.
- LoginView: larger logo (80pt), bolder "Kisani" wordmark (32pt bold),
tagline, staggered spring entrance animations (0.08-0.36s delay).
- SettingsView: Sign Out button in ACCOUNT section with
confirmationDialog (destructive, clears connection + resets session).
- ConnectionStore: signOut() resets isSessionActive, onboardingPhotoShown,
and clears savedConnection (triggers Keychain delete).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 16:41:16 +03:00
|
|
|
func signOut() {
|
|
|
|
|
isSessionActive = false
|
|
|
|
|
onboardingPhotoShown = false
|
|
|
|
|
savedConnection = nil
|
|
|
|
|
}
|
|
|
|
|
|
Initial scaffold — NASBackup iOS app
Full project scaffold: XcodeGen project.yml, Core models/protocols/errors,
SMBService (kishikawakatsumi/SMBClient), SFTPService (Citadel 0.9.2),
PhotoLibraryService, LANMonitor, BackupEngine, BackgroundTaskManager,
all feature UIs (Login, Connect, Browse, Backup, History, Settings),
Shared components and theme. Builds clean with zero errors.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-15 17:05:04 +03:00
|
|
|
var isInQuietHours: Bool {
|
|
|
|
|
guard quietHoursEnabled else { return false }
|
|
|
|
|
let hour = Calendar.current.component(.hour, from: Date())
|
|
|
|
|
if quietHoursStart > quietHoursEnd {
|
|
|
|
|
return hour >= quietHoursStart || hour < quietHoursEnd
|
|
|
|
|
}
|
|
|
|
|
return hour >= quietHoursStart && hour < quietHoursEnd
|
|
|
|
|
}
|
|
|
|
|
}
|