PropertyPersistentFlags.swift 1.1 KB

123456789101112131415161718192021222324252627282930
  1. //
  2. // PropertyPersistentFlags.swift
  3. // Trio
  4. //
  5. // Created by Cengiz Deniz on 06.05.25.
  6. //
  7. import Foundation
  8. /// Centralized store for app-wide persistent flags backed by property list (.plist) files.
  9. ///
  10. /// This class uses the `@PersistedProperty` wrapper to store simple state flags such as
  11. /// onboarding completion, diagnostics sharing preference, and the last cleanup timestamp.
  12. ///
  13. /// All values are persisted independently in the app’s documents directory as `.plist` files,
  14. /// and survive app restarts and reinstallations (unless the sandbox is cleared).
  15. ///
  16. /// Accessed as a singleton via `PropertyPersistentFlags.shared`.
  17. final class PropertyPersistentFlags {
  18. static let shared = PropertyPersistentFlags()
  19. @PersistedProperty(key: "onboardingCompleted") var onboardingCompleted: Bool?
  20. @PersistedProperty(key: "diagnosticsSharing") var diagnosticsSharingEnabled: Bool?
  21. @PersistedProperty(key: "lastCleanupDate") var lastCleanupDate: Date?
  22. // TODO: This flag can be deleted in March 2027. Check the commit for other places to cleanup.
  23. @PersistedProperty(key: "hasSeenFatProteinOrderChange") var hasSeenFatProteinOrderChange: Bool?
  24. }