mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Fix location sharing double sheet presentation on the Mac
Which would override each other and break the UI state
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user