Move toolbar content inline

For consistency, can search with "toolbar {".
This commit is contained in:
Davide De Rosa 2022-04-21 15:56:26 +02:00
parent 23d184ae08
commit 992178bcd6
9 changed files with 85 additions and 116 deletions

View File

@ -69,16 +69,7 @@ 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 {
}.toolbar {
themeCloseItem(isPresented: bindings.$isPresented)
ToolbarItem(placement: .primaryAction) {
Button(nextString) {
@ -89,6 +80,11 @@ struct AddHostView: View {
}
}
}
}.alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile)
.onAppear(perform: requestResourcePermissions)
.onDisappear(perform: dropResourcePermissions)
.navigationTitle(L10n.AddProfile.Shared.title)
.themeSecondaryView()
}
@ViewBuilder

View File

@ -78,17 +78,14 @@ extension AddProviderView {
bindings: bindings
)
}
}.navigationTitle(providerMetadata.fullName)
.toolbar(content: toolbar)
.alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile)
}
private func toolbar() -> some View {
}.toolbar {
Button {
saveProfile(replacingExisting: false)
} label: {
themeSaveButtonLabel()
}
}.alert(isPresented: $viewModel.isAskingOverwrite, content: alertOverwriteExistingProfile)
.navigationTitle(providerMetadata.fullName)
}
private func alertOverwriteExistingProfile() -> Alert {

View File

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

View File

@ -55,18 +55,10 @@ struct DebugLogView: View {
ScrollViewReader { scrollProxy in
ScrollView(showsIndicators: true) {
contentView
}.toolbar(content: toolbar)
.onAppear {
}.onAppear {
refreshLog(scrollingToLatestWith: scrollProxy)
}.onReceive(timer, perform: refreshLog)
}.sheet(isPresented: $isSharing, content: sharingActivityView)
.navigationTitle(L10n.DebugLog.title)
.themeDebugLogFont()
.edgesIgnoringSafeArea([.leading, .trailing])
}
@ViewBuilder
private func toolbar() -> some View {
}.toolbar {
if !isSharing {
Button(action: shareDebugLog) {
themeShareImage.asSystemImage
@ -74,6 +66,11 @@ struct DebugLogView: View {
} else {
ProgressView()
}
}.sheet(isPresented: $isSharing, content: sharingActivityView)
.edgesIgnoringSafeArea([.leading, .trailing])
.onReceive(timer, perform: refreshLog)
.navigationTitle(L10n.DebugLog.title)
.themeDebugLogFont()
}
private var contentView: some View {

View File

@ -95,20 +95,7 @@ struct OrganizerView: View {
didHandleSubreddit: $didHandleSubreddit
)
ProfilesList(alertType: $alertType)
}.navigationTitle(Unlocalized.appName)
.toolbar(content: toolbar)
.sheet(item: $modalType, content: presentedModal)
.alert(item: $alertType, content: presentedAlert)
.fileImporter(
isPresented: $isHostFileImporterPresented,
allowedContentTypes: hostFileTypes,
allowsMultipleSelection: false,
onCompletion: onHostFileImporterResult
).onOpenURL(perform: onOpenURL)
}
@ToolbarContentBuilder
private func toolbar() -> some ToolbarContent {
}.toolbar {
ToolbarItem(placement: .primaryAction) {
AddMenu(
modalType: $modalType,
@ -120,13 +107,20 @@ struct OrganizerView: View {
modalType: $modalType,
alertType: $alertType
)
// EditButton()
// EditButton()
}
}.sheet(item: $modalType, content: presentedModal)
.alert(item: $alertType, content: presentedAlert)
.fileImporter(
isPresented: $isHostFileImporterPresented,
allowedContentTypes: hostFileTypes,
allowsMultipleSelection: false,
onCompletion: onHostFileImporterResult
).onOpenURL(perform: onOpenURL)
.navigationTitle(Unlocalized.appName)
}
}
// MARK: Global handlers
extension OrganizerView {
@ViewBuilder
@ -223,8 +217,6 @@ extension OrganizerView {
}
}
// MARK: Actions
extension OrganizerView {
private func presentSubscribeReddit() {
alertType = .subscribeReddit

View File

@ -59,9 +59,8 @@ struct PaywallView: View {
feature: feature
)
}
}.themeSecondaryView()
.toolbar {
}.toolbar {
themeCloseItem(isPresented: $isPresented)
}
}.themeSecondaryView()
}
}

View File

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

View File

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

View File

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