mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Save and load default font in UserDefaults
This commit is contained in:
parent
41eba71e39
commit
2f4d4b8e73
@ -28,6 +28,7 @@ class WriteFreelyModel: ObservableObject {
|
||||
init() {
|
||||
DispatchQueue.main.async {
|
||||
self.preferences.appearance = self.defaults.integer(forKey: self.preferences.colorSchemeIntegerKey)
|
||||
self.preferences.font = self.defaults.integer(forKey: self.preferences.defaultFontIntegerKey)
|
||||
self.account.restoreState()
|
||||
if self.account.isLoggedIn {
|
||||
guard let serverURL = URL(string: self.account.server) else {
|
||||
|
@ -3,6 +3,7 @@ import SwiftUI
|
||||
class PreferencesModel: ObservableObject {
|
||||
private let defaults = UserDefaults.standard
|
||||
let colorSchemeIntegerKey = "colorSchemeIntegerKey"
|
||||
let defaultFontIntegerKey = "defaultFontIntegerKey"
|
||||
|
||||
/* We're stuck dropping into AppKit/UIKit to set light/dark schemes for now,
|
||||
* because setting the .preferredColorScheme modifier on views in SwiftUI is
|
||||
@ -56,4 +57,9 @@ class PreferencesModel: ObservableObject {
|
||||
defaults.set(appearance, forKey: colorSchemeIntegerKey)
|
||||
}
|
||||
}
|
||||
@Published var font: Int = 0 {
|
||||
didSet {
|
||||
defaults.set(font, forKey: defaultFontIntegerKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user