Skip to content

Commit e9373c3

Browse files
lissine0tmolitor-stud-tu
authored andcommitted
Own OmemoKeys view: use AddTopLevelNavigation only on iPads
1 parent 4f43f66 commit e9373c3

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Monal/Classes/SwiftuiHelpers.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,25 @@ class SwiftuiInterface : NSObject {
736736
@objc
737737
func makeOwnOmemoKeyView(_ ownContact: MLContact?) -> UIViewController {
738738
let host = UIHostingController(rootView:AnyView(EmptyView()))
739-
if(ownContact == nil) {
740-
host.rootView = AnyView(UIKitWorkaround(OmemoKeysView(omemoKeys: OmemoKeysForChat(viewContact: nil))))
739+
let delegate = SheetDismisserProtocol()
740+
delegate.host = host
741+
742+
@ViewBuilder
743+
var omemoKeysView: some View {
744+
if(ownContact == nil) {
745+
OmemoKeysView(omemoKeys: OmemoKeysForChat(viewContact: nil))
746+
} else {
747+
OmemoKeysView(omemoKeys: OmemoKeysForChat(viewContact: ObservableKVOWrapper<MLContact>(ownContact!)))
748+
}
749+
}
750+
751+
if (UIDevice.current.userInterfaceIdiom == .phone) || ProcessInfo().isMacCatalystApp {
752+
host.rootView = AnyView(UIKitWorkaround(omemoKeysView))
741753
} else {
742-
host.rootView = AnyView(UIKitWorkaround(OmemoKeysView(omemoKeys: OmemoKeysForChat(viewContact: ObservableKVOWrapper<MLContact>(ownContact!)))))
754+
// The app is running on an iPad
755+
host.rootView = AnyView(AddTopLevelNavigation(withDelegate:delegate, to:omemoKeysView))
743756
}
757+
744758
return host
745759
}
746760

0 commit comments

Comments
 (0)