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>
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import Foundation
|
||||
import UserNotifications
|
||||
import os.log
|
||||
|
||||
private let logger = Logger(subsystem: "com.albert.nasbackup", category: "BackupEngine")
|
||||
|
||||
@MainActor
|
||||
final class BackupEngine: ObservableObject {
|
||||
@@ -7,11 +10,30 @@ final class BackupEngine: ObservableObject {
|
||||
|
||||
@Published private(set) var job: BackupJob = BackupJob()
|
||||
|
||||
private let photoService: PhotoLibraryProtocol = PhotoLibraryService()
|
||||
private let photoService: PhotoLibraryProtocol
|
||||
private let transferFactory: (NASProtocol) -> any NASTransferProtocol
|
||||
private var activeTransfer: (any NASTransferProtocol)?
|
||||
private var isCancelled = false
|
||||
|
||||
private init() {}
|
||||
private init(
|
||||
photos: PhotoLibraryProtocol = PhotoLibraryService(),
|
||||
transferFactory: @escaping (NASProtocol) -> any NASTransferProtocol = { proto in
|
||||
switch proto {
|
||||
case .smb: return SMBService()
|
||||
case .sftp: return SFTPService()
|
||||
}
|
||||
}
|
||||
) {
|
||||
self.photoService = photos
|
||||
self.transferFactory = transferFactory
|
||||
}
|
||||
|
||||
static func testInstance(
|
||||
transfer: any NASTransferProtocol,
|
||||
photos: PhotoLibraryProtocol
|
||||
) -> BackupEngine {
|
||||
BackupEngine(photos: photos, transferFactory: { _ in transfer })
|
||||
}
|
||||
|
||||
func run(
|
||||
connection: NASConnection,
|
||||
@@ -36,11 +58,7 @@ final class BackupEngine: ObservableObject {
|
||||
let assets = photoService.fetchAssets(filter: filter)
|
||||
|
||||
// 2. Connect to NAS
|
||||
let transfer: any NASTransferProtocol
|
||||
switch connection.nasProtocol {
|
||||
case .smb: transfer = SMBService()
|
||||
case .sftp: transfer = SFTPService()
|
||||
}
|
||||
let transfer = transferFactory(connection.nasProtocol)
|
||||
|
||||
try await transfer.connect(
|
||||
to: host,
|
||||
@@ -102,6 +120,7 @@ final class BackupEngine: ObservableObject {
|
||||
job.fileCompleted(skipped: false)
|
||||
uploaded += 1
|
||||
} catch {
|
||||
logger.error("Upload failed for \(asset.filename, privacy: .public): \(error.localizedDescription, privacy: .public)")
|
||||
job.fileFailed()
|
||||
failed += 1
|
||||
}
|
||||
|
||||
@@ -44,25 +44,26 @@ final class PhotoLibraryService: PhotoLibraryProtocol {
|
||||
let result = PHAsset.fetchAssets(with: options)
|
||||
var assets: [PhotoAsset] = []
|
||||
result.enumerateObjects { asset, _, _ in
|
||||
let isScreenshot = asset.mediaSubtypes.contains(.photoScreenshot)
|
||||
let resources = PHAssetResource.assetResources(for: asset)
|
||||
// RAW files are identified by an alternate photo resource (RAW+JPEG pairs)
|
||||
let isRAW = resources.contains { $0.type == .alternatePhoto }
|
||||
if isRAW && !filter.includeRAW { return }
|
||||
autoreleasepool {
|
||||
let isScreenshot = asset.mediaSubtypes.contains(.photoScreenshot)
|
||||
let resources = PHAssetResource.assetResources(for: asset)
|
||||
let isRAW = resources.contains { $0.type == .alternatePhoto }
|
||||
if isRAW && !filter.includeRAW { return }
|
||||
|
||||
let filename = resources.first?.originalFilename ?? "\(asset.localIdentifier).jpg"
|
||||
let filename = resources.first?.originalFilename ?? "\(asset.localIdentifier).jpg"
|
||||
|
||||
assets.append(PhotoAsset(
|
||||
localIdentifier: asset.localIdentifier,
|
||||
filename: filename,
|
||||
creationDate: asset.creationDate,
|
||||
mediaType: asset.mediaType,
|
||||
pixelWidth: asset.pixelWidth,
|
||||
pixelHeight: asset.pixelHeight,
|
||||
duration: asset.duration,
|
||||
isScreenshot: isScreenshot,
|
||||
isRAW: isRAW
|
||||
))
|
||||
assets.append(PhotoAsset(
|
||||
localIdentifier: asset.localIdentifier,
|
||||
filename: filename,
|
||||
creationDate: asset.creationDate,
|
||||
mediaType: asset.mediaType,
|
||||
pixelWidth: asset.pixelWidth,
|
||||
pixelHeight: asset.pixelHeight,
|
||||
duration: asset.duration,
|
||||
isScreenshot: isScreenshot,
|
||||
isRAW: isRAW
|
||||
))
|
||||
}
|
||||
}
|
||||
return assets
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user