swipe actions improvements (#785)

* swipe actions improvements

* use old values as default settings

* Polish swipe actions settings

* Fix background color

---------

Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
Peter-Josef Meisch 2023-02-11 21:48:08 +01:00 committed by GitHub
parent c6a4aa5fff
commit 124aeef7fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 462 additions and 20 deletions

View file

@ -80,6 +80,7 @@
9FE151A6293C90F900E9683D /* IconSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FE151A5293C90F900E9683D /* IconSelectorView.swift */; };
9FE3DB57296FEFCA00628CB0 /* AppAccount in Frameworks */ = {isa = PBXBuildFile; productRef = 9FE3DB56296FEFCA00628CB0 /* AppAccount */; };
C9B22677297F6C2E001F9EFE /* ContentSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B22676297F6C2E001F9EFE /* ContentSettingsView.swift */; };
D08A9C3529956CFA00204A4A /* SwipeActionsSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D08A9C3429956CFA00204A4A /* SwipeActionsSettingsView.swift */; };
E92817FA298443D600875FD1 /* Models in Frameworks */ = {isa = PBXBuildFile; productRef = E92817F9298443D600875FD1 /* Models */; };
E92817FC298443D600875FD1 /* Network in Frameworks */ = {isa = PBXBuildFile; productRef = E92817FB298443D600875FD1 /* Network */; };
E92817FE29844DB700875FD1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E92817FD29844DB700875FD1 /* Assets.xcassets */; };
@ -224,6 +225,7 @@
C4CBB90B298A0DA3007E1707 /* en-GB */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "en-GB"; path = "en-GB.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
C4FBCF6F298FD88A0015DF22 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
C9B22676297F6C2E001F9EFE /* ContentSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentSettingsView.swift; sourceTree = "<group>"; };
D08A9C3429956CFA00204A4A /* SwipeActionsSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeActionsSettingsView.swift; sourceTree = "<group>"; };
DD31E2E5297FB68B00A4BE29 /* IceCubesApp.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = IceCubesApp.xcconfig; sourceTree = "<group>"; };
E92817FD29844DB700875FD1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E970C10929845A9400E88A8C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@ -466,6 +468,7 @@
9F2A5410296A1429009B2D7C /* PushNotificationsView.swift */,
9FAE4ACA293783B000772766 /* SettingsTab.swift */,
9F2A540629699698009B2D7C /* SupportAppView.swift */,
D08A9C3429956CFA00204A4A /* SwipeActionsSettingsView.swift */,
);
path = Settings;
sourceTree = "<group>";
@ -758,6 +761,7 @@
9F2B92FA295DA7D700DE16D0 /* AddAccountsView.swift in Sources */,
639CDF9C296AC82F00C35E58 /* SafariRouter.swift in Sources */,
9F35DB4729506F6600B3281A /* NotificationTab.swift in Sources */,
D08A9C3529956CFA00204A4A /* SwipeActionsSettingsView.swift in Sources */,
9F7335F22967608F00AFF0BA /* AddRemoteTimelineView.swift in Sources */,
9F55C68D2955968700F94077 /* ExploreTab.swift in Sources */,
9F1E8B47298EBCBB00609F80 /* HapticSettingsView.swift in Sources */,

View file

@ -113,6 +113,9 @@ struct SettingsTabs: View {
NavigationLink(destination: ContentSettingsView()) {
Label("settings.general.content", systemImage: "rectangle.on.rectangle")
}
NavigationLink(destination: SwipeActionsSettingsView()) {
Label("settings.general.swipeactions", systemImage: "hand.draw")
}
Link(destination: URL(string: UIApplication.openSettingsURLString)!) {
Label("settings.system", systemImage: "gear")
}

View file

@ -0,0 +1,55 @@
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") {
HStack {
Text("settings.swipeactions.status.leading")
Image(systemName: "arrow.right")
}
Picker(selection: $userPreferences.swipeActionsStatusLeadingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.leading.left")) {
ForEach(StatusAction.allCases) { action in
Text(action.displayName).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)
}
}
HStack {
Text("settings.swipeactions.status.trailing")
Image(systemName: "arrow.left")
}
Picker(selection: $userPreferences.swipeActionsStatusTrailingLeft, label: makeSwipeLabel(left: true, text: "settings.swipeactions.status.trailing.left")) {
ForEach(StatusAction.allCases) { action in
Text(action.displayName).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)
}
}
}
.listRowBackground(theme.primaryBackgroundColor)
}
.navigationTitle("settings.swipeactions.navigation-title")
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
}
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)
}
}

View file

@ -160,6 +160,22 @@
"settings.display.show-ipad-column" = "Habilitar columna secondària";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Exploreu";
"tab.federated" = "Federat";

View file

@ -158,6 +158,22 @@
"settings.display.show-ipad-column" = "Zweite Spalte aktivieren";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"enum.expand-media.show" = "Alle zeigen";
"enum.expand-media.hide" = "Alle ausblenden";
"enum.expand-media.hide-sensitive" = "Sensible ausblenden";

View file

@ -164,6 +164,22 @@
"settings.display.show-ipad-column" = "Enable secondary column";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Explore";
"tab.federated" = "Federated";

View file

@ -162,6 +162,22 @@
"settings.display.show-ipad-column" = "Enable secondary column";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Explore";
"tab.federated" = "Federated";

View file

@ -158,6 +158,22 @@
"settings.display.show-ipad-column" = "Enable secondary column";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"enum.expand-media.show" = "Siempre";
"enum.expand-media.hide" = "Nunca";
"enum.expand-media.hide-sensitive" = "Ocultar contenido sensible";

View file

@ -158,6 +158,22 @@
"settings.display.show-ipad-column" = "Gaitu bigarren zutabea";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"enum.expand-media.show" = "Erakutsi guztia";
"enum.expand-media.hide" = "Ezkutatu guztia";
"enum.expand-media.hide-sensitive" = "Ezkutatu hunkigarria";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "Activer la colonne secondaire";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Explorer";
"tab.federated" = "Fédéré";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "Attiva la seconda colonna";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Esplora";
"tab.federated" = "Federazione";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "セカンドカラムを有効にする";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "エクスプローラー";
"tab.federated" = "連合";

View file

@ -160,6 +160,22 @@
"settings.display.show-tab-label" = "하단 탭 바에 제목 표시";
"settings.display.show-ipad-column" = "보조 열 사용";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "둘러보기";
"tab.federated" = "연합";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "Enable secondary column";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Utforsk";
"tab.federated" = "Federert";

View file

@ -158,6 +158,22 @@
"settings.display.show-ipad-column" = "Toon tweede kolom";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Ontdekken";
"tab.federated" = "Gefedereerd";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "Włącz dodatkową kolumnę";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Odkrywaj";
"tab.federated" = "Globalny";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "Enable secondary column";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Explorar";
"tab.federated" = "Linha global";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "Enable secondary column";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "Keşfet";
"tab.federated" = "Birleştirilmiş";

View file

@ -161,6 +161,22 @@
"settings.display.show-ipad-column" = "启用边栏";
"settings.general.swipeactions" = "Swipe Actions";
"settings.swipeactions.navigation-title" = "Swipe Actions";
"settings.swipeactions.status.action.bookmark" = "Bookmark";
"settings.swipeactions.status.action.boost" = "Boost";
"settings.swipeactions.status.action.favorite" = "Favorite";
"settings.swipeactions.status.action.none" = "None";
"settings.swipeactions.status.action.quote" = "Quote";
"settings.swipeactions.status.action.reply" = "Reply";
"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.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
// MARK: Tabs
"tab.explore" = "探索";
"tab.federated" = "跨站";

View file

@ -0,0 +1,42 @@
import SwiftUI
public enum StatusAction : String, CaseIterable, Identifiable {
public var id: String {
"\(rawValue)"
}
case none, boost, reply, quote, favorite, bookmark
public var displayName: LocalizedStringKey {
switch self {
case .none:
return "settings.swipeactions.status.action.none"
case .reply:
return "settings.swipeactions.status.action.reply"
case .quote:
return "settings.swipeactions.status.action.quote"
case .boost:
return "settings.swipeactions.status.action.boost"
case .favorite:
return "settings.swipeactions.status.action.favorite"
case .bookmark:
return "settings.swipeactions.status.action.bookmark"
}
}
public func iconName(isReblogged: Bool = false, isFavorited: Bool = false, isBookmarked: Bool = false) -> String {
switch self {
case .none:
return "slash.circle"
case .reply:
return "arrowshape.turn.up.left"
case .quote:
return "quote.bubble"
case .boost:
return isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
case .favorite:
return isFavorited ? "star.fill" : "star"
case .bookmark:
return isBookmarked ? "bookmark.fill" : "bookmark"
}
}
}

View file

@ -40,6 +40,43 @@ public class UserPreferences: ObservableObject {
@AppStorage("show_second_column_ipad") public var showiPadSecondaryColumn = true
@AppStorage("swipeactions.status.trailing.right") var _swipeActionsStatusTrailingRight = StatusAction.favorite.rawValue
public var swipeActionsStatusTrailingRight: StatusAction {
get {
StatusAction(rawValue: _swipeActionsStatusTrailingRight) ?? StatusAction.none
}
set {
_swipeActionsStatusTrailingRight = newValue.rawValue
}
}
@AppStorage("swipeactions.status.trailing.left") var _swipeActionsStatusTrailingLeft = StatusAction.boost.rawValue
public var swipeActionsStatusTrailingLeft: StatusAction {
get {
StatusAction(rawValue: _swipeActionsStatusTrailingLeft) ?? StatusAction.none
}
set {
_swipeActionsStatusTrailingLeft = newValue.rawValue
}
}
@AppStorage("swipeactions.status.leading.left") var _swipeActionsStatusLeadingLeft = StatusAction.reply.rawValue
public var swipeActionsStatusLeadingLeft: StatusAction {
get {
StatusAction(rawValue: _swipeActionsStatusLeadingLeft) ?? StatusAction.none
}
set {
_swipeActionsStatusLeadingLeft = newValue.rawValue
}
}
@AppStorage("swipeactions.status.leading.right") var _swipeActionsStatusLeadingRight = StatusAction.none.rawValue
public var swipeActionsStatusLeadingRight: StatusAction {
get {
StatusAction(rawValue: _swipeActionsStatusLeadingRight) ?? StatusAction.none
}
set {
_swipeActionsStatusLeadingRight = newValue.rawValue
}
}
public var postVisibility: Models.Visibility {
if useInstanceContentSettings {
return serverPreferences?.postVisibility ?? .pub

View file

@ -85,7 +85,7 @@ public struct StatusRowView: View {
.listRowBackground(viewModel.highlightRowColor)
.swipeActions(edge: .trailing) {
if !viewModel.isCompact {
trailinSwipeActions
trailingSwipeActions
}
}
.swipeActions(edge: .leading) {
@ -453,43 +453,88 @@ public struct StatusRowView: View {
}
@ViewBuilder
private var trailinSwipeActions: some View {
Button {
Task {
HapticManager.shared.fireHaptic(of: .notification(.success))
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)
}
}
@ViewBuilder
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)
}
}
@ViewBuilder
private func makeSwipeButton(action: StatusAction) -> some View {
switch action {
case .reply:
makeSwipeButtonForRouterPath(action: action, destination: .replyToStatusEditor(status: viewModel.status))
case .quote:
makeSwipeButtonForRouterPath(action: action, destination: .quoteStatusEditor(status: viewModel.status))
case .favorite:
makeSwipeButtonForTask(action: action) {
if viewModel.isFavorited {
await viewModel.unFavorite()
} else {
await viewModel.favorite()
}
}
} label: {
Image(systemName: "star")
}
.tint(.yellow)
Button {
Task {
HapticManager.shared.fireHaptic(of: .notification(.success))
case .boost:
makeSwipeButtonForTask(action: action) {
if viewModel.isReblogged {
await viewModel.unReblog()
} else {
await viewModel.reblog()
}
}
} label: {
Image(systemName: "arrow.left.arrow.right.circle")
case .bookmark:
makeSwipeButtonForTask(action: action) {
if viewModel.isBookmarked {
await viewModel.unbookmark()
} else {
await
viewModel.bookmark()
}
}
case .none:
EmptyView()
}
.tint(theme.tintColor)
}
@ViewBuilder
private var leadingSwipeActions: some View {
private func makeSwipeButtonForRouterPath(action: StatusAction, destination: SheetDestinations) -> some View {
Button {
HapticManager.shared.fireHaptic(of: .notification(.success))
routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
routerPath.presentedSheet = destination
} label: {
Image(systemName: "arrowshape.turn.up.left")
}
.tint(theme.tintColor)
Text(action.displayName)
Image(systemName: action.iconName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
.foregroundColor(.red)
}
}
@ViewBuilder
private func makeSwipeButtonForTask(action: StatusAction, task: @escaping () async -> Void ) -> some View {
Button {
Task {
HapticManager.shared.fireHaptic(of: .notification(.success))
await task()
}
} label: {
Text(action.displayName)
Image(systemName: action.iconName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
}
}
}