From e13e8ca5ab90fd8a158c013678dcd68879b859a0 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Mon, 5 Aug 2024 13:59:59 -0400 Subject: [PATCH 1/3] Digital PCT265 story MVAPCT-213 - Allow for panels to override the supported orientation. Force chatbot panel to be full screen width on non tablet devices. --- .../MVMCoreUIPanelProtocol.h | 3 +++ .../MVMCoreUISplitViewController.h | 9 +++++++ .../MVMCoreUISplitViewController.m | 26 +++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h index 8d381b76..bb151cc7 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h @@ -33,6 +33,9 @@ - (void)showArrow; - (void)hideArrow; +/// Orientation supported by the panel. +- (UIInterfaceOrientationMask)supportedInterfac; + /// The width to use if the panel is automatically extended when the screen is big enough. - (CGFloat)panelExtendedWidth; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index ac057f10..915b832a 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -59,6 +59,13 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { @property (nullable, strong, nonatomic) NSSet *cancellables; +/// When set to true, the panel will always be full width of the split. +@property (nonatomic) BOOL leftPanelFullWidth; + +/// When set to true, the panel will always be full width of the split. +@property (nonatomic) BOOL rightPanelFullWidth; + + // Convenience getter + (nullable instancetype)mainSplitViewController; @@ -131,6 +138,8 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { /// Returns true if a panel is showing. - (BOOL)isAPanelShowing; +- (BOOL)isLeftPanelShowing; +- (BOOL)isRightPanelShowing; #pragma mark - Main Subclassables diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 4d865830..78d5ef5a 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -679,6 +679,11 @@ CGFloat const PanelAnimationDuration = 0.2; [protocolController panelDidAppear:panel]; } } + if (@available(iOS 16.0, *)) { + if ([panel respondsToSelector:@selector(supportedInterfac)]) { + [controller setNeedsUpdateOfSupportedInterfaceOrientations]; + } + } } - (void)panelWillDisappear:(UIViewController *)panel animated:(BOOL)animated { @@ -709,6 +714,11 @@ CGFloat const PanelAnimationDuration = 0.2; [protocolController panelDidDisappear:panel]; } } + if (@available(iOS 16.0, *)) { + if ([panel respondsToSelector:@selector(supportedInterfac)]) { + [controller setNeedsUpdateOfSupportedInterfaceOrientations]; + } + } } - (void)addPanel:(nonnull UIViewController *)panel { @@ -999,7 +1009,9 @@ CGFloat const PanelAnimationDuration = 0.2; CGFloat leftPanelExtendedWidth = [self leftPanelExtendedWidth]; CGFloat leftPanelMaxWidth = [self leftPanelMaxWidth]; - if ([self shouldExtendLeftPanel:numberOfDrawers] && viewWidth > leftPanelExtendedWidth) { + if (self.leftPanelFullWidth) { + self.leftPanelWidth.constant = viewWidth; + } else if ([self shouldExtendLeftPanel:numberOfDrawers] && viewWidth > leftPanelExtendedWidth) { self.leftPanelWidth.constant = leftPanelExtendedWidth; } else if (viewWidth > leftPanelMaxWidth) { self.leftPanelWidth.constant = leftPanelMaxWidth; @@ -1009,7 +1021,9 @@ CGFloat const PanelAnimationDuration = 0.2; CGFloat rightPanelExtendedWidth = [self rightPanelExtendedWidth]; CGFloat rightPanelMaxWidth = [self rightPanelMaxWidth]; - if ([self shouldExtendRightPanel:numberOfDrawers] && viewWidth > rightPanelExtendedWidth) { + if (self.rightPanelFullWidth) { + self.rightPanelWidth.constant = viewWidth; + } else if ([self shouldExtendRightPanel:numberOfDrawers] && viewWidth > rightPanelExtendedWidth) { self.rightPanelWidth.constant = rightPanelExtendedWidth; } else if (viewWidth > rightPanelMaxWidth) { self.rightPanelWidth.constant = rightPanelMaxWidth; @@ -1063,6 +1077,14 @@ CGFloat const PanelAnimationDuration = 0.2; return fabs(self.mainViewLeading.constant) > 1; } +- (BOOL)isLeftPanelShowing { + return !self.leftView.isHidden; +} + +- (BOOL)isRightPanelShowing { + return !self.rightView.isHidden; +} + #pragma mark - Getters // Returns the desired view or falls back. Hot fix until we can get away from using these functions... From 1d2defeabbd0bf46afc848adf25599cc6fef1eb7 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 6 Aug 2024 09:53:59 -0400 Subject: [PATCH 2/3] Digital PCT265 story MVAPCT-213 - Add Helper to update the orientation. --- .../Utility/MVMCoreUIUtility+Extension.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift index 5b70412e..18578682 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift +++ b/MVMCoreUI/Utility/MVMCoreUIUtility+Extension.swift @@ -102,4 +102,22 @@ public extension MVMCoreUIUtility { return nil } } + + @available(iOS 16.0, *) + @objc @MainActor + static func setNeedsUpdateOfSupportedInterfaceOrientations() { + var viewController = NavigationHandler.shared().getViewControllerToPresentOn() + while let presentedController = viewController?.presentedViewController, + !presentedController.isBeingDismissed { + viewController = presentedController + } + if let navigationController = viewController as? UINavigationController { + viewController = navigationController.topViewController + } + if let viewController = viewController { + viewController.setNeedsUpdateOfSupportedInterfaceOrientations() + } else if let viewController = MVMCoreUISession.sharedGlobal()?.navigationController?.topViewController { + viewController.setNeedsUpdateOfSupportedInterfaceOrientations() + } + } } From dfbb53f5453eb69f24a98692b95438d95e544464 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Tue, 6 Aug 2024 10:31:18 -0400 Subject: [PATCH 3/3] Digital PCT265 story MVAPCT-213 - Function name update --- .../Containers/SplitViewController/MVMCoreUIPanelProtocol.h | 2 +- .../SplitViewController/MVMCoreUISplitViewController.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h index bb151cc7..589dd5f3 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h @@ -34,7 +34,7 @@ - (void)hideArrow; /// Orientation supported by the panel. -- (UIInterfaceOrientationMask)supportedInterfac; +- (UIInterfaceOrientationMask)supportedInterface; /// The width to use if the panel is automatically extended when the screen is big enough. - (CGFloat)panelExtendedWidth; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 78d5ef5a..ec2e7d27 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -680,7 +680,7 @@ CGFloat const PanelAnimationDuration = 0.2; } } if (@available(iOS 16.0, *)) { - if ([panel respondsToSelector:@selector(supportedInterfac)]) { + if ([panel respondsToSelector:@selector(supportedInterface)]) { [controller setNeedsUpdateOfSupportedInterfaceOrientations]; } } @@ -715,7 +715,7 @@ CGFloat const PanelAnimationDuration = 0.2; } } if (@available(iOS 16.0, *)) { - if ([panel respondsToSelector:@selector(supportedInterfac)]) { + if ([panel respondsToSelector:@selector(supportedInterface)]) { [controller setNeedsUpdateOfSupportedInterfaceOrientations]; } }