Cleanup display settings

This commit is contained in:
Thomas Ricouard 2023-03-03 08:29:45 +01:00
parent db5d0b9274
commit 5766adc965

View File

@ -25,11 +25,26 @@ struct DisplaySettingsView: View {
routerPath: RouterPath()) // translate from latin button
var body: some View {
Form {
exampleSection
themeSection
fontSection
layoutSection
platformsSection
resetSection
}
.navigationTitle("settings.display.navigation-title")
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
private var exampleSection: some View {
Section("settings.display.example-toot") {
StatusRowView(viewModel: { previewStatusViewModel })
.allowsHitTesting(false)
}
}
private var themeSection: some View {
Section {
Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme)
themeSelectorButton
@ -78,7 +93,9 @@ struct DisplaySettingsView: View {
}
}
.listRowBackground(theme.primaryBackgroundColor)
}
private var fontSection: some View {
Section("settings.display.section.font") {
Picker("settings.display.font", selection: .init(get: { () -> FontState in
if theme.chosenFont?.fontName == "OpenDyslexic-Regular" {
@ -119,7 +136,9 @@ struct DisplaySettingsView: View {
}
}
.listRowBackground(theme.primaryBackgroundColor)
}
private var layoutSection: some View {
Section("settings.display.section.display") {
Picker("settings.display.avatar.position", selection: $theme.avatarPosition) {
ForEach(Theme.AvatarPosition.allCases, id: \.rawValue) { position in
@ -146,7 +165,10 @@ struct DisplaySettingsView: View {
Toggle("settings.display.translate-button", isOn: $userPreferences.showTranslateButton)
}
.listRowBackground(theme.primaryBackgroundColor)
}
@ViewBuilder
private var platformsSection: some View {
if UIDevice.current.userInterfaceIdiom == .phone {
Section("iPhone") {
Toggle("settings.display.show-tab-label", isOn: $userPreferences.showiPhoneTabLabel)
@ -160,7 +182,9 @@ struct DisplaySettingsView: View {
}
.listRowBackground(theme.primaryBackgroundColor)
}
}
private var resetSection: some View {
Section {
Button {
theme.followSystemColorScheme = true
@ -180,10 +204,6 @@ struct DisplaySettingsView: View {
}
.listRowBackground(theme.primaryBackgroundColor)
}
.navigationTitle("settings.display.navigation-title")
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
private var themeSelectorButton: some View {
NavigationLink(destination: ThemePreviewView()) {