Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
30ef5f13ed
commit
9e6ba26f5f
@ -7,6 +7,15 @@ import Bedrock
|
|||||||
final class SettingsStore: CloudSyncable {
|
final class SettingsStore: CloudSyncable {
|
||||||
@ObservationIgnored private let cloudSync = CloudSyncManager<AppSettingsData>()
|
@ObservationIgnored private let cloudSync = CloudSyncManager<AppSettingsData>()
|
||||||
|
|
||||||
|
/// Observable copy of last sync date, updated when sync completes.
|
||||||
|
private(set) var lastSyncDate: Date?
|
||||||
|
|
||||||
|
/// Observable copy of sync status, updated when sync state changes.
|
||||||
|
private(set) var syncStatus: String = ""
|
||||||
|
|
||||||
|
/// Observable copy of initial sync state.
|
||||||
|
private(set) var hasCompletedInitialSync: Bool = false
|
||||||
|
|
||||||
var hapticsEnabled: Bool {
|
var hapticsEnabled: Bool {
|
||||||
get { cloudSync.data.hapticsEnabled }
|
get { cloudSync.data.hapticsEnabled }
|
||||||
set { update { $0.hapticsEnabled = newValue } }
|
set { update { $0.hapticsEnabled = newValue } }
|
||||||
@ -24,22 +33,33 @@ final class SettingsStore: CloudSyncable {
|
|||||||
set { cloudSync.iCloudEnabled = newValue }
|
set { cloudSync.iCloudEnabled = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastSyncDate: Date? { cloudSync.lastSyncDate }
|
init() {
|
||||||
var syncStatus: String { cloudSync.syncStatus }
|
// Initialize observable properties from cloudSync
|
||||||
var hasCompletedInitialSync: Bool { cloudSync.hasCompletedInitialSync }
|
refreshSyncState()
|
||||||
|
}
|
||||||
|
|
||||||
func forceSync() {
|
func forceSync() {
|
||||||
cloudSync.sync()
|
cloudSync.sync()
|
||||||
|
refreshSyncState()
|
||||||
}
|
}
|
||||||
|
|
||||||
func refresh() {
|
func refresh() {
|
||||||
cloudSync.sync()
|
cloudSync.sync()
|
||||||
|
refreshSyncState()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func update(_ transform: (inout AppSettingsData) -> Void) {
|
private func update(_ transform: (inout AppSettingsData) -> Void) {
|
||||||
cloudSync.update { data in
|
cloudSync.update { data in
|
||||||
transform(&data)
|
transform(&data)
|
||||||
}
|
}
|
||||||
|
refreshSyncState()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Copies sync state from CloudSyncManager to observable properties.
|
||||||
|
private func refreshSyncState() {
|
||||||
|
lastSyncDate = cloudSync.lastSyncDate
|
||||||
|
syncStatus = cloudSync.syncStatus
|
||||||
|
hasCompletedInitialSync = cloudSync.hasCompletedInitialSync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ struct RitualMilestonesView: View {
|
|||||||
.frame(width: AppMetrics.Size.milestoneIcon, height: AppMetrics.Size.milestoneIcon)
|
.frame(width: AppMetrics.Size.milestoneIcon, height: AppMetrics.Size.milestoneIcon)
|
||||||
|
|
||||||
Image(systemName: milestone.symbolName)
|
Image(systemName: milestone.symbolName)
|
||||||
.font(.system(size: Design.BaseFontSize.caption))
|
.font(.caption)
|
||||||
.foregroundStyle(milestone.isAchieved ? AppStatus.success : AppTextColors.tertiary)
|
.foregroundStyle(milestone.isAchieved ? AppStatus.success : AppTextColors.tertiary)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -200,7 +200,7 @@ struct RitualDetailView: View {
|
|||||||
private var headerSection: some View {
|
private var headerSection: some View {
|
||||||
HStack(spacing: Design.Spacing.medium) {
|
HStack(spacing: Design.Spacing.medium) {
|
||||||
Image(systemName: ritual.iconName)
|
Image(systemName: ritual.iconName)
|
||||||
.font(.system(size: Design.BaseFontSize.largeTitle))
|
.font(.largeTitle)
|
||||||
.foregroundStyle(ritual.hasActiveArc ? AppAccent.primary : AppTextColors.secondary)
|
.foregroundStyle(ritual.hasActiveArc ? AppAccent.primary : AppTextColors.secondary)
|
||||||
.frame(width: 56, height: 56)
|
.frame(width: 56, height: 56)
|
||||||
.background((ritual.hasActiveArc ? AppAccent.primary : AppTextColors.secondary).opacity(0.1))
|
.background((ritual.hasActiveArc ? AppAccent.primary : AppTextColors.secondary).opacity(0.1))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user