IceCubesApp/IceCubesApp/App/Tabs/Settings/DisplaySettingsView.swift

84 lines
3 KiB
Swift
Raw Normal View History

2023-01-06 16:14:34 +00:00
import DesignSystem
2023-01-22 05:38:30 +00:00
import Env
2023-01-17 10:36:01 +00:00
import Models
2023-01-06 16:14:34 +00:00
import Status
2023-01-17 10:36:01 +00:00
import SwiftUI
2023-01-06 16:14:34 +00:00
struct DisplaySettingsView: View {
@EnvironmentObject private var theme: Theme
2023-01-17 20:08:05 +00:00
@EnvironmentObject private var userPreferences: UserPreferences
2023-01-17 10:36:01 +00:00
2023-01-06 16:14:34 +00:00
@State private var isThemeSelectorPresented = false
2023-01-17 10:36:01 +00:00
2023-01-06 16:14:34 +00:00
var body: some View {
Form {
Section("settings.display.section.theme") {
Toggle("settings.display.theme.systemColor", isOn: $theme.followSystemColorScheme)
2023-01-06 16:14:34 +00:00
themeSelectorButton
ColorPicker("settings.display.theme.tint", selection: $theme.tintColor)
ColorPicker("settings.display.theme.background", selection: $theme.primaryBackgroundColor)
ColorPicker("settings.display.theme.secondary-background", selection: $theme.secondaryBackgroundColor)
2023-01-06 16:14:34 +00:00
}
.listRowBackground(theme.primaryBackgroundColor)
2023-01-17 10:36:01 +00:00
Section("settings.display.section.display") {
Picker("settings.display.avatar.position", selection: $theme.avatarPosition) {
2023-01-06 16:14:34 +00:00
ForEach(Theme.AvatarPosition.allCases, id: \.rawValue) { position in
Text(position.description).tag(position)
}
}
Picker("settings.display.avatar.shape", selection: $theme.avatarShape) {
2023-01-06 16:14:34 +00:00
ForEach(Theme.AvatarShape.allCases, id: \.rawValue) { shape in
Text(shape.description).tag(shape)
}
}
Picker("settings.display.status.action-buttons", selection: $theme.statusActionsDisplay) {
2023-01-06 16:14:34 +00:00
ForEach(Theme.StatusActionsDisplay.allCases, id: \.rawValue) { buttonStyle in
Text(buttonStyle.description).tag(buttonStyle)
}
}
2023-01-17 10:36:01 +00:00
Picker("settings.display.status.media-style", selection: $theme.statusDisplayStyle) {
2023-01-07 16:44:25 +00:00
ForEach(Theme.StatusDisplayStyle.allCases, id: \.rawValue) { buttonStyle in
Text(buttonStyle.description).tag(buttonStyle)
}
}
2023-01-17 20:08:05 +00:00
if ProcessInfo.processInfo.isiOSAppOnMac {
VStack {
2023-01-22 05:38:30 +00:00
Slider(value: $userPreferences.fontSizeScale, in: 0.5 ... 1.5, step: 0.1)
2023-01-17 20:08:05 +00:00
Text("Font scaling: \(String(format: "%.1f", userPreferences.fontSizeScale))")
.font(.scaledBody)
}
}
Toggle("settings.display.translate-button", isOn: $userPreferences.showTranslateButton)
2023-01-06 16:14:34 +00:00
}
.listRowBackground(theme.primaryBackgroundColor)
2023-01-17 10:36:01 +00:00
2023-01-06 16:14:34 +00:00
Section {
Button {
theme.selectedSet = .iceCubeDark
theme.avatarShape = .rounded
theme.avatarPosition = .top
theme.statusActionsDisplay = .full
} label: {
Text("settings.display.restore")
2023-01-06 16:14:34 +00:00
}
}
.listRowBackground(theme.primaryBackgroundColor)
}
.navigationTitle("settings.display.navigation-title")
2023-01-06 16:14:34 +00:00
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
2023-01-17 10:36:01 +00:00
2023-01-06 16:14:34 +00:00
private var themeSelectorButton: some View {
NavigationLink(destination: ThemePreviewView()) {
HStack {
Text("settings.display.section.theme")
2023-01-06 16:14:34 +00:00
Spacer()
Text(theme.selectedSet.rawValue)
}
}
}
}