From 00b5e1dea97f118a360a1e30f00cdd7544967ac4 Mon Sep 17 00:00:00 2001 From: Grigorii Lutkov Date: Fri, 5 Feb 2021 16:39:57 +0300 Subject: [PATCH] Validate that presentationStyle and alwaysVisibleOptions don't conflict with each other --- LGSideMenuController/LGSideMenuController.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/LGSideMenuController/LGSideMenuController.m b/LGSideMenuController/LGSideMenuController.m index dd672c3..dc97f70 100644 --- a/LGSideMenuController/LGSideMenuController.m +++ b/LGSideMenuController/LGSideMenuController.m @@ -1024,6 +1024,7 @@ - (void)setLeftViewPresentationStyle:(LGSideMenuPresentationStyle)leftViewPresen _leftViewPresentationStyle = leftViewPresentationStyle; + [self validateAlwaysVisibleConflict]; [self setNeedsUpdateLayoutsAndStyles]; } @@ -1032,6 +1033,7 @@ - (void)setRightViewPresentationStyle:(LGSideMenuPresentationStyle)rightViewPres _rightViewPresentationStyle = rightViewPresentationStyle; + [self validateAlwaysVisibleConflict]; [self setNeedsUpdateLayoutsAndStyles]; } @@ -1072,6 +1074,7 @@ - (void)setLeftViewAlwaysVisibleOptions:(LGSideMenuAlwaysVisibleOptions)leftView _leftViewAlwaysVisibleOptions = leftViewAlwaysVisibleOptions; + [self validateAlwaysVisibleConflict]; [self setNeedsUpdateLayoutsAndStyles]; } @@ -1080,6 +1083,7 @@ - (void)setRightViewAlwaysVisibleOptions:(LGSideMenuAlwaysVisibleOptions)rightVi _rightViewAlwaysVisibleOptions = rightViewAlwaysVisibleOptions; + [self validateAlwaysVisibleConflict]; [self setNeedsUpdateLayoutsAndStyles]; } @@ -1449,6 +1453,22 @@ - (void)removeRightViews { #pragma mark - Validators +- (void)validateAlwaysVisibleConflict { + if (self.leftViewAlwaysVisibleOptions == LGSideMenuAlwaysVisibleOnNone && self.rightViewAlwaysVisibleOptions == LGSideMenuAlwaysVisibleOnNone) { + return; + } + + if (self.leftView) { + NSAssert(self.leftViewPresentationStyle == LGSideMenuPresentationStyleSlideAbove || self.leftViewPresentationStyle == LGSideMenuPresentationStyleSlideBelow, + @".AlwaysVisibleOptions can be used only with .SlideAbove or .SlideBelow presentation styles"); + } + + if (self.rightView) { + NSAssert(self.rightViewPresentationStyle == LGSideMenuPresentationStyleSlideAbove || self.rightViewPresentationStyle == LGSideMenuPresentationStyleSlideBelow, + @".AlwaysVisibleOptions can be used only with .SlideAbove or .SlideBelow presentation styles"); + } +} + - (void)rootViewsValidate { if (!self.rootView) return;