mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
observe font change and contrast change in main app for macos
This commit is contained in:
parent
6b5f8b7443
commit
f4706205b0
2 changed files with 24 additions and 13 deletions
|
|
@ -9,8 +9,9 @@ import Views
|
|||
)
|
||||
@AppStorage(UserDefaultKey.preferredWebLineSpacing.rawValue) var storedLineSpacing = 150
|
||||
@AppStorage(UserDefaultKey.preferredWebMaxWidthPercentage.rawValue) var storedMaxWidthPercentage = 100
|
||||
@AppStorage(UserDefaultKey.preferredWebFont.rawValue) var preferredFont = WebFont.inter.rawValue
|
||||
@AppStorage(UserDefaultKey.prefersHighContrastWebFont.rawValue) var prefersHighContrastText = true
|
||||
|
||||
@Binding var preferredFont: String
|
||||
@Binding var prefersHighContrastText: Bool
|
||||
|
||||
public var fontSizeButtons: some View {
|
||||
Group {
|
||||
|
|
@ -76,7 +77,13 @@ import Views
|
|||
}
|
||||
}
|
||||
|
||||
public init() {}
|
||||
public init(
|
||||
preferredFont: Binding<String>,
|
||||
prefersHighContrastText: Binding<Bool>
|
||||
) {
|
||||
self._preferredFont = preferredFont
|
||||
self._prefersHighContrastText = prefersHighContrastText
|
||||
}
|
||||
|
||||
public var body: some Commands {
|
||||
CommandMenu("Reader Settings") {
|
||||
|
|
@ -96,20 +103,12 @@ import Views
|
|||
ForEach(WebFont.allCases, id: \.self) { font in
|
||||
Text(font.displayValue).tag(font.rawValue)
|
||||
}
|
||||
// TODO: fix this since it doesn't work
|
||||
.onChange(of: preferredFont) { _ in
|
||||
NSNotification.readerSettingsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
Toggle(
|
||||
isOn: $prefersHighContrastText,
|
||||
label: { Text("High Contrast Text") }
|
||||
)
|
||||
// TODO: fix this since it doesn't work
|
||||
.onChange(of: prefersHighContrastText) { _ in
|
||||
NSNotification.readerSettingsChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
// swiftlint:disable weak_delegate
|
||||
import App
|
||||
import SwiftUI
|
||||
import Utils
|
||||
|
||||
#if os(macOS)
|
||||
import AppKit
|
||||
import Views
|
||||
#elseif os(iOS)
|
||||
import Intercom
|
||||
import UIKit
|
||||
import Utils
|
||||
#endif
|
||||
|
||||
@main
|
||||
struct MainApp: App {
|
||||
#if os(macOS)
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
@AppStorage(UserDefaultKey.preferredWebFont.rawValue) var preferredFont = WebFont.inter.rawValue
|
||||
@AppStorage(UserDefaultKey.prefersHighContrastWebFont.rawValue) var prefersHighContrastText = true
|
||||
#elseif os(iOS)
|
||||
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
#endif
|
||||
|
|
@ -34,7 +37,16 @@ struct MainApp: App {
|
|||
RootView(intercomProvider: nil)
|
||||
}
|
||||
.commands {
|
||||
MacMenuCommands()
|
||||
MacMenuCommands(
|
||||
preferredFont: $preferredFont,
|
||||
prefersHighContrastText: $prefersHighContrastText
|
||||
)
|
||||
}
|
||||
.onChange(of: preferredFont) { _ in
|
||||
NSNotification.readerSettingsChanged()
|
||||
}
|
||||
.onChange(of: prefersHighContrastText) { _ in
|
||||
NSNotification.readerSettingsChanged()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue