Add close button to modals
Swipe down only works on iOS portrait and iPadOS.
This commit is contained in:
parent
991a283de9
commit
20ec8d472f
|
@ -188,8 +188,8 @@ extension View {
|
|||
"heart.fill"
|
||||
}
|
||||
|
||||
var themeAboutImage: String {
|
||||
"info.circle"
|
||||
var themeCloseImage: String {
|
||||
"xmark"
|
||||
}
|
||||
|
||||
var themeDeleteImage: String {
|
||||
|
@ -280,6 +280,26 @@ extension String {
|
|||
// MARK: Shortcuts
|
||||
|
||||
extension View {
|
||||
func themeCloseItem(presentationMode: Binding<PresentationMode>) -> some ToolbarContent {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
} label: {
|
||||
themeCloseImage.asSystemImage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func themeCloseItem(isPresented: Binding<Bool>) -> some ToolbarContent {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button {
|
||||
isPresented.wrappedValue = false
|
||||
} label: {
|
||||
themeCloseImage.asSystemImage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func themeSaveButtonLabel() -> some View {
|
||||
// themeCheckmarkImage.asSystemImage
|
||||
Text(L10n.Global.Strings.save)
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
import SwiftUI
|
||||
|
||||
struct AboutView: View {
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
|
||||
private let versionString = Constants.Global.appVersionString
|
||||
|
||||
private let readmeURL = Constants.URLs.readme
|
||||
|
@ -47,6 +49,9 @@ struct AboutView: View {
|
|||
webSubview
|
||||
}.themeSecondaryView()
|
||||
.navigationTitle(L10n.About.title)
|
||||
.toolbar {
|
||||
themeCloseItem(presentationMode: presentationMode)
|
||||
}
|
||||
}
|
||||
|
||||
private var infoSubview: some View {
|
||||
|
|
|
@ -77,12 +77,16 @@ struct AddHostView: View {
|
|||
.onDisappear(perform: dropResourcePermissions)
|
||||
}
|
||||
|
||||
private func toolbar() -> some View {
|
||||
Button(nextString) {
|
||||
if !viewModel.processedProfile.isPlaceholder {
|
||||
saveProfile()
|
||||
} else {
|
||||
processProfile(replacingExisting: false)
|
||||
@ToolbarContentBuilder
|
||||
private func toolbar() -> some ToolbarContent {
|
||||
themeCloseItem(isPresented: bindings.$isPresented)
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(nextString) {
|
||||
if !viewModel.processedProfile.isPlaceholder {
|
||||
saveProfile()
|
||||
} else {
|
||||
processProfile(replacingExisting: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ struct AddProviderView: View {
|
|||
ForEach(viewModel.providers, id: \.navigationId, content: providerNavigationLink)
|
||||
}.themeSecondaryView()
|
||||
.navigationTitle(L10n.AddProfile.Shared.title)
|
||||
.toolbar(content: toolbar)
|
||||
.sheet(isPresented: $viewModel.isPaywallPresented) {
|
||||
NavigationView {
|
||||
PaywallView(isPresented: $viewModel.isPaywallPresented)
|
||||
|
@ -95,6 +96,11 @@ struct AddProviderView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@ToolbarContentBuilder
|
||||
private func toolbar() -> some ToolbarContent {
|
||||
themeCloseItem(isPresented: bindings.$isPresented)
|
||||
}
|
||||
|
||||
private var mainSection: some View {
|
||||
Section(
|
||||
footer: Text(L10n.AddProfile.Provider.Sections.Vpn.footer)
|
||||
|
|
|
@ -42,7 +42,7 @@ struct DonateView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
|
||||
@ObservedObject private var productManager: ProductManager
|
||||
|
||||
|
@ -60,7 +60,9 @@ struct DonateView: View {
|
|||
.disabled(pendingDonationIdentifier != nil)
|
||||
}.themeSecondaryView()
|
||||
.navigationTitle(L10n.Donate.title)
|
||||
.alert(item: $alertType, content: presentedAlert)
|
||||
.toolbar {
|
||||
themeCloseItem(presentationMode: presentationMode)
|
||||
}.alert(item: $alertType, content: presentedAlert)
|
||||
}
|
||||
|
||||
private func presentedAlert(_ alertType: AlertType) -> Alert {
|
||||
|
|
|
@ -60,5 +60,8 @@ struct PaywallView: View {
|
|||
)
|
||||
}
|
||||
}.themeSecondaryView()
|
||||
.toolbar {
|
||||
themeCloseItem(isPresented: $isPresented)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,8 +55,11 @@ extension ProfileView {
|
|||
}.themeSecondaryView()
|
||||
.navigationTitle(currentProfile.value.header.name)
|
||||
.toolbar {
|
||||
Button(action: commitRenaming) {
|
||||
themeDoneButtonLabel()
|
||||
themeCloseItem(presentationMode: presentationMode)
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(action: commitRenaming) {
|
||||
themeDoneButtonLabel()
|
||||
}
|
||||
}
|
||||
}.alert(isPresented: $isOverwritingExistingProfile, content: alertOverwriteExistingProfile)
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ struct ShortcutsView: View {
|
|||
|
||||
@ObservedObject private var intentsManager: IntentsManager
|
||||
|
||||
@Environment(\.presentationMode) private var presentationMode
|
||||
|
||||
private let target: Profile
|
||||
|
||||
@State private var modalType: ModalType?
|
||||
|
@ -66,7 +68,9 @@ struct ShortcutsView: View {
|
|||
addSection
|
||||
}.themeSecondaryView()
|
||||
.navigationTitle(L10n.Organizer.Items.SiriShortcuts.caption)
|
||||
.sheet(item: $modalType, content: presentedModal)
|
||||
.toolbar {
|
||||
themeCloseItem(presentationMode: presentationMode)
|
||||
}.sheet(item: $modalType, content: presentedModal)
|
||||
.onAppear {
|
||||
intentsManager.reloadShortcuts()
|
||||
}.onReceive(intentsManager.shouldDismissIntentView) { _ in
|
||||
|
|
Loading…
Reference in New Issue