-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix location of AppChangeMigrator file
- Loading branch information
Showing
2 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// AppChangeMigrator.swift | ||
// Solstice | ||
// | ||
// Created by Daniel Eden on 19/06/2024. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AppChangeMigrator: ViewModifier { | ||
@AppStorage(Preferences.NotificationSettings._notificationTime) var notificationTime | ||
@AppStorage(Preferences.NotificationSettings.notificationDateComponents) var notificationDateComponents | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.task(id: "Notification schedule strategy migrator") { | ||
if notificationDateComponents == Preferences.NotificationSettings.defaultDateComponents { | ||
notificationDateComponents = Calendar.autoupdatingCurrent.dateComponents([.hour, .minute], from: notificationTime) | ||
} | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
func migrateAppFeatures() -> some View { | ||
self.modifier(AppChangeMigrator()) | ||
} | ||
} |