From ec444e7ce1bce68bd2bcd3e5b91e2752da256f52 Mon Sep 17 00:00:00 2001 From: Arturs Krumins Date: Thu, 3 Oct 2024 21:18:13 +0300 Subject: [PATCH] load sheet navigation titles before presenting (#4963) * load sheet navigation titles before presenting * list background during loading --- .../Shared/Views/ChatList/ChatListView.swift | 65 ++++++++++--------- .../RemoteAccess/ConnectDesktopView.swift | 11 ---- .../Views/UserSettings/SettingsView.swift | 5 +- 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 856199a405..53c4be35a4 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -18,6 +18,17 @@ enum UserPickerSheet: Identifiable { case settings var id: Self { self } + + var navigationTitle: LocalizedStringKey { + switch self { + case .address: "SimpleX address" + case .chatPreferences: "Your preferences" + case .chatProfiles: "Your chat profiles" + case .currentProfile: "Your current profile" + case .useFromDesktop: "Connect to desktop" + case .settings: "Your settings" + } + } } struct UserPickerSheetView: View { @@ -27,43 +38,39 @@ struct UserPickerSheetView: View { @State private var loaded = false var body: some View { - Group { - if loaded, let currentUser = chatModel.currentUser { - switch sheet { - case .address: - NavigationView { + NavigationView { + ZStack { + if loaded, let currentUser = chatModel.currentUser { + switch sheet { + case .address: UserAddressView(shareViaProfile: currentUser.addressShared) - .navigationTitle("SimpleX address") - .navigationBarTitleDisplayMode(.large) - .modifier(ThemedBackground(grouped: true)) - } - case .chatProfiles: - NavigationView { + case .chatPreferences: + PreferencesView( + profile: currentUser.profile, + preferences: currentUser.fullPreferences, + currentPreferences: currentUser.fullPreferences + ) + case .chatProfiles: UserProfilesView() - } - case .currentProfile: - NavigationView { + case .currentProfile: UserProfile() - .navigationTitle("Your current profile") - .modifier(ThemedBackground(grouped: true)) + case .useFromDesktop: + ConnectDesktopView() + case .settings: + SettingsView(showSettings: $showSettings, withNavigation: false) } - case .chatPreferences: - NavigationView { - PreferencesView(profile: currentUser.profile, preferences: currentUser.fullPreferences, currentPreferences: currentUser.fullPreferences) - .navigationTitle("Your preferences") - .navigationBarTitleDisplayMode(.large) - .modifier(ThemedBackground(grouped: true)) - } - case .useFromDesktop: - ConnectDesktopView(viaSettings: false) - case .settings: - SettingsView(showSettings: $showSettings) - .navigationBarTitleDisplayMode(.large) } + Color.clear // Required for list background to be rendered during loading } + .navigationTitle(sheet.navigationTitle) + .navigationBarTitleDisplayMode(.large) + .modifier(ThemedBackground(grouped: true)) } .task { - withAnimation(.easeOut(duration: 0.1)) { loaded = true } + withAnimation( + .easeOut(duration: 0.1), + { loaded = true } + ) } } } diff --git a/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift b/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift index b1f68c09f4..b99c054abb 100644 --- a/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift +++ b/apps/ios/Shared/Views/RemoteAccess/ConnectDesktopView.swift @@ -14,7 +14,6 @@ struct ConnectDesktopView: View { @EnvironmentObject var m: ChatModel @EnvironmentObject var theme: AppTheme @Environment(\.dismiss) var dismiss: DismissAction - var viaSettings = false @AppStorage(DEFAULT_DEVICE_NAME_FOR_REMOTE_ACCESS) private var deviceName = UIDevice.current.name @AppStorage(DEFAULT_CONFIRM_REMOTE_SESSIONS) private var confirmRemoteSessions = false @AppStorage(DEFAULT_CONNECT_REMOTE_VIA_MULTICAST) private var connectRemoteViaMulticast = true @@ -57,16 +56,6 @@ struct ConnectDesktopView: View { } var body: some View { - if viaSettings { - viewBody - } else { - NavigationView { - viewBody - } - } - } - - var viewBody: some View { Group { let discovery = m.remoteCtrlSession?.discovery if discovery == true || (discovery == nil && !showConnectScreen) { diff --git a/apps/ios/Shared/Views/UserSettings/SettingsView.swift b/apps/ios/Shared/Views/UserSettings/SettingsView.swift index e018b181e6..83630f798d 100644 --- a/apps/ios/Shared/Views/UserSettings/SettingsView.swift +++ b/apps/ios/Shared/Views/UserSettings/SettingsView.swift @@ -262,10 +262,13 @@ struct SettingsView: View { @EnvironmentObject var theme: AppTheme @Binding var showSettings: Bool @State private var showProgress: Bool = false + var withNavigation = true var body: some View { ZStack { - NavigationView { + if withNavigation { + NavigationView { settingsView() } + } else { settingsView() } if showProgress {