From e13d7d30c1ca67477a96a602cc350b4436097b19 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 14:04:19 +0800 Subject: [PATCH] Add reset reader settings --- .../Sources/App/MacMenuCommands.swift | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index 8616567d6..aab150d3c 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -84,6 +84,26 @@ import Views } } + public var resetButton: some View { + Group { + Button( + action: { + storedLineSpacing = max(storedLineSpacing - 25, 100) + + ThemeManager.currentThemeName = Theme.system.rawValue + storedFontSize = 16 + storedLineSpacing = 150 + storedMaxWidthPercentage = 80 + preferredFont = WebFont.inter.rawValue + prefersHighContrastText = true + + NSNotification.readerSettingsChanged() + }, + label: { Text("Reset") } + ) + } + } + public init( preferredFont: Binding, prefersHighContrastText: Binding, @@ -96,8 +116,8 @@ import Views self._currentThemeName = currentThemeName } - public var body: some Commands { - CommandMenu("Reader Display") { + var spacingButtons: some View { + Group { fontSizeButtons Divider() @@ -109,6 +129,12 @@ import Views lineSpacingButtons Divider() + } + } + + public var body: some Commands { + CommandMenu("Reader Display") { + spacingButtons Picker(selection: $preferredFont, label: Text(LocalText.genericFontFamily)) { ForEach(WebFont.allCases, id: \.self) { font in @@ -120,8 +146,6 @@ import Views ForEach(Theme.allCases, id: \.self) { theme in Text(theme.rawValue).tag(theme.rawValue).tag(theme.rawValue) } - }.onChange(of: currentThemeName) { _ in - NSNotification.readerSettingsChanged() } Toggle( @@ -133,6 +157,10 @@ import Views isOn: $justifyText, label: { Text(LocalText.enableJustifyText) } ) + + Divider() + + resetButton } } }