IceCubesApp/IceCubesApp/App/Tabs/Settings/ContentSettingsView.swift

71 lines
2.5 KiB
Swift
Raw Normal View History

import AppAccount
import DesignSystem
import Env
import Models
import Network
import NukeUI
import SwiftUI
import UserNotifications
struct ContentSettingsView: View {
@EnvironmentObject private var userPreferences: UserPreferences
@EnvironmentObject private var theme: Theme
2023-01-27 19:36:40 +00:00
var body: some View {
Form {
Section("settings.content.boosts") {
Toggle(isOn: $userPreferences.suppressDupeReblogs) {
Text("settings.content.hide-repeated-boosts")
}
}.listRowBackground(theme.primaryBackgroundColor)
Section("settings.content.instance-settings") {
Toggle(isOn: $userPreferences.useInstanceContentSettings) {
Text("settings.content.use-instance-settings")
}
}
.listRowBackground(theme.primaryBackgroundColor)
.onChange(of: userPreferences.useInstanceContentSettings) { newVal in
if newVal {
userPreferences.appAutoExpandSpoilers = userPreferences.autoExpandSpoilers
userPreferences.appAutoExpandMedia = userPreferences.autoExpandMedia
userPreferences.appDefaultPostsSensitive = userPreferences.postIsSensitive
userPreferences.appDefaultPostVisibility = userPreferences.postVisibility
}
}
2023-01-27 19:36:40 +00:00
Section("settings.content.reading") {
Toggle(isOn: $userPreferences.appAutoExpandSpoilers) {
Text("settings.content.expand-spoilers")
}
.disabled(userPreferences.useInstanceContentSettings)
2023-01-27 19:36:40 +00:00
Picker("settings.content.expand-media", selection: $userPreferences.appAutoExpandMedia) {
ForEach(ServerPreferences.AutoExpandMedia.allCases, id: \.rawValue) { media in
Text(media.description).tag(media)
}
}
.disabled(userPreferences.useInstanceContentSettings)
}.listRowBackground(theme.primaryBackgroundColor)
2023-01-27 19:36:40 +00:00
Section("settings.content.posting") {
Picker("settings.content.default-visibility", selection: $userPreferences.appDefaultPostVisibility) {
ForEach(Visibility.allCases, id: \.rawValue) { vis in
Text(vis.title).tag(vis)
}
}
.disabled(userPreferences.useInstanceContentSettings)
Toggle(isOn: $userPreferences.appDefaultPostsSensitive) {
Text("settings.content.default-sensitive")
}
.disabled(userPreferences.useInstanceContentSettings)
}
.listRowBackground(theme.primaryBackgroundColor)
}
.navigationTitle("settings.content.navigation-title")
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
}