Files
IYmtg/IYmtg_App_iOS/AppConfig.swift
Mike Wichers 24dcb44af4 Implement storage architecture from ai_blueprint.md
Primary sync: replace PersistenceActor JSON file with SwiftData + CloudKit
- Add SavedCardModel (@Model class) and PersistenceController (ModelContainer
  with .automatic CloudKit, fallback to local). BackgroundPersistenceActor
  (@ModelActor) handles all DB I/O off the main thread.
- One-time migration imports user_collection.json into SwiftData and renames
  the original file to prevent re-import.
- Inject modelContainer into SwiftUI environment in IYmtgApp.

Image storage: Documents/UserContent/ subfolder (blueprint requirement)
- ImageManager.dir now targets iCloud Documents/UserContent/ (or local equiv).
- migrateImagesToUserContent() moves existing JPGs to the new subfolder on
  first launch; called during the SwiftData migration.

Firebase: demoted to optional manual backup (metadata only, no images)
- Remove all automatic CloudEngine.save/delete/batchUpdatePrices calls from
  CollectionViewModel mutations.
- Add backupAllToFirebase() for user-triggered metadata sync.
- Add isFirebaseBackupEnabled to AppConfig (default false).
- Add Cloud Backup section in Library settings with iCloud vs Firebase
  explanation and "Backup Metadata to Firebase Now" button.

Also: full modular refactor (Data/, Features/, Services/ directories) and
README updated with CloudKit setup steps and revised release checklist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 12:13:17 -05:00

71 lines
2.4 KiB
Swift

import Foundation
enum CurrencyCode: String, CaseIterable, Codable {
case usd = "USD"
case eur = "EUR"
var symbol: String {
switch self {
case .usd: return "$"
case .eur: return ""
}
}
var scryfallKey: String {
switch self {
case .usd: return "usd"
case .eur: return "eur"
}
}
}
struct AppConfig {
// 1. CONTACT EMAIL (Required by Scryfall)
static let contactEmail = "support@iymtg.com" // Example: Use your real email
// 2. IN-APP PURCHASE ID (Use a "Consumable" type in App Store Connect for repeatable tips)
static let tipJarProductIDs: [String] = [] // Example: Use your real Product ID
// Feature Flags
static let enableFoilDetection = true
static let enableConditionGrading = true
static let enableSetSymbolDetection = true
static let enableStampDetection = true
static let defaultCurrency: CurrencyCode = .usd
struct Defaults {
static let masterCollectionName = "Master Collection"
static let unsortedBoxName = "Unsorted"
static let defaultCondition = "Near Mint (NM)"
static let defaultFoil = "None"
}
static var isTrainingOptIn: Bool {
get { UserDefaults.standard.bool(forKey: "TrainingOptIn") }
set { UserDefaults.standard.set(newValue, forKey: "TrainingOptIn") }
}
// Firebase secondary backup metadata only (no card images).
// Default: false. Users opt-in via the Cloud Backup section in Library settings.
static var isFirebaseBackupEnabled: Bool {
get { UserDefaults.standard.bool(forKey: "FirebaseBackupEnabled") }
set { UserDefaults.standard.set(newValue, forKey: "FirebaseBackupEnabled") }
}
static var scryfallUserAgent: String {
return "IYmtg/1.0 (\(contactEmail))"
}
static func validate() {
#if DEBUG
if contactEmail.contains("yourdomain.com") {
fatalError("🛑 SETUP ERROR: Change 'contactEmail' in AppConfig.swift to your real email.")
}
if tipJarProductIDs.isEmpty {
print("⚠️ CONFIG WARNING: 'tipJarProductIDs' is empty. Tip Jar will not be available.")
} else if let first = tipJarProductIDs.first, (first.contains("yourname") || first == "com.iymtg.app.tip") {
print("⚠️ CONFIG WARNING: 'tipJarProductIDs' contains placeholder. IAP will not load.")
}
#endif
}
}