Fix location sharing double sheet presentation on the Mac

Which would override each other and break the UI state
This commit is contained in:
Stefan Ceriu
2026-10-06 15:06:13 +03:00
parent 4640f9cec0
commit acd18f3aa9
@@ -16,19 +16,19 @@ struct LocationSharingScreen: View {
switch context.viewState.interactionMode {
case .picker:
mainContent
.sheet(isPresented: .constant(true)) {
.locationSheet {
LocationPickerSheet(context: context)
.alert(item: $context.alertInfo)
}
case .viewStatic:
mainContent
.sheet(isPresented: .constant(true)) {
.locationSheet {
StaticLocationSheet(context: context)
.alert(item: $context.alertInfo)
}
case .viewLive:
mainContent
.sheet(isPresented: .constant(true)) {
.locationSheet {
LiveLocationSheet(context: context)
.alert(item: $context.alertInfo)
}
@@ -122,6 +122,22 @@ struct LocationSharingScreen: View {
}
}
private extension View {
/// The Mac hides a sheet's parent sheet while it's presented, taking the close button with it.
@ViewBuilder
func locationSheet<Content: View>(@ViewBuilder content: @escaping () -> Content) -> some View {
if ProcessInfo.processInfo.isiOSAppOnMac {
safeAreaInset(edge: .bottom, spacing: 0) {
content()
.fixedSize(horizontal: false, vertical: true)
.background(.compound.bgCanvasDefault)
}
} else {
sheet(isPresented: .constant(true), content: content)
}
}
}
// MARK: - Previews
struct LocationSharingScreen_Previews: PreviewProvider, TestablePreview {