From 009becfde7a581bbf8e94ff8f7e815a2fcc03e49 Mon Sep 17 00:00:00 2001 From: Matthew Fennell Date: Sat, 31 Aug 2024 16:11:54 +0100 Subject: [PATCH] Always display back button on catalyst On iOS, you can dismiss modals by dragging down on them, or by tapping outside of the modal. The same affordances are not made on MacOS. This means that, if you open the contact details view on catalyst at the moment, it is impossible to close the view, since we have disabled showing the back button in AddTopLevelNavigation when the size class is regular (which is normally the case on MacOS). Therefore, if the current target is mac catalyst, we should always display back buttons on modals, so that users can dismiss them without having to force close the app. Thanks lissine for finding this, and suggesting how to fix it. Co-authored-by: lissine --- Monal/Classes/SwiftuiHelpers.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Monal/Classes/SwiftuiHelpers.swift b/Monal/Classes/SwiftuiHelpers.swift index 2441339ad..4d2586ec3 100644 --- a/Monal/Classes/SwiftuiHelpers.swift +++ b/Monal/Classes/SwiftuiHelpers.swift @@ -573,7 +573,11 @@ struct AddTopLevelNavigation: View { .navigationBarTitleDisplayMode(.automatic) .navigationBarBackButtonHidden(true) // will not be shown because swiftui does not know we navigated here from UIKit .toolbar { +#if targetEnvironment(macCatalyst) + let shouldDisplayBackButton = true +#else let shouldDisplayBackButton = UIUserInterfaceSizeClass(rawValue: sizeClass.horizontal) == .compact +#endif if shouldDisplayBackButton { ToolbarItem(placement: .topBarLeading) { Button(action : {