diff --git a/Passepartout/App/Views/AddHostView.swift b/Passepartout/App/Views/AddHostView.swift index 9262bbed..36a2bb36 100644 --- a/Passepartout/App/Views/AddHostView.swift +++ b/Passepartout/App/Views/AddHostView.swift @@ -69,28 +69,24 @@ struct AddHostView: View { bindings: bindings ) } - }.themeSecondaryView() - .navigationTitle(L10n.AddProfile.Shared.title) - .toolbar(content: toolbar) - .alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile) - .onAppear(perform: requestResourcePermissions) - .onDisappear(perform: dropResourcePermissions) - } - - @ToolbarContentBuilder - private func toolbar() -> some ToolbarContent { - themeCloseItem(isPresented: bindings.$isPresented) - ToolbarItem(placement: .primaryAction) { - Button(nextString) { - if !viewModel.processedProfile.isPlaceholder { - saveProfile() - } else { - processProfile(replacingExisting: false) + }.toolbar { + themeCloseItem(isPresented: bindings.$isPresented) + ToolbarItem(placement: .primaryAction) { + Button(nextString) { + if !viewModel.processedProfile.isPlaceholder { + saveProfile() + } else { + processProfile(replacingExisting: false) + } } } - } + }.alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile) + .onAppear(perform: requestResourcePermissions) + .onDisappear(perform: dropResourcePermissions) + .navigationTitle(L10n.AddProfile.Shared.title) + .themeSecondaryView() } - + @ViewBuilder private var processingView: some View { AddProfileView.ProfileNameSection( diff --git a/Passepartout/App/Views/AddProviderView+Name.swift b/Passepartout/App/Views/AddProviderView+Name.swift index dbce1863..a0102924 100644 --- a/Passepartout/App/Views/AddProviderView+Name.swift +++ b/Passepartout/App/Views/AddProviderView+Name.swift @@ -78,19 +78,16 @@ extension AddProviderView { bindings: bindings ) } - }.navigationTitle(providerMetadata.fullName) - .toolbar(content: toolbar) - .alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile) + }.toolbar { + Button { + saveProfile(replacingExisting: false) + } label: { + themeSaveButtonLabel() + } + }.alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile) + .navigationTitle(providerMetadata.fullName) } - private func toolbar() -> some View { - Button { - saveProfile(replacingExisting: false) - } label: { - themeSaveButtonLabel() - } - } - private func alertOverwriteExistingProfile() -> Alert { return Alert( title: Text(L10n.AddProfile.Shared.title), diff --git a/Passepartout/App/Views/AddProviderView.swift b/Passepartout/App/Views/AddProviderView.swift index 58e1204e..b8c90344 100644 --- a/Passepartout/App/Views/AddProviderView.swift +++ b/Passepartout/App/Views/AddProviderView.swift @@ -88,19 +88,14 @@ struct AddProviderView: View { // hidden ForEach(providers, id: \.navigationId, content: providerNavigationLink) - }.themeSecondaryView() - .navigationTitle(L10n.AddProfile.Shared.title) - .toolbar(content: toolbar) - .sheet(isPresented: $viewModel.isPaywallPresented) { + }.toolbar { + themeCloseItem(isPresented: bindings.$isPresented) + }.sheet(isPresented: $viewModel.isPaywallPresented) { NavigationView { PaywallView(isPresented: $viewModel.isPaywallPresented) }.themeGlobal() - } - } - - @ToolbarContentBuilder - private func toolbar() -> some ToolbarContent { - themeCloseItem(isPresented: bindings.$isPresented) + }.navigationTitle(L10n.AddProfile.Shared.title) + .themeSecondaryView() } private var mainSection: some View { diff --git a/Passepartout/App/Views/DebugLogView.swift b/Passepartout/App/Views/DebugLogView.swift index ba634ab2..6aa1d2c2 100644 --- a/Passepartout/App/Views/DebugLogView.swift +++ b/Passepartout/App/Views/DebugLogView.swift @@ -55,27 +55,24 @@ struct DebugLogView: View { ScrollViewReader { scrollProxy in ScrollView(showsIndicators: true) { contentView - }.toolbar(content: toolbar) - .onAppear { + }.onAppear { refreshLog(scrollingToLatestWith: scrollProxy) - }.onReceive(timer, perform: refreshLog) + } + }.toolbar { + if !isSharing { + Button(action: shareDebugLog) { + themeShareImage.asSystemImage + }.disabled(logLines.isEmpty) + } else { + ProgressView() + } }.sheet(isPresented: $isSharing, content: sharingActivityView) + .edgesIgnoringSafeArea([.leading, .trailing]) + .onReceive(timer, perform: refreshLog) .navigationTitle(L10n.DebugLog.title) .themeDebugLogFont() - .edgesIgnoringSafeArea([.leading, .trailing]) } - @ViewBuilder - private func toolbar() -> some View { - if !isSharing { - Button(action: shareDebugLog) { - themeShareImage.asSystemImage - }.disabled(logLines.isEmpty) - } else { - ProgressView() - } - } - private var contentView: some View { LazyVStack { ForEach(logLines.indices, id: \.self) { diff --git a/Passepartout/App/Views/OrganizerView.swift b/Passepartout/App/Views/OrganizerView.swift index ce2c17e6..25a0b4de 100644 --- a/Passepartout/App/Views/OrganizerView.swift +++ b/Passepartout/App/Views/OrganizerView.swift @@ -95,9 +95,21 @@ struct OrganizerView: View { didHandleSubreddit: $didHandleSubreddit ) ProfilesList(alertType: $alertType) - }.navigationTitle(Unlocalized.appName) - .toolbar(content: toolbar) - .sheet(item: $modalType, content: presentedModal) + }.toolbar { + ToolbarItem(placement: .primaryAction) { + AddMenu( + modalType: $modalType, + isHostFileImporterPresented: $isHostFileImporterPresented + ) + } + ToolbarItem(placement: .navigation) { + SettingsMenu( + modalType: $modalType, + alertType: $alertType + ) + // EditButton() + } + }.sheet(item: $modalType, content: presentedModal) .alert(item: $alertType, content: presentedAlert) .fileImporter( isPresented: $isHostFileImporterPresented, @@ -105,28 +117,10 @@ struct OrganizerView: View { allowsMultipleSelection: false, onCompletion: onHostFileImporterResult ).onOpenURL(perform: onOpenURL) - } - - @ToolbarContentBuilder - private func toolbar() -> some ToolbarContent { - ToolbarItem(placement: .primaryAction) { - AddMenu( - modalType: $modalType, - isHostFileImporterPresented: $isHostFileImporterPresented - ) - } - ToolbarItem(placement: .navigation) { - SettingsMenu( - modalType: $modalType, - alertType: $alertType - ) -// EditButton() - } + .navigationTitle(Unlocalized.appName) } } -// MARK: Global handlers - extension OrganizerView { @ViewBuilder @@ -223,8 +217,6 @@ extension OrganizerView { } } -// MARK: Actions - extension OrganizerView { private func presentSubscribeReddit() { alertType = .subscribeReddit diff --git a/Passepartout/App/Views/PaywallView.swift b/Passepartout/App/Views/PaywallView.swift index 1e11d811..0de4c66d 100644 --- a/Passepartout/App/Views/PaywallView.swift +++ b/Passepartout/App/Views/PaywallView.swift @@ -59,9 +59,8 @@ struct PaywallView: View { feature: feature ) } - }.themeSecondaryView() - .toolbar { + }.toolbar { themeCloseItem(isPresented: $isPresented) - } + }.themeSecondaryView() } } diff --git a/Passepartout/App/Views/ProfileView.swift b/Passepartout/App/Views/ProfileView.swift index f23b908b..7dba88f0 100644 --- a/Passepartout/App/Views/ProfileView.swift +++ b/Passepartout/App/Views/ProfileView.swift @@ -78,11 +78,20 @@ struct ProfileView: View { } else { welcomeView } - }.themeSecondaryView() - .navigationTitle(title) - .toolbar(content: toolbar) - .sheet(item: $modalType, content: presentedModal) + }.toolbar { + // FIXME: toolbars, unroll single items + ToolbarItemGroup(placement: .navigationBarTrailing) { + if !isDeleted { + MenuBar( + currentProfile: profileManager.currentProfile, + modalType: $modalType + ) + } + } + }.sheet(item: $modalType, content: presentedModal) .onAppear(perform: loadProfileIfNeeded) + .navigationTitle(title) + .themeSecondaryView() } private var title: String { @@ -106,17 +115,6 @@ struct ProfileView: View { WelcomeView() } - private func toolbar() -> some ToolbarContent { - ToolbarItemGroup(placement: .navigationBarTrailing) { - if !isDeleted { - MenuBar( - currentProfile: profileManager.currentProfile, - modalType: $modalType - ) - } - } - } - @ViewBuilder private func presentedModal(_ modalType: ModalType) -> some View { switch modalType { diff --git a/Passepartout/App/Views/ProviderLocationView.swift b/Passepartout/App/Views/ProviderLocationView.swift index b8cf59b9..9786e62c 100644 --- a/Passepartout/App/Views/ProviderLocationView.swift +++ b/Passepartout/App/Views/ProviderLocationView.swift @@ -101,8 +101,17 @@ struct ProviderLocationView: View, ProviderProfileAvailability { } else { EmptyView() } + }.toolbar { + if #available(iOS 15, *) { + Button { + withAnimation { + isShowingFavorites.toggle() + } + } label: { + themeFavoritesImage(isShowingFavorites).asSystemImage + } + } }.navigationTitle(L10n.Provider.Location.title) - .toolbar(content: toolbar) } private var mainView: some View { @@ -120,21 +129,6 @@ struct ProviderLocationView: View, ProviderProfileAvailability { // } } - @ViewBuilder - private func toolbar() -> some View { - if #available(iOS 15, *) { - Button { - withAnimation { - isShowingFavorites.toggle() - } - } label: { - themeFavoritesImage(isShowingFavorites).asSystemImage - } - } else { - self - } - } - private var categoriesView: some View { ForEach(categories, content: categorySection) } diff --git a/Passepartout/App/Views/ShortcutsView.swift b/Passepartout/App/Views/ShortcutsView.swift index bde4108d..96d97624 100644 --- a/Passepartout/App/Views/ShortcutsView.swift +++ b/Passepartout/App/Views/ShortcutsView.swift @@ -66,9 +66,7 @@ struct ShortcutsView: View { shortcutsSection } addSection - }.themeSecondaryView() - .navigationTitle(L10n.Organizer.Items.SiriShortcuts.caption) - .toolbar { + }.toolbar { themeCloseItem(presentationMode: presentationMode) }.sheet(item: $modalType, content: presentedModal) @@ -81,6 +79,9 @@ struct ShortcutsView: View { .onReceive(intentsManager.shouldDismissIntentView) { _ in modalType = nil } + + .navigationTitle(L10n.Organizer.Items.SiriShortcuts.caption) + .themeSecondaryView() } private var shortcutsSection: some View {