Move settings tab and profile tab around

This commit is contained in:
Thomas Ricouard 2023-01-26 07:34:29 +01:00
parent 0f412ab309
commit 43ac56302e
16 changed files with 50 additions and 20 deletions

View File

@ -74,6 +74,9 @@ extension View {
case let .statusEditHistory(status): case let .statusEditHistory(status):
StatusEditHistoryView(statusId: status) StatusEditHistoryView(statusId: status)
.withEnvironments() .withEnvironments()
case .settings:
SettingsTabs(popToRootTab: .constant(.settings))
.withEnvironments()
} }
} }
} }
@ -84,5 +87,6 @@ extension View {
.environmentObject(CurrentInstance.shared) .environmentObject(CurrentInstance.shared)
.environmentObject(Theme.shared) .environmentObject(Theme.shared)
.environmentObject(AppAccountsManager.shared) .environmentObject(AppAccountsManager.shared)
.applyTheme(Theme.shared)
} }
} }

View File

@ -21,13 +21,6 @@ struct ProfileTab: View {
AccountDetailView(account: account) AccountDetailView(account: account)
.withAppRouter() .withAppRouter()
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet) .withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
.toolbar {
if UIDevice.current.userInterfaceIdiom != .pad {
ToolbarItem(placement: .navigationBarLeading) {
AppAccountsSelectorView(routerPath: routerPath)
}
}
}
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
.id(currentAccount.account?.id) .id(currentAccount.account?.id)
} else { } else {
@ -37,7 +30,7 @@ struct ProfileTab: View {
} }
} }
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in .onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
if popToRootTab == .messages { if popToRootTab == .profile {
routerPath.path = [] routerPath.path = []
} }
} }

View File

@ -22,12 +22,6 @@ struct AccountSettingsView: View {
var body: some View { var body: some View {
Form { Form {
Section {
NavigationLink(value: RouterDestinations.accountDetailWithAccount(account: account)) {
Label("See Profile", systemImage: "person.crop.circle")
}
}
.listRowBackground(theme.primaryBackgroundColor)
Section { Section {
Label("Edit profile", systemImage: "pencil") Label("Edit profile", systemImage: "pencil")
.onTapGesture { .onTapGesture {

View File

@ -8,6 +8,8 @@ import SwiftUI
import Timeline import Timeline
struct SettingsTabs: View { struct SettingsTabs: View {
@Environment(\.dismiss) private var dismiss
@EnvironmentObject private var pushNotifications: PushNotificationsService @EnvironmentObject private var pushNotifications: PushNotificationsService
@EnvironmentObject private var preferences: UserPreferences @EnvironmentObject private var preferences: UserPreferences
@EnvironmentObject private var client: Client @EnvironmentObject private var client: Client
@ -34,6 +36,15 @@ struct SettingsTabs: View {
.navigationTitle(Text("settings.title")) .navigationTitle(Text("settings.title"))
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar) .toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
.toolbar {
if UIDevice.current.userInterfaceIdiom == .phone {
ToolbarItem {
Button("action.done") {
dismiss()
}
}
}
}
.withAppRouter() .withAppRouter()
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet) .withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
} }

View File

@ -21,7 +21,7 @@ enum Tab: Int, Identifiable, Hashable {
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
return [.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings] return [.timeline, .trending, .federated, .local, .notifications, .mentions, .explore, .messages, .settings]
} else { } 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) MessagesTab(popToRootTab: popToRootTab)
case .settings: case .settings:
SettingsTabs(popToRootTab: popToRootTab) SettingsTabs(popToRootTab: popToRootTab)
case .other, .profile: case .profile:
ProfileTab(popToRootTab: popToRootTab)
case .other:
EmptyView() EmptyView()
} }
} }
@ -72,7 +74,9 @@ enum Tab: Int, Identifiable, Hashable {
Label("tab.messages", systemImage: iconName) Label("tab.messages", systemImage: iconName)
case .settings: case .settings:
Label("tab.settings", systemImage: iconName) Label("tab.settings", systemImage: iconName)
case .other, .profile: case .profile:
Label("tab.profile", systemImage: iconName)
case .other:
EmptyView() EmptyView()
} }
} }
@ -97,7 +101,9 @@ enum Tab: Int, Identifiable, Hashable {
return "tray" return "tray"
case .settings: case .settings:
return "gear" return "gear"
case .other, .profile: case .profile:
return "person.crop.circle"
case .other:
return "" return ""
} }
} }

View File

@ -129,6 +129,7 @@
"tab.settings" = "Einstellungen"; "tab.settings" = "Einstellungen";
"tab.timeline" = "Timeline"; "tab.timeline" = "Timeline";
"tab.trending" = "Im Trend"; "tab.trending" = "Im Trend";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ ist eine gültige Instanz"; "timeline.%@-is-valid" = "%@ ist eine gültige Instanz";

View File

@ -132,6 +132,7 @@
"tab.settings" = "Settings"; "tab.settings" = "Settings";
"tab.timeline" = "Timeline"; "tab.timeline" = "Timeline";
"tab.trending" = "Trending"; "tab.trending" = "Trending";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ is a valid instance"; "timeline.%@-is-valid" = "%@ is a valid instance";

View File

@ -132,6 +132,7 @@
"tab.settings" = "Ajustes"; "tab.settings" = "Ajustes";
"tab.timeline" = "Cronología"; "tab.timeline" = "Cronología";
"tab.trending" = "Tendencias"; "tab.trending" = "Tendencias";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ es una instancia válida"; "timeline.%@-is-valid" = "%@ es una instancia válida";

View File

@ -129,6 +129,7 @@
"tab.settings" = "Impostazioni"; "tab.settings" = "Impostazioni";
"tab.timeline" = "Timeline"; "tab.timeline" = "Timeline";
"tab.trending" = "Trending"; "tab.trending" = "Trending";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ è un'istanza valida"; "timeline.%@-is-valid" = "%@ è un'istanza valida";

View File

@ -115,6 +115,7 @@
"tab.settings" = "設定"; "tab.settings" = "設定";
"tab.timeline" = "タイムライン"; "tab.timeline" = "タイムライン";
"tab.trending" = "トレンド"; "tab.trending" = "トレンド";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ は有効なインスタンスです"; "timeline.%@-is-valid" = "%@ は有効なインスタンスです";

View File

@ -129,6 +129,7 @@
"tab.settings" = "Instellingen"; "tab.settings" = "Instellingen";
"tab.timeline" = "Tijdlijn"; "tab.timeline" = "Tijdlijn";
"tab.trending" = "Trending"; "tab.trending" = "Trending";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ is een geldige instantie"; "timeline.%@-is-valid" = "%@ is een geldige instantie";

View File

@ -119,6 +119,7 @@
"tab.settings" = "Ayarlar"; "tab.settings" = "Ayarlar";
"tab.timeline" = "Zaman Dilimi"; "tab.timeline" = "Zaman Dilimi";
"tab.trending" = "Yükselişte"; "tab.trending" = "Yükselişte";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ geçerli bir oluşum"; "timeline.%@-is-valid" = "%@ geçerli bir oluşum";

View File

@ -130,6 +130,7 @@
"tab.settings" = "设置"; "tab.settings" = "设置";
"tab.timeline" = "时间线"; "tab.timeline" = "时间线";
"tab.trending" = "当下流行"; "tab.trending" = "当下流行";
"tab.profile" = "Profile";
// MARK: Timeline // MARK: Timeline
"timeline.%@-is-valid" = "%@ 是一个可用的服务器"; "timeline.%@-is-valid" = "%@ 是一个可用的服务器";

View File

@ -524,10 +524,14 @@ public struct AccountDetailView: View {
} }
} }
} label: { } label: {
if scrollOffset < -40 {
Image(systemName: "ellipsis.circle")
} else {
Image(systemName: "ellipsis.circle.fill") Image(systemName: "ellipsis.circle.fill")
} }
} }
} }
}
} }
struct AccountDetailView_Previews: PreviewProvider { struct AccountDetailView_Previews: PreviewProvider {

View File

@ -101,6 +101,15 @@ public struct AppAccountsSelectorView: View {
Label("app-account.button.add", systemImage: "person.badge.plus") 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() { private func refreshAccounts() {

View File

@ -29,10 +29,11 @@ public enum SheetDestinations: Identifiable {
case addAccount case addAccount
case addRemoteLocalTimeline case addRemoteLocalTimeline
case statusEditHistory(status: String) case statusEditHistory(status: String)
case settings
public var id: String { public var id: String {
switch self { switch self {
case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor, .mentionStatusEditor: case .editStatusEditor, .newStatusEditor, .replyToStatusEditor, .quoteStatusEditor, .mentionStatusEditor, .settings:
return "statusEditor" return "statusEditor"
case .listEdit: case .listEdit:
return "listEdit" return "listEdit"