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):
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)
}
}

View file

@ -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 = []
}
}

View file

@ -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 {

View file

@ -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)
}

View file

@ -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 ""
}
}

View file

@ -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";

View file

@ -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";

View file

@ -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";

View file

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

View file

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

View file

@ -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";

View file

@ -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";

View file

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

View file

@ -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")
}
}
}
}

View file

@ -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() {

View file

@ -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"