Skip to content

Commit

Permalink
prefs: add option to reset layouts
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <82flex@gmail.com>
  • Loading branch information
Lessica committed Jan 15, 2024
1 parent 1cb18fd commit 497f953
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Reveil/Resources/Settings.bundle/Root.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Performance</string>
<key>FooterText</key>
<string>Restart “Reveil” to make things happen.</string>
</dict>
<dict>
<key>Type</key>
Expand Down Expand Up @@ -54,6 +52,24 @@
<key>DefaultValue</key>
<false/>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>Title</key>
<string>Dashboard</string>
<key>FooterText</key>
<string>Restart “Reveil” to make things happen.</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>Reset Layouts</string>
<key>Key</key>
<string>ResetLayouts</string>
<key>DefaultValue</key>
<false/>
</dict>
</array>
</dict>
</plist>
4 changes: 4 additions & 0 deletions Reveil/Resources/Settings.bundle/en.lproj/Root.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

"Animated Text" = "Animated Text";

"Dashboard" = "Dashboard";

"Enabled" = "Enabled";

"Group" = "Group";
Expand All @@ -16,4 +18,6 @@

"Performance" = "Performance";

"Reset Layouts" = "Reset Layouts";

"Restart “Reveil” to make things happen." = "Restart “Reveil” to make things happen.";
4 changes: 4 additions & 0 deletions Reveil/Resources/Settings.bundle/zh_Hans.lproj/Root.strings
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

"Animated Text" = "动态文字";

"Dashboard" = "仪表盘";

"Enabled" = "启用";

"Group" = "组";
Expand All @@ -16,4 +18,6 @@

"Performance" = "性能";

"Reset Layouts" = "还原布局";

"Restart “Reveil” to make things happen." = "重新打开 “Reveil” 以应用任何更改。";
4 changes: 4 additions & 0 deletions Reveil/Storage/PinStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ final class PinStorage: ObservableObject {

private init() {
pinnedEntryKeys = []
if StandardUserDefaults.shared.shouldResetLayouts {
resetDefaults()
StandardUserDefaults.shared.didResetLayouts()
}
reloadData()
registerNotifications()
try? registerDefaults()
Expand Down
11 changes: 11 additions & 0 deletions Reveil/Storage/StandardUserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ private let gDefaultsKeyLegacyUI = "LegacyUI"
private let gDefaultsKeyAnimatedText = "AnimatedText"
private let gDefaultsKeyAnimatedBackground = "AnimatedBackground"
private let gDefaultsKeyLowFrameRate = "LowFrameRate"
private let gDefaultsKeyResetLayouts = "ResetLayouts"

class StandardUserDefaults {
static let shared = StandardUserDefaults()

private init() {
UserDefaults.standard.register(defaults: [
gDefaultsKeyLegacyUI: false,
gDefaultsKeyAnimatedText: true,
gDefaultsKeyAnimatedBackground: true,
gDefaultsKeyLowFrameRate: false,
gDefaultsKeyResetLayouts: false,
])
}

Expand All @@ -38,4 +41,12 @@ class StandardUserDefaults {
lazy var isLowFrameRateEnabled: Bool = {
UserDefaults.standard.bool(forKey: gDefaultsKeyLowFrameRate)
}()

lazy var shouldResetLayouts: Bool = {
UserDefaults.standard.bool(forKey: gDefaultsKeyResetLayouts)
}()

func didResetLayouts() {
UserDefaults.standard.removeObject(forKey: gDefaultsKeyResetLayouts)
}
}

0 comments on commit 497f953

Please sign in to comment.