mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
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
This commit is contained in:
parent
e6c5f2a9ca
commit
0b3319c2e1
15 changed files with 81 additions and 45 deletions
|
@ -7,35 +7,56 @@ struct SwipeActionsSettingsView: View {
|
|||
@EnvironmentObject private var userPreferences: UserPreferences
|
||||
|
||||
var body: some View {
|
||||
|
||||
Form {
|
||||
Section("settings.swipeactions.status") {
|
||||
HStack {
|
||||
Text("settings.swipeactions.status.leading")
|
||||
Image(systemName: "arrow.right")
|
||||
}
|
||||
Label("settings.swipeactions.status.leading", systemImage: "arrow.right.circle")
|
||||
Picker(selection: $userPreferences.swipeActionsStatusLeadingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.leading.left")) {
|
||||
ForEach(StatusAction.allCases) { action in
|
||||
Text(action.displayName).tag(action)
|
||||
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")) {
|
||||
ForEach(StatusAction.allCases) { action in
|
||||
Text(action.displayName).tag(action)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
Text("settings.swipeactions.status.trailing")
|
||||
Image(systemName: "arrow.left")
|
||||
}
|
||||
Label("settings.swipeactions.status.trailing", systemImage: "arrow.left.circle")
|
||||
Picker(selection: $userPreferences.swipeActionsStatusTrailingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.trailing.left")) {
|
||||
ForEach(StatusAction.allCases) { action in
|
||||
Text(action.displayName).tag(action)
|
||||
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")) {
|
||||
ForEach(StatusAction.allCases) { action in
|
||||
Text(action.displayName).tag(action)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +68,7 @@ struct SwipeActionsSettingsView: View {
|
|||
}
|
||||
|
||||
private func makeSwipeLabel(left: Bool, text: LocalizedStringKey) -> some View {
|
||||
return HStack {
|
||||
Image(systemName: left ? "rectangle.lefthalf.filled" : "rectangle.righthalf.filled")
|
||||
Text(text)
|
||||
}.padding(.leading, 16)
|
||||
return Label(text, systemImage: left ? "rectangle.lefthalf.filled" : "rectangle.righthalf.filled")
|
||||
.padding(.leading, 16)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
"settings.swipeactions.status.leading" = "Nach rechts wischen";
|
||||
"settings.swipeactions.status.leading.left" = "links";
|
||||
"settings.swipeactions.status.leading.right" = "links";
|
||||
"settings.swipeactions.status.trailing" = " Nach links wischen";
|
||||
"settings.swipeactions.status.trailing" = "Nach links wischen";
|
||||
"settings.swipeactions.status.trailing.left" = "links";
|
||||
"settings.swipeactions.status.trailing.right" = "rechts";
|
||||
"settings.swipeactions.status" = "Beitrag";
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -173,7 +173,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"settings.swipeactions.status.leading" = "Swipe right";
|
||||
"settings.swipeactions.status.leading.left" = "left";
|
||||
"settings.swipeactions.status.leading.right" = "right";
|
||||
"settings.swipeactions.status.trailing" = " Swipe left";
|
||||
"settings.swipeactions.status.trailing" = "Swipe left";
|
||||
"settings.swipeactions.status.trailing.left" = "left";
|
||||
"settings.swipeactions.status.trailing.right" = "right";
|
||||
"settings.swipeactions.status" = "Post";
|
||||
|
|
|
@ -4,9 +4,10 @@ public enum StatusAction : String, CaseIterable, Identifiable {
|
|||
public var id: String {
|
||||
"\(rawValue)"
|
||||
}
|
||||
case none, boost, reply, quote, favorite, bookmark
|
||||
|
||||
public var displayName: LocalizedStringKey {
|
||||
case none, reply, boost, favorite, bookmark, quote
|
||||
|
||||
public func displayName(isReblogged: Bool = false, isFavorited: Bool = false, isBookmarked: Bool = false) -> LocalizedStringKey {
|
||||
switch self {
|
||||
case .none:
|
||||
return "settings.swipeactions.status.action.none"
|
||||
|
@ -15,11 +16,11 @@ public enum StatusAction : String, CaseIterable, Identifiable {
|
|||
case .quote:
|
||||
return "settings.swipeactions.status.action.quote"
|
||||
case .boost:
|
||||
return "settings.swipeactions.status.action.boost"
|
||||
return isReblogged ? "status.action.unboost" : "settings.swipeactions.status.action.boost"
|
||||
case .favorite:
|
||||
return "settings.swipeactions.status.action.favorite"
|
||||
return isFavorited ? "status.action.unfavorite" : "settings.swipeactions.status.action.favorite"
|
||||
case .bookmark:
|
||||
return "settings.swipeactions.status.action.bookmark"
|
||||
return isBookmarked ? "status.action.unbookmark" : "settings.swipeactions.status.action.bookmark"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,4 +40,21 @@ public enum StatusAction : String, CaseIterable, Identifiable {
|
|||
return isBookmarked ? "bookmark.fill" : "bookmark"
|
||||
}
|
||||
}
|
||||
|
||||
public func color(themeTintColor: Color) -> Color {
|
||||
switch self {
|
||||
case .none:
|
||||
return .gray
|
||||
case .reply:
|
||||
return .gray
|
||||
case .quote:
|
||||
return .gray
|
||||
case .boost:
|
||||
return themeTintColor
|
||||
case .favorite:
|
||||
return .yellow
|
||||
case .bookmark:
|
||||
return .pink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -455,11 +455,9 @@ public struct StatusRowView: View {
|
|||
private var trailingSwipeActions: some View {
|
||||
if preferences.swipeActionsStatusTrailingRight != StatusAction.none {
|
||||
makeSwipeButton(action: preferences.swipeActionsStatusTrailingRight)
|
||||
.tint(theme.tintColor)
|
||||
}
|
||||
if preferences.swipeActionsStatusTrailingLeft != StatusAction.none {
|
||||
makeSwipeButton(action: preferences.swipeActionsStatusTrailingLeft)
|
||||
.tint(.gray)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,11 +465,9 @@ public struct StatusRowView: View {
|
|||
private var leadingSwipeActions: some View {
|
||||
if preferences.swipeActionsStatusLeadingLeft != StatusAction.none {
|
||||
makeSwipeButton(action: preferences.swipeActionsStatusLeadingLeft)
|
||||
.tint(theme.tintColor)
|
||||
}
|
||||
if preferences.swipeActionsStatusLeadingRight != StatusAction.none {
|
||||
makeSwipeButton(action: preferences.swipeActionsStatusLeadingRight)
|
||||
.tint(.gray)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,10 +514,11 @@ public struct StatusRowView: View {
|
|||
HapticManager.shared.fireHaptic(of: .notification(.success))
|
||||
routerPath.presentedSheet = destination
|
||||
} label: {
|
||||
Text(action.displayName)
|
||||
Text(action.displayName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
|
||||
Image(systemName: action.iconName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
|
||||
.foregroundColor(.red)
|
||||
.environment(\.symbolVariants, .none)
|
||||
}
|
||||
.tint(action.color(themeTintColor: theme.tintColor))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -532,8 +529,10 @@ public struct StatusRowView: View {
|
|||
await task()
|
||||
}
|
||||
} label: {
|
||||
Text(action.displayName)
|
||||
Text(action.displayName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
|
||||
Image(systemName: action.iconName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
|
||||
.environment(\.symbolVariants, .none)
|
||||
}
|
||||
.tint(action.color(themeTintColor: theme.tintColor))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue