2023-02-11 20:48:08 +00:00
|
|
|
import DesignSystem
|
|
|
|
import Env
|
|
|
|
import SwiftUI
|
|
|
|
|
2023-09-19 07:18:20 +00:00
|
|
|
@MainActor
|
2023-02-11 20:48:08 +00:00
|
|
|
struct SwipeActionsSettingsView: View {
|
2023-09-18 19:03:52 +00:00
|
|
|
@Environment(Theme.self) private var theme
|
2023-09-19 07:18:20 +00:00
|
|
|
@Environment(UserPreferences.self) private var userPreferences
|
2023-02-12 15:29:41 +00:00
|
|
|
|
2023-02-11 20:48:08 +00:00
|
|
|
var body: some View {
|
2023-09-19 07:18:20 +00:00
|
|
|
@Bindable var userPreferences = userPreferences
|
2023-02-11 20:48:08 +00:00
|
|
|
Form {
|
2023-02-22 06:07:26 +00:00
|
|
|
Section {
|
|
|
|
Label("settings.swipeactions.status.leading", systemImage: "arrow.right")
|
|
|
|
.foregroundColor(.secondary)
|
2023-02-22 18:09:39 +00:00
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusLeadingLeft,
|
2023-02-22 18:09:39 +00:00
|
|
|
label: "settings.swipeactions.primary")
|
2023-09-18 05:01:23 +00:00
|
|
|
.onChange(of: userPreferences.swipeActionsStatusLeadingLeft) { _, action in
|
2023-02-22 06:07:26 +00:00
|
|
|
if action == .none {
|
2023-02-22 18:09:39 +00:00
|
|
|
userPreferences.swipeActionsStatusLeadingRight = .none
|
2023-02-12 09:37:09 +00:00
|
|
|
}
|
2023-02-11 20:48:08 +00:00
|
|
|
}
|
2023-02-22 18:09:39 +00:00
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusLeadingRight,
|
2023-02-22 18:09:39 +00:00
|
|
|
label: "settings.swipeactions.secondary")
|
|
|
|
.disabled(userPreferences.swipeActionsStatusLeadingLeft == .none)
|
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
Label("settings.swipeactions.status.trailing", systemImage: "arrow.left")
|
|
|
|
.foregroundColor(.secondary)
|
2023-02-22 18:09:39 +00:00
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusTrailingRight,
|
2023-02-22 18:09:39 +00:00
|
|
|
label: "settings.swipeactions.primary")
|
2023-09-18 05:01:23 +00:00
|
|
|
.onChange(of: userPreferences.swipeActionsStatusTrailingRight) { _, action in
|
2023-02-22 06:07:26 +00:00
|
|
|
if action == .none {
|
2023-02-22 18:09:39 +00:00
|
|
|
userPreferences.swipeActionsStatusTrailingLeft = .none
|
2023-02-12 09:37:09 +00:00
|
|
|
}
|
2023-02-11 20:48:08 +00:00
|
|
|
}
|
2023-02-22 06:07:26 +00:00
|
|
|
|
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusTrailingLeft,
|
2023-02-22 18:09:39 +00:00
|
|
|
label: "settings.swipeactions.secondary")
|
2023-02-22 06:07:26 +00:00
|
|
|
.disabled(userPreferences.swipeActionsStatusTrailingRight == .none)
|
2023-02-22 18:09:39 +00:00
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
} header: {
|
|
|
|
Text("settings.swipeactions.status")
|
|
|
|
} footer: {
|
|
|
|
Text("settings.swipeactions.status.explanation")
|
|
|
|
}
|
2023-12-19 08:48:12 +00:00
|
|
|
#if !os(visionOS)
|
2023-02-22 06:07:26 +00:00
|
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
2023-12-19 08:48:12 +00:00
|
|
|
#endif
|
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
Section {
|
|
|
|
Picker(selection: $userPreferences.swipeActionsIconStyle, label: Text("settings.swipeactions.icon-style")) {
|
2023-02-14 06:01:55 +00:00
|
|
|
ForEach(UserPreferences.SwipeActionsIconStyle.allCases, id: \.rawValue) { style in
|
|
|
|
Text(style.description).tag(style)
|
|
|
|
}
|
|
|
|
}
|
2023-02-22 06:07:26 +00:00
|
|
|
Toggle(isOn: $userPreferences.swipeActionsUseThemeColor) {
|
|
|
|
Text("settings.swipeactions.use-theme-colors")
|
|
|
|
}
|
|
|
|
} header: {
|
|
|
|
Text("settings.swipeactions.appearance")
|
|
|
|
} footer: {
|
|
|
|
Text("settings.swipeactions.use-theme-colors-explanation")
|
2023-02-11 20:48:08 +00:00
|
|
|
}
|
2023-12-19 08:48:12 +00:00
|
|
|
#if !os(visionOS)
|
2023-02-11 20:48:08 +00:00
|
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
2023-12-19 08:48:12 +00:00
|
|
|
#endif
|
2023-02-11 20:48:08 +00:00
|
|
|
}
|
|
|
|
.navigationTitle("settings.swipeactions.navigation-title")
|
2023-12-19 08:48:12 +00:00
|
|
|
#if !os(visionOS)
|
2023-02-11 20:48:08 +00:00
|
|
|
.scrollContentBackground(.hidden)
|
|
|
|
.background(theme.secondaryBackgroundColor)
|
2023-12-19 08:48:12 +00:00
|
|
|
#endif
|
2023-02-11 20:48:08 +00:00
|
|
|
}
|
2023-02-12 15:29:41 +00:00
|
|
|
|
2023-02-22 06:07:26 +00:00
|
|
|
private func createStatusActionPicker(selection: Binding<StatusAction>, label: LocalizedStringKey) -> some View {
|
2023-09-16 12:15:03 +00:00
|
|
|
Picker(selection: selection, label: Text(label)) {
|
2023-02-22 06:07:26 +00:00
|
|
|
Section {
|
|
|
|
Text(StatusAction.none.displayName()).tag(StatusAction.none)
|
|
|
|
}
|
|
|
|
Section {
|
|
|
|
ForEach(StatusAction.allCases) { action in
|
|
|
|
if action != .none {
|
|
|
|
Text(action.displayName()).tag(action)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 20:48:08 +00:00
|
|
|
}
|
|
|
|
}
|