Improve swipe actions (#825)

* Remove icons from settings

* Add new toggle for using the theme tint

* Localizations

* Add icon style picker

* Localizations

---------

Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
Chanhwi Joo 2023-02-14 15:01:55 +09:00 committed by GitHub
parent 01a45b4a52
commit af61ff7914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 124 additions and 21 deletions

View file

@ -12,24 +12,24 @@ struct SwipeActionsSettingsView: View {
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)
Text(StatusAction.none.displayName()).tag(StatusAction.none)
}
Section {
ForEach(StatusAction.allCases) { action in
if action != .none {
Label(action.displayName(), systemImage: action.iconName()).tag(action)
Text(action.displayName()).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)
Text(StatusAction.none.displayName()).tag(StatusAction.none)
}
Section {
ForEach(StatusAction.allCases) { action in
if action != .none {
Label(action.displayName(), systemImage: action.iconName()).tag(action)
Text(action.displayName()).tag(action)
}
}
}
@ -37,28 +37,36 @@ struct SwipeActionsSettingsView: View {
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)
Text(StatusAction.none.displayName()).tag(StatusAction.none)
}
Section {
ForEach(StatusAction.allCases) { action in
if action != .none {
Label(action.displayName(), systemImage: action.iconName()).tag(action)
Text(action.displayName()).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)
Text(StatusAction.none.displayName()).tag(StatusAction.none)
}
Section {
ForEach(StatusAction.allCases) { action in
if action != .none {
Label(action.displayName(), systemImage: action.iconName()).tag(action)
Text(action.displayName()).tag(action)
}
}
}
}
Toggle(isOn: $userPreferences.swipeActionsUseThemeColor) {
Label("settings.swipeactions.status.use-theme-colors", systemImage: "paintbrush.pointed")
}
Picker(selection: $userPreferences.swipeActionsIconStyle, label: Label("settings.swipeactions.status.icon-style", systemImage: "text.below.photo")) {
ForEach(UserPreferences.SwipeActionsIconStyle.allCases, id: \.rawValue) { style in
Text(style.description).tag(style)
}
}
}
.listRowBackground(theme.primaryBackgroundColor)
}

View file

@ -36,6 +36,8 @@
"enum.status-actions-display.only-buttons" = "Només els botons";
"enum.status-display-style.compact" = "Compacte";
"enum.status-display-style.large" = "Gran";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Dominis";
@ -177,6 +179,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Exploreu";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Nur Buttons";
"enum.status-display-style.compact" = "Kompakt";
"enum.status-display-style.large" = "Groß";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domains";
@ -175,6 +177,8 @@
"settings.swipeactions.status.trailing.left" = "links";
"settings.swipeactions.status.trailing.right" = "rechts";
"settings.swipeactions.status" = "Beitrag";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
"enum.expand-media.show" = "Alle zeigen";
"enum.expand-media.hide" = "Alle ausblenden";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Only buttons";
"enum.status-display-style.compact" = "Compact";
"enum.status-display-style.large" = "Large";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domains";
@ -181,6 +183,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Explore";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Only buttons";
"enum.status-display-style.compact" = "Compact";
"enum.status-display-style.large" = "Large";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domains";
@ -179,6 +181,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Explore";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Sólo botones";
"enum.status-display-style.compact" = "Compacto";
"enum.status-display-style.large" = "Grande";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Dominios";
@ -175,6 +177,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
"enum.expand-media.show" = "Siempre";
"enum.expand-media.hide" = "Nunca";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Botoiak bakarrik";
"enum.status-display-style.compact" = "Trinkoa";
"enum.status-display-style.large" = "Handia";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domeinuak";
@ -175,6 +177,8 @@
"settings.swipeactions.status.trailing.left" = "ezker";
"settings.swipeactions.status.trailing.right" = "eskuma";
"settings.swipeactions.status" = "Argitaratu";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
"enum.expand-media.show" = "Erakutsi guztia";
"enum.expand-media.hide" = "Ezkutatu guztia";
@ -241,8 +245,8 @@
"account.follow.requested" = "Eskaera eginda";
"account.follow-request.accept" = "Onartu";
"account.follow-request.reject" = "Baztertu";
"account.follow-requests.pending-requests" = "Erabakitzeke eskaerak";
"account.follow-requests.instructions" = "Erabiltzaile horiek ez dituzte zure bidalketak ikusiko onartzen ez dituzun arte.";
"account.follow-requests.pending-requests" = "Erabakitzeko eskaerak";
"account.follow-requests.instructions" = "Erabiltzaile horiek ez dituzte zure bidalketak ikusiko onartzen ez dituzun arte.";
"account.followers" = "Jarraitzaile";
"account.following" = "Jarraitzen";
"account.list.create" = "Sortu zerrenda berria";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Seulement les boutons";
"enum.status-display-style.compact" = "Compact";
"enum.status-display-style.large" = "Grand";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domaines";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Explorer";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Solo bottoni";
"enum.status-display-style.compact" = "Compatto";
"enum.status-display-style.large" = "Completo";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domini";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "sinistra";
"settings.swipeactions.status.trailing.right" = "destra";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Esplora";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "ボタンのみ";
"enum.status-display-style.compact" = "コンパクト";
"enum.status-display-style.large" = "ラージ";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "ドメイン";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "左";
"settings.swipeactions.status.trailing.right" = "右";
"settings.swipeactions.status" = "投稿";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "エクスプローラー";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "버튼만 표시";
"enum.status-display-style.compact" = "작게";
"enum.status-display-style.large" = "크게";
"enum.swipeactions.icon-with-text" = "아이콘과 텍스트";
"enum.swipeactions.icon-only" = "아이콘만";
// MARK: Instances
"instance.info.domains" = "도메인";
@ -177,7 +179,9 @@
"settings.swipeactions.status.trailing" = "왼쪽으로 쓸어넘길 때";
"settings.swipeactions.status.trailing.left" = "왼쪽 버튼";
"settings.swipeactions.status.trailing.right" = "오른쪽 버튼";
"settings.swipeactions.status" = "글을";
"settings.swipeactions.status" = "글";
"settings.swipeactions.status.use-theme-colors" = "기본 색상 대신 테마 색상 사용";
"settings.swipeactions.status.icon-style" = "아이콘 모양";
// MARK: Tabs
"tab.explore" = "둘러보기";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Bare knapper";
"enum.status-display-style.compact" = "Kompakt";
"enum.status-display-style.large" = "Stor";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domener";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Utforsk";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Zonder tekst";
"enum.status-display-style.compact" = "Compact";
"enum.status-display-style.large" = "Groot";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domeinen";
@ -175,6 +177,8 @@
"settings.swipeactions.status.trailing.left" = "links";
"settings.swipeactions.status.trailing.right" = "rechts";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Ontdekken";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Tylko przyciski";
"enum.status-display-style.compact" = "Pomniejszone";
"enum.status-display-style.large" = "Duże";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domeny";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "lewa";
"settings.swipeactions.status.trailing.right" = "prawa";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Odkrywaj";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Somente botões";
"enum.status-display-style.compact" = "Compacto";
"enum.status-display-style.large" = "Largo";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domínios";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Explorar";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "Sadece Butonlar";
"enum.status-display-style.compact" = "Kompakt";
"enum.status-display-style.large" = "Geniş";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "Domainler";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "left";
"settings.swipeactions.status.trailing.right" = "right";
"settings.swipeactions.status" = "Post";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "Keşfet";

View file

@ -37,6 +37,8 @@
"enum.status-actions-display.only-buttons" = "仅图标";
"enum.status-display-style.compact" = "紧凑";
"enum.status-display-style.large" = "宽松";
"enum.swipeactions.icon-with-text" = "Icon with text";
"enum.swipeactions.icon-only" = "Icon only";
// MARK: Instances
"instance.info.domains" = "域名";
@ -178,6 +180,8 @@
"settings.swipeactions.status.trailing.left" = "左";
"settings.swipeactions.status.trailing.right" = "右";
"settings.swipeactions.status" = "嘟文";
"settings.swipeactions.status.use-theme-colors" = "Use theme colors instead of default colors";
"settings.swipeactions.status.icon-style" = "Icon style";
// MARK: Tabs
"tab.explore" = "探索";

View file

@ -41,14 +41,18 @@ public enum StatusAction: String, CaseIterable, Identifiable {
}
}
public func color(themeTintColor: Color) -> Color {
public func color(themeTintColor: Color, useThemeColor: Bool, outside: Bool) -> Color {
if (useThemeColor) {
return outside ? themeTintColor : .gray
}
switch self {
case .none:
return .gray
case .reply:
return .gray
return outside ? .gray : Color(white: 0.45)
case .quote:
return .gray
return outside ? .gray : Color(white: 0.45)
case .boost:
return themeTintColor
case .favorite:

View file

@ -44,6 +44,21 @@ public class UserPreferences: ObservableObject {
@AppStorage("swipeactions-status-trailing-left") public var swipeActionsStatusTrailingLeft = StatusAction.boost
@AppStorage("swipeactions-status-leading-left") public var swipeActionsStatusLeadingLeft = StatusAction.reply
@AppStorage("swipeactions-status-leading-right") public var swipeActionsStatusLeadingRight = StatusAction.none
@AppStorage("swipeactions-use-theme-color") public var swipeActionsUseThemeColor = false
@AppStorage("swipeactions-icon-style") public var swipeActionsIconStyle: SwipeActionsIconStyle = .iconWithText
public enum SwipeActionsIconStyle: String, CaseIterable {
case iconWithText, iconOnly
public var description: LocalizedStringKey {
switch self {
case .iconWithText:
return "enum.swipeactions.icon-with-text"
case .iconOnly:
return "enum.swipeactions.icon-only"
}
}
}
public var postVisibility: Models.Visibility {
if useInstanceContentSettings {

View file

@ -467,9 +467,11 @@ public struct StatusRowView: View {
private var trailingSwipeActions: some View {
if preferences.swipeActionsStatusTrailingRight != StatusAction.none, !viewModel.isRemote {
makeSwipeButton(action: preferences.swipeActionsStatusTrailingRight)
.tint(preferences.swipeActionsStatusTrailingRight.color(themeTintColor: theme.tintColor, useThemeColor: preferences.swipeActionsUseThemeColor, outside: true))
}
if preferences.swipeActionsStatusTrailingLeft != StatusAction.none, !viewModel.isRemote {
makeSwipeButton(action: preferences.swipeActionsStatusTrailingLeft)
.tint(preferences.swipeActionsStatusTrailingLeft.color(themeTintColor: theme.tintColor, useThemeColor: preferences.swipeActionsUseThemeColor, outside: false))
}
}
@ -477,9 +479,11 @@ public struct StatusRowView: View {
private var leadingSwipeActions: some View {
if preferences.swipeActionsStatusLeadingLeft != StatusAction.none, !viewModel.isRemote {
makeSwipeButton(action: preferences.swipeActionsStatusLeadingLeft)
.tint(preferences.swipeActionsStatusLeadingLeft.color(themeTintColor: theme.tintColor, useThemeColor: preferences.swipeActionsUseThemeColor, outside: true))
}
if preferences.swipeActionsStatusLeadingRight != StatusAction.none, !viewModel.isRemote {
makeSwipeButton(action: preferences.swipeActionsStatusLeadingRight)
.tint(preferences.swipeActionsStatusLeadingRight.color(themeTintColor: theme.tintColor, useThemeColor: preferences.swipeActionsUseThemeColor, outside: false))
}
}
@ -526,11 +530,8 @@ public struct StatusRowView: View {
HapticManager.shared.fireHaptic(of: .notification(.success))
routerPath.presentedSheet = destination
} label: {
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)
makeSwipeLabel(action: action, style: preferences.swipeActionsIconStyle)
}
.tint(action.color(themeTintColor: theme.tintColor))
}
@ViewBuilder
@ -541,10 +542,21 @@ public struct StatusRowView: View {
await task()
}
} label: {
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))
makeSwipeLabel(action: action, style: preferences.swipeActionsIconStyle)
}
}
@ViewBuilder
private func makeSwipeLabel(action: StatusAction, style: UserPreferences.SwipeActionsIconStyle) -> some View {
switch (style) {
case .iconOnly:
Label(action.displayName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked), systemImage: action.iconName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
.labelStyle(.iconOnly)
.environment(\.symbolVariants, .none)
case .iconWithText:
Label(action.displayName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked), systemImage: action.iconName(isReblogged: viewModel.isReblogged, isFavorited: viewModel.isFavorited, isBookmarked: viewModel.isBookmarked))
.labelStyle(.titleAndIcon)
.environment(\.symbolVariants, .none)
}
.tint(action.color(themeTintColor: theme.tintColor))
}
}