mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +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 {
|
switch context.viewState.interactionMode {
|
||||||
case .picker:
|
case .picker:
|
||||||
mainContent
|
mainContent
|
||||||
.sheet(isPresented: .constant(true)) {
|
.locationSheet {
|
||||||
LocationPickerSheet(context: context)
|
LocationPickerSheet(context: context)
|
||||||
.alert(item: $context.alertInfo)
|
.alert(item: $context.alertInfo)
|
||||||
}
|
}
|
||||||
case .viewStatic:
|
case .viewStatic:
|
||||||
mainContent
|
mainContent
|
||||||
.sheet(isPresented: .constant(true)) {
|
.locationSheet {
|
||||||
StaticLocationSheet(context: context)
|
StaticLocationSheet(context: context)
|
||||||
.alert(item: $context.alertInfo)
|
.alert(item: $context.alertInfo)
|
||||||
}
|
}
|
||||||
case .viewLive:
|
case .viewLive:
|
||||||
mainContent
|
mainContent
|
||||||
.sheet(isPresented: .constant(true)) {
|
.locationSheet {
|
||||||
LiveLocationSheet(context: context)
|
LiveLocationSheet(context: context)
|
||||||
.alert(item: $context.alertInfo)
|
.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
|
// MARK: - Previews
|
||||||
|
|
||||||
struct LocationSharingScreen_Previews: PreviewProvider, TestablePreview {
|
struct LocationSharingScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
|
|||||||
Reference in New Issue
Block a user