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,26 +69,22 @@ 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

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 {
Button {
saveProfile(replacingExisting: false)
} label: {
themeSaveButtonLabel()
}
}.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,25 +55,22 @@ 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 {

View File

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

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 {