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
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Form {
|
|
|
|
Section("settings.swipeactions.status") {
|
2023-02-12 10:37:09 +01:00
|
|
|
Label("settings.swipeactions.status.leading", systemImage: "arrow.right.circle")
|
2023-02-11 21:48:08 +01:00
|
|
|
Picker(selection: $userPreferences.swipeActionsStatusLeadingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.leading.left")) {
|
2023-02-12 10:37:09 +01:00
|
|
|
Section {
|
|
|
|
Label(StatusAction.none.displayName(), systemImage: StatusAction.none.iconName()).tag(StatusAction.none)
|
|
|
|
}
|
|
|
|
Section {
|
|
|
|
ForEach(StatusAction.allCases) { action in
|
|
|
|
if (action != .none) {
|
|
|
|
Label(action.displayName(), systemImage: action.iconName()).tag(action)
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Picker(selection: $userPreferences.swipeActionsStatusLeadingRight, label: makeSwipeLabel(left: false, text: "settings.swipeactions.status.leading.right")) {
|
2023-02-12 10:37:09 +01:00
|
|
|
Section {
|
|
|
|
Label(StatusAction.none.displayName(), systemImage: StatusAction.none.iconName()).tag(StatusAction.none)
|
|
|
|
}
|
|
|
|
Section {
|
|
|
|
ForEach(StatusAction.allCases) { action in
|
|
|
|
if (action != .none) {
|
|
|
|
Label(action.displayName(), systemImage: action.iconName()).tag(action)
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-12 10:37:09 +01:00
|
|
|
Label("settings.swipeactions.status.trailing", systemImage: "arrow.left.circle")
|
2023-02-11 21:48:08 +01:00
|
|
|
Picker(selection: $userPreferences.swipeActionsStatusTrailingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.trailing.left")) {
|
2023-02-12 10:37:09 +01:00
|
|
|
Section {
|
|
|
|
Label(StatusAction.none.displayName(), systemImage: StatusAction.none.iconName()).tag(StatusAction.none)
|
|
|
|
}
|
|
|
|
Section {
|
|
|
|
ForEach(StatusAction.allCases) { action in
|
|
|
|
if (action != .none) {
|
|
|
|
Label(action.displayName(), systemImage: action.iconName()).tag(action)
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Picker(selection: $userPreferences.swipeActionsStatusTrailingRight, label: makeSwipeLabel(left: false, text: "settings.swipeactions.status.trailing.right")) {
|
2023-02-12 10:37:09 +01:00
|
|
|
Section {
|
|
|
|
Label(StatusAction.none.displayName(), systemImage: StatusAction.none.iconName()).tag(StatusAction.none)
|
|
|
|
}
|
|
|
|
Section {
|
|
|
|
ForEach(StatusAction.allCases) { action in
|
|
|
|
if (action != .none) {
|
|
|
|
Label(action.displayName(), systemImage: action.iconName()).tag(action)
|
|
|
|
}
|
|
|
|
}
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
|
|
|
}
|
|
|
|
.navigationTitle("settings.swipeactions.navigation-title")
|
|
|
|
.scrollContentBackground(.hidden)
|
|
|
|
.background(theme.secondaryBackgroundColor)
|
|
|
|
}
|
|
|
|
|
|
|
|
private func makeSwipeLabel(left: Bool, text: LocalizedStringKey) -> some View {
|
2023-02-12 10:37:09 +01:00
|
|
|
return Label(text, systemImage: left ? "rectangle.lefthalf.filled" : "rectangle.righthalf.filled")
|
|
|
|
.padding(.leading, 16)
|
2023-02-11 21:48:08 +01:00
|
|
|
}
|
|
|
|
}
|