2023-02-11 21:48:08 +01:00
|
|
|
import DesignSystem
|
|
|
|
import Env
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SwipeActionsSettingsView: View {
|
|
|
|
@EnvironmentObject private var theme: Theme
|
|
|
|
@EnvironmentObject private var userPreferences: UserPreferences
|
2023-02-12 16:29:41 +01:00
|
|
|
|
2023-02-11 21:48:08 +01:00
|
|
|
var body: some View {
|
|
|
|
Form {
|
2023-02-22 07:07:26 +01:00
|
|
|
Section {
|
|
|
|
|
|
|
|
Label("settings.swipeactions.status.leading", systemImage: "arrow.right")
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
|
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusLeadingLeft,
|
|
|
|
label: "settings.swipeactions.primary")
|
|
|
|
.onChange(of: userPreferences.swipeActionsStatusLeadingLeft) { action in
|
|
|
|
if action == .none {
|
|
|
|
userPreferences.swipeActionsStatusLeadingRight = .none;
|
2023-02-12 10:37:09 +01:00
|
|
|
}
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
2023-02-22 07:07:26 +01:00
|
|
|
|
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusLeadingRight,
|
|
|
|
label: "settings.swipeactions.secondary")
|
|
|
|
.disabled(userPreferences.swipeActionsStatusLeadingLeft == .none)
|
|
|
|
|
|
|
|
Label("settings.swipeactions.status.trailing", systemImage: "arrow.left")
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
|
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusTrailingRight,
|
|
|
|
label: "settings.swipeactions.primary")
|
|
|
|
.onChange(of: userPreferences.swipeActionsStatusTrailingRight) { action in
|
|
|
|
if action == .none {
|
|
|
|
userPreferences.swipeActionsStatusTrailingLeft = .none;
|
2023-02-12 10:37:09 +01:00
|
|
|
}
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
2023-02-22 07:07:26 +01:00
|
|
|
|
|
|
|
createStatusActionPicker(selection: $userPreferences.swipeActionsStatusTrailingLeft,
|
|
|
|
label: "settings.swipeactions.secondary")
|
|
|
|
.disabled(userPreferences.swipeActionsStatusTrailingRight == .none)
|
|
|
|
|
|
|
|
} header: {
|
|
|
|
Text("settings.swipeactions.status")
|
|
|
|
} footer: {
|
|
|
|
Text("settings.swipeactions.status.explanation")
|
|
|
|
}
|
|
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
|
|
|
|
|
|
|
Section {
|
|
|
|
Picker(selection: $userPreferences.swipeActionsIconStyle, label: Text("settings.swipeactions.icon-style")) {
|
2023-02-14 07:01:55 +01:00
|
|
|
ForEach(UserPreferences.SwipeActionsIconStyle.allCases, id: \.rawValue) { style in
|
|
|
|
Text(style.description).tag(style)
|
|
|
|
}
|
|
|
|
}
|
2023-02-22 07:07:26 +01: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 21:48:08 +01:00
|
|
|
}
|
|
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
|
|
|
}
|
|
|
|
.navigationTitle("settings.swipeactions.navigation-title")
|
|
|
|
.scrollContentBackground(.hidden)
|
|
|
|
.background(theme.secondaryBackgroundColor)
|
|
|
|
}
|
2023-02-12 16:29:41 +01:00
|
|
|
|
2023-02-22 07:07:26 +01:00
|
|
|
private func createStatusActionPicker(selection: Binding<StatusAction>, label: LocalizedStringKey) -> some View {
|
|
|
|
return Picker(selection: selection, label: Text(label)) {
|
|
|
|
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 21:48:08 +01:00
|
|
|
}
|
2023-02-22 07:07:26 +01:00
|
|
|
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|