spb/focale Public
Swift 100%
1//2// AppModel.swift3// Focale4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7//89import Foundation10import Observation11import Photos1213@MainActor14@Observable15final class AppModel {1617 let camera = CameraModel()18 let recipes = RecipeStore()19 let projects = ProjectStore()20 let albums = LivingAlbumStore()21 let placeProvider = PlaceProvider()22 let indexPipeline = IndexPipeline(container: IndexStore.container)23 let searchEngine = SearchEngine(container: IndexStore.container)2425 private(set) var photoAccess: PHAuthorizationStatus2627 init() {28 photoAccess = PHPhotoLibrary.authorizationStatus(for: .readWrite)29 camera.recipes = recipes30 camera.projects = projects31 camera.indexPipeline = indexPipeline32 camera.placeProvider = placeProvider33 }3435 /// Full access or nothing — in `.limited` the product cannot work36 /// (CLAUDE.md §2). `.limited` gets its own explanatory screen.37 var hasFullPhotoAccess: Bool { photoAccess == .authorized }38 var hasLimitedPhotoAccess: Bool { photoAccess == .limited }3940 func requestPhotoAccess() async {41 photoAccess = await PHPhotoLibrary.requestAuthorization(for: .readWrite)42 }4344 func refreshPhotoAccess() {45 photoAccess = PHPhotoLibrary.authorizationStatus(for: .readWrite)46 }47}48