From 43ac56302e38b62b6a6adafe6132ba35ee29c7d6 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Thu, 26 Jan 2023 07:34:29 +0100 Subject: [PATCH] Move settings tab and profile tab around --- IceCubesApp/App/AppRouter.swift | 4 ++++ IceCubesApp/App/Tabs/ProfileTab.swift | 9 +-------- .../App/Tabs/Settings/AccountSettingView.swift | 6 ------ IceCubesApp/App/Tabs/Settings/SettingsTab.swift | 11 +++++++++++ IceCubesApp/App/Tabs/Tabs.swift | 14 ++++++++++---- .../Localization/de.lproj/Localizable.strings | 1 + .../Localization/en.lproj/Localizable.strings | 1 + .../Localization/es.lproj/Localizable.strings | 1 + .../Localization/it.lproj/Localizable.strings | 1 + .../Localization/ja.lproj/Localizable.strings | 1 + .../Localization/nl.lproj/Localizable.strings | 1 + .../Localization/tr.lproj/Localizable.strings | 1 + .../Localization/zh-Hans.lproj/Localizable.strings | 1 + .../Sources/Account/AccountDetailView.swift | 6 +++++- .../AppAccount/AppAccountsSelectorView.swift | 9 +++++++++ Packages/Env/Sources/Env/Router.swift | 3 ++- 16 files changed, 50 insertions(+), 20 deletions(-) diff --git a/IceCubesApp/App/AppRouter.swift b/IceCubesApp/App/AppRouter.swift index ae75e306..8e57a7f1 100644 --- a/IceCubesApp/App/AppRouter.swift +++ b/IceCubesApp/App/AppRouter.swift @@ -74,6 +74,9 @@ extension View { case let .statusEditHistory(status): StatusEditHistoryView(statusId: status) .withEnvironments() + case .settings: + SettingsTabs(popToRootTab: .constant(.settings)) + .withEnvironments() } } } @@ -84,5 +87,6 @@ extension View { .environmentObject(CurrentInstance.shared) .environmentObject(Theme.shared) .environmentObject(AppAccountsManager.shared) + .applyTheme(Theme.shared) } } diff --git a/IceCubesApp/App/Tabs/ProfileTab.swift b/IceCubesApp/App/Tabs/ProfileTab.swift index c4300bc8..1fa7d0d3 100644 --- a/IceCubesApp/App/Tabs/ProfileTab.swift +++ b/IceCubesApp/App/Tabs/ProfileTab.swift @@ -21,13 +21,6 @@ struct ProfileTab: View { AccountDetailView(account: account) .withAppRouter() .withSheetDestinations(sheetDestinations: $routerPath.presentedSheet) - .toolbar { - if UIDevice.current.userInterfaceIdiom != .pad { - ToolbarItem(placement: .navigationBarLeading) { - AppAccountsSelectorView(routerPath: routerPath) - } - } - } .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) .id(currentAccount.account?.id) } else { @@ -37,7 +30,7 @@ struct ProfileTab: View { } } .onChange(of: $popToRootTab.wrappedValue) { popToRootTab in - if popToRootTab == .messages { + if popToRootTab == .profile { routerPath.path = [] } } diff --git a/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift b/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift index bd031795..dccbad8f 100644 --- a/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift +++ b/IceCubesApp/App/Tabs/Settings/AccountSettingView.swift @@ -22,12 +22,6 @@ struct AccountSettingsView: View { var body: some View { Form { - Section { - NavigationLink(value: RouterDestinations.accountDetailWithAccount(account: account)) { - Label("See Profile", systemImage: "person.crop.circle") - } - } - .listRowBackground(theme.primaryBackgroundColor) Section { Label("Edit profile", systemImage: "pencil") .onTapGesture { diff --git a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift index d3bc7357..eaae5c3f 100644 --- a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift +++ b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift @@ -8,6 +8,8 @@ import SwiftUI import Timeline struct SettingsTabs: View { + @Environment(\.dismiss) private var dismiss + @EnvironmentObject private var pushNotifications: PushNotificationsService @EnvironmentObject private var preferences: UserPreferences @EnvironmentObject private var client: Client @@ -34,6 +36,15 @@ struct SettingsTabs: View { .navigationTitle(Text("settings.title")) .navigationBarTitleDisplayMode(.inline) .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) + .toolbar { + if UIDevice.current.userInterfaceIdiom == .phone { + ToolbarItem { + Button("action.done") { + dismiss() + } + } + } + } .withAppRouter() .withSheetDestinations(sheetDestinations: $routerPath.presentedSheet) } diff --git a/IceCubesApp/App/Tabs/Tabs.swift b/IceCubesApp/App/Tabs/Tabs.swift index 168b3635..684e0291 100644 --- a/IceCubesApp/App/Tabs/Tabs.swift +++ b/IceCubesApp/App/Tabs/Tabs.swift @@ -21,7 +21,7 @@ enum Tab: Int, Identifiable, Hashable { if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { return [.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings] } else { - return [.timeline, .notifications, .explore, .messages, .settings] + return [.timeline, .notifications, .explore, .messages, .profile] } } @@ -46,7 +46,9 @@ enum Tab: Int, Identifiable, Hashable { MessagesTab(popToRootTab: popToRootTab) case .settings: SettingsTabs(popToRootTab: popToRootTab) - case .other, .profile: + case .profile: + ProfileTab(popToRootTab: popToRootTab) + case .other: EmptyView() } } @@ -72,7 +74,9 @@ enum Tab: Int, Identifiable, Hashable { Label("tab.messages", systemImage: iconName) case .settings: Label("tab.settings", systemImage: iconName) - case .other, .profile: + case .profile: + Label("tab.profile", systemImage: iconName) + case .other: EmptyView() } } @@ -97,7 +101,9 @@ enum Tab: Int, Identifiable, Hashable { return "tray" case .settings: return "gear" - case .other, .profile: + case .profile: + return "person.crop.circle" + case .other: return "" } } diff --git a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings index 779d7c47..79aaeeaa 100644 --- a/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/de.lproj/Localizable.strings @@ -129,6 +129,7 @@ "tab.settings" = "Einstellungen"; "tab.timeline" = "Timeline"; "tab.trending" = "Im Trend"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ ist eine gültige Instanz"; diff --git a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings index 20b3c23c..20f6e2ec 100644 --- a/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/en.lproj/Localizable.strings @@ -132,6 +132,7 @@ "tab.settings" = "Settings"; "tab.timeline" = "Timeline"; "tab.trending" = "Trending"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ is a valid instance"; diff --git a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings index 3d7789c4..0ff0eddd 100644 --- a/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/es.lproj/Localizable.strings @@ -132,6 +132,7 @@ "tab.settings" = "Ajustes"; "tab.timeline" = "Cronología"; "tab.trending" = "Tendencias"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ es una instancia válida"; diff --git a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings index f237ecc5..22f1282f 100644 --- a/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/it.lproj/Localizable.strings @@ -129,6 +129,7 @@ "tab.settings" = "Impostazioni"; "tab.timeline" = "Timeline"; "tab.trending" = "Trending"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ è un'istanza valida"; diff --git a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings index 197d09ee..9686771e 100644 --- a/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/ja.lproj/Localizable.strings @@ -115,6 +115,7 @@ "tab.settings" = "設定"; "tab.timeline" = "タイムライン"; "tab.trending" = "トレンド"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ は有効なインスタンスです"; diff --git a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings index fc974aee..38d2401a 100644 --- a/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/nl.lproj/Localizable.strings @@ -129,6 +129,7 @@ "tab.settings" = "Instellingen"; "tab.timeline" = "Tijdlijn"; "tab.trending" = "Trending"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ is een geldige instantie"; diff --git a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings index 71d9fdab..6e08a39a 100644 --- a/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/tr.lproj/Localizable.strings @@ -119,6 +119,7 @@ "tab.settings" = "Ayarlar"; "tab.timeline" = "Zaman Dilimi"; "tab.trending" = "Yükselişte"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ geçerli bir oluşum"; diff --git a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings index c4637c4f..1f504d5a 100644 --- a/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings +++ b/IceCubesApp/Resources/Localization/zh-Hans.lproj/Localizable.strings @@ -130,6 +130,7 @@ "tab.settings" = "设置"; "tab.timeline" = "时间线"; "tab.trending" = "当下流行"; +"tab.profile" = "Profile"; // MARK: Timeline "timeline.%@-is-valid" = "%@ 是一个可用的服务器"; diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 75239009..cc62bda3 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -524,7 +524,11 @@ public struct AccountDetailView: View { } } } label: { - Image(systemName: "ellipsis.circle.fill") + if scrollOffset < -40 { + Image(systemName: "ellipsis.circle") + } else { + Image(systemName: "ellipsis.circle.fill") + } } } } diff --git a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift index 3a35640f..f4aab96b 100644 --- a/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift +++ b/Packages/AppAccount/Sources/AppAccount/AppAccountsSelectorView.swift @@ -101,6 +101,15 @@ public struct AppAccountsSelectorView: View { Label("app-account.button.add", systemImage: "person.badge.plus") } } + + if UIDevice.current.userInterfaceIdiom == .phone { + Divider() + Button { + routerPath.presentedSheet = .settings + } label: { + Label("tab.settings", systemImage: "gear") + } + } } private func refreshAccounts() { diff --git a/Packages/Env/Sources/Env/Router.swift b/Packages/Env/Sources/Env/Router.swift index d4868418..38cb4dc5 100644 --- a/Packages/Env/Sources/Env/Router.swift +++ b/Packages/Env/Sources/Env/Router.swift @@ -29,10 +29,11 @@ public enum SheetDestinations: Identifiable { case addAccount case addRemoteLocalTimeline case statusEditHistory(status: String) + case settings public var id: String { switch self { - case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor, .mentionStatusEditor: + case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor, .mentionStatusEditor, .settings: return "statusEditor" case .listEdit: return "listEdit"