IceCubes/IceCubesApp/App/Tabs/Settings/SwipeActionsSettingsView.swift
Chanhwi Joo 0b3319c2e1
Improve swipe actions and settings (#808)
* Remove an unnecessary space from string

settings.swipeactions.status.trailing

* Make SwipeActionsSettingsView to be consistent with others

* Divide none as another section

* Add icons

* Make hollow icons work

* Show different button label by its status

* Use different colors by actions

* Fix swapped icons in settings

* Refactor
2023-02-12 10:37:09 +01:00

75 lines
3.1 KiB
Swift

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") {
Label("settings.swipeactions.status.leading", systemImage: "arrow.right.circle")
Picker(selection: $userPreferences.swipeActionsStatusLeadingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.leading.left")) {
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)
}
}
}
}
Picker(selection: $userPreferences.swipeActionsStatusLeadingRight, label: makeSwipeLabel(left: false, text: "settings.swipeactions.status.leading.right")) {
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)
}
}
}
}
Label("settings.swipeactions.status.trailing", systemImage: "arrow.left.circle")
Picker(selection: $userPreferences.swipeActionsStatusTrailingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.trailing.left")) {
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)
}
}
}
}
Picker(selection: $userPreferences.swipeActionsStatusTrailingRight, label: makeSwipeLabel(left: false, text: "settings.swipeactions.status.trailing.right")) {
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)
}
}
}
}
}
.listRowBackground(theme.primaryBackgroundColor)
}
.navigationTitle("settings.swipeactions.navigation-title")
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
private func makeSwipeLabel(left: Bool, text: LocalizedStringKey) -> some View {
return Label(text, systemImage: left ? "rectangle.lefthalf.filled" : "rectangle.righthalf.filled")
.padding(.leading, 16)
}
}