Set default new-post font from preferences view

This commit is contained in:
Angelo Stavrow 2020-09-18 11:40:06 -04:00
parent 4058985709
commit c4c36eeed7
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 49 additions and 13 deletions

View File

@ -105,6 +105,14 @@ struct PostListView: View {
managedPost.title = ""
managedPost.body = ""
managedPost.status = PostStatus.local.rawValue
switch model.preferences.font {
case 1:
managedPost.appearance = "sans"
case 2:
managedPost.appearance = "wrap"
default:
managedPost.appearance = "serif"
}
if let languageCode = Locale.current.languageCode {
managedPost.language = languageCode
managedPost.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft

View File

@ -4,20 +4,48 @@ struct PreferencesView: View {
@ObservedObject var preferences: PreferencesModel
var body: some View {
#if os(iOS)
Picker(selection: $preferences.appearance, label: Text("Appearance")) {
Text("System").tag(0)
Text("Light").tag(1)
Text("Dark").tag(2)
VStack {
VStack {
Text("Choose the preferred appearance for the app.")
.font(.caption)
.foregroundColor(.secondary)
Picker(selection: $preferences.appearance, label: Text("Appearance")) {
Text("System").tag(0)
Text("Light").tag(1)
Text("Dark").tag(2)
}
.pickerStyle(SegmentedPickerStyle())
}
.padding(.bottom)
VStack {
Text("Choose the default font for new posts.")
.font(.caption)
.foregroundColor(.secondary)
Picker(selection: $preferences.font, label: Text("Default Font")) {
Text("Serif").tag(0)
Text("Sans-Serif").tag(1)
Text("Monospace").tag(2)
}
.pickerStyle(SegmentedPickerStyle())
.padding(.bottom)
switch preferences.font {
case 1:
Text("Sample Text")
.frame(width: 240, height: 50, alignment: .center)
.font(.custom("OpenSans-Regular", size: 20))
case 2:
Text("Sample Text")
.frame(width: 240, height: 50, alignment: .center)
.font(.custom("Hack-Regular", size: 20))
default:
Text("Sample Text")
.frame(width: 240, height: 50, alignment: .center)
.font(.custom("Lora", size: 20))
}
}
.padding(.bottom)
}
.pickerStyle(SegmentedPickerStyle())
#elseif os(macOS)
Picker(selection: $preferences.appearance, label: Text("Appearance")) {
Text("System").tag(0)
Text("Light").tag(1)
Text("Dark").tag(2)
}
#endif
}
}