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>
This commit is contained in:
Robin Kutesa
2026-05-15 17:05:04 +03:00
commit b96711c535
44 changed files with 3412 additions and 0 deletions

View File

@@ -0,0 +1,152 @@
import SwiftUI
struct LANTriggerSection: View {
@EnvironmentObject var store: ConnectionStore
@EnvironmentObject var lanMonitor: LANMonitor
var body: some View {
VStack(alignment: .leading, spacing: 8) {
Text("AUTOMATION — LAN TRIGGER")
.font(AppTheme.smallFont)
.foregroundColor(AppTheme.textSecondary)
.padding(.leading, 4)
// Hero card blue border, FIXED 210px height, strict top-down layout
VStack(spacing: 0) {
// Header band
HStack {
Image(systemName: "wifi")
.font(.system(size: 14, weight: .medium))
.foregroundColor(.white)
Text("Auto-backup on home network")
.font(.system(size: 14, weight: .semibold))
.foregroundColor(.white)
Spacer()
Text(store.lanTriggerEnabled ? "On" : "Off")
.font(.system(size: 12, weight: .bold))
.foregroundColor(.white)
.padding(.horizontal, 8)
.padding(.vertical, 3)
.background(store.lanTriggerEnabled ? Color.white.opacity(0.25) : Color.white.opacity(0.15))
.clipShape(Capsule())
}
.padding(.horizontal, 14)
.padding(.vertical, 10)
.background(AppTheme.blue)
// Toggle row
HStack {
VStack(alignment: .leading, spacing: 2) {
Text("Start when on trusted Wi-Fi")
.font(.system(size: 14, weight: .medium))
.foregroundColor(AppTheme.textPrimary)
Text("Backup runs on SSID match")
.font(.system(size: 12))
.foregroundColor(AppTheme.textSecondary)
}
Spacer()
Toggle("", isOn: $store.lanTriggerEnabled)
.labelsHidden()
.tint(AppTheme.blue)
.scaleEffect(0.85)
}
.padding(.horizontal, 14)
.padding(.top, 10)
.padding(.bottom, 6)
Divider().padding(.horizontal, 14)
// Trusted networks
VStack(alignment: .leading, spacing: 4) {
Text("TRUSTED NETWORKS")
.font(.system(size: 10, weight: .semibold))
.foregroundColor(AppTheme.textTertiary)
.padding(.horizontal, 14)
.padding(.top, 6)
ForEach(store.trustedSSIDs, id: \.self) { ssid in
HStack(spacing: 8) {
Circle()
.fill(ssid == lanMonitor.currentSSID ? AppTheme.green : AppTheme.textTertiary)
.frame(width: 7, height: 7)
Text(ssid == lanMonitor.currentSSID ? "Connected" : "Saved")
.font(.system(size: 11))
.foregroundColor(AppTheme.textTertiary)
.frame(width: 54, alignment: .leading)
Text(ssid)
.font(.system(size: 13, weight: .medium))
.foregroundColor(AppTheme.textPrimary)
Spacer()
Button {
store.trustedSSIDs.removeAll { $0 == ssid }
} label: {
Image(systemName: "xmark")
.font(.system(size: 11, weight: .medium))
.foregroundColor(AppTheme.textTertiary)
}
}
.padding(.horizontal, 14)
.padding(.vertical, 2)
}
Button {
Task {
if let ssid = await lanMonitor.fetchCurrentSSID(),
!store.trustedSSIDs.contains(ssid) {
store.trustedSSIDs.append(ssid)
}
}
} label: {
HStack(spacing: 6) {
Image(systemName: "plus.circle.fill")
.font(.system(size: 13))
.foregroundColor(AppTheme.blue)
Text("Add current network")
.font(.system(size: 13, weight: .medium))
.foregroundColor(AppTheme.blue)
}
.padding(.horizontal, 14)
.padding(.vertical, 4)
}
}
Divider().padding(.horizontal, 14).padding(.top, 4)
// Bottom options row
HStack {
HStack(spacing: 6) {
Image(systemName: "timer")
.font(.system(size: 12))
.foregroundColor(AppTheme.textSecondary)
Text("Wait before starting")
.font(.system(size: 13))
.foregroundColor(AppTheme.textPrimary)
}
Spacer()
Menu {
ForEach([0, 15, 30, 60, 120], id: \.self) { sec in
Button("\(sec)s") { store.startDelaySeconds = sec }
}
} label: {
HStack(spacing: 4) {
Text("\(store.startDelaySeconds)s")
.font(.system(size: 13, weight: .medium))
.foregroundColor(AppTheme.blue)
Image(systemName: "chevron.right")
.font(.system(size: 11))
.foregroundColor(AppTheme.textTertiary)
}
}
}
.padding(.horizontal, 14)
.padding(.vertical, 8)
}
.frame(height: 210)
.clipShape(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius))
.overlay(
RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius)
.stroke(AppTheme.lanBorder, lineWidth: 1.5)
)
}
}
}

View File

@@ -0,0 +1,156 @@
import SwiftUI
struct SettingsView: View {
@EnvironmentObject var store: ConnectionStore
var body: some View {
ZStack {
Color.white.ignoresSafeArea()
ScrollView {
VStack(spacing: AppTheme.sectionSpacing) {
// LAN trigger hero section
LANTriggerSection()
// What to back up
mediaSection
// Quiet hours
quietHoursSection
// Notification section
notificationSection
Spacer(minLength: 40)
}
.padding(.horizontal, 20)
.padding(.top, 20)
}
}
.navigationTitle("Settings")
.navigationBarTitleDisplayMode(.inline)
}
// MARK: Media section
private var mediaSection: some View {
VStack(alignment: .leading, spacing: 8) {
Text("WHAT TO BACK UP")
.font(AppTheme.smallFont)
.foregroundColor(AppTheme.textSecondary)
.padding(.leading, 4)
VStack(spacing: 0) {
ToggleRow(icon: "photo", title: "Photos",
isOn: $store.backupFilter.includePhotos)
Divider().padding(.leading, 44)
ToggleRow(icon: "video", title: "Videos",
isOn: $store.backupFilter.includeVideos)
Divider().padding(.leading, 44)
ToggleRow(icon: "camera.viewfinder", title: "Screenshots",
isOn: $store.backupFilter.includeScreenshots)
Divider().padding(.leading, 44)
ToggleRow(icon: "rays", title: "RAW",
isOn: $store.backupFilter.includeRAW)
Divider().padding(.leading, 44)
ToggleRow(icon: "doc.badge.clock", title: "New files only",
subtitle: "Skip files already on NAS",
isOn: $store.backupFilter.newFilesOnly)
}
.padding(.horizontal, 16)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius))
.overlay(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius).stroke(AppTheme.cardBorder))
}
}
// MARK: Quiet hours
private var quietHoursSection: some View {
VStack(alignment: .leading, spacing: 8) {
Text("QUIET HOURS")
.font(AppTheme.smallFont)
.foregroundColor(AppTheme.textSecondary)
.padding(.leading, 4)
VStack(spacing: 0) {
ToggleRow(icon: "moon.fill", title: "Quiet hours",
subtitle: "No auto-backup during this window",
isOn: $store.quietHoursEnabled)
if store.quietHoursEnabled {
Divider().padding(.leading, 44)
timePickerRow(label: "Start", hour: $store.quietHoursStart)
Divider().padding(.leading, 44)
timePickerRow(label: "End", hour: $store.quietHoursEnd)
}
Divider().padding(.leading, 44)
ToggleRow(icon: "bolt.fill", title: "Only while charging",
subtitle: "Preserve battery on large libraries",
isOn: $store.chargingOnlyMode)
}
.padding(.horizontal, 16)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius))
.overlay(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius).stroke(AppTheme.cardBorder))
}
}
private func timePickerRow(label: String, hour: Binding<Int>) -> some View {
HStack {
Text(label)
.font(AppTheme.bodyFont)
.foregroundColor(AppTheme.textPrimary)
.frame(width: 80, alignment: .leading)
Spacer()
Picker(label, selection: hour) {
ForEach(0..<24, id: \.self) { h in
Text(String(format: "%02d:00", h)).tag(h)
}
}
.pickerStyle(.menu)
.tint(AppTheme.blue)
}
.padding(.vertical, 8)
}
// MARK: Notifications
private var notificationSection: some View {
VStack(alignment: .leading, spacing: 8) {
Text("NOTIFICATIONS")
.font(AppTheme.smallFont)
.foregroundColor(AppTheme.textSecondary)
.padding(.leading, 4)
VStack(spacing: 0) {
staticRow(icon: "bell.fill", title: "On start", value: "Off")
Divider().padding(.leading, 44)
staticRow(icon: "checkmark.circle.fill", title: "On complete", value: "On")
Divider().padding(.leading, 44)
staticRow(icon: "exclamationmark.triangle.fill", title: "On errors", value: "On")
}
.padding(.horizontal, 16)
.background(Color.white)
.clipShape(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius))
.overlay(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius).stroke(AppTheme.cardBorder))
}
}
private func staticRow(icon: String, title: String, value: String) -> some View {
HStack {
Image(systemName: icon)
.foregroundColor(AppTheme.blue)
.frame(width: 28)
Text(title)
.font(AppTheme.bodyFont)
.foregroundColor(AppTheme.textPrimary)
Spacer()
Text(value)
.font(AppTheme.bodyFont)
.foregroundColor(AppTheme.textSecondary)
}
.padding(.vertical, 12)
}
}