Skip to content

Commit

Permalink
Validate that presentationStyle and alwaysVisibleOptions don't confli…
Browse files Browse the repository at this point in the history
…ct with each other
  • Loading branch information
Friend-LGA committed Feb 5, 2021
1 parent 338e223 commit 00b5e1d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LGSideMenuController/LGSideMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ - (void)setLeftViewPresentationStyle:(LGSideMenuPresentationStyle)leftViewPresen

_leftViewPresentationStyle = leftViewPresentationStyle;

[self validateAlwaysVisibleConflict];
[self setNeedsUpdateLayoutsAndStyles];
}

Expand All @@ -1032,6 +1033,7 @@ - (void)setRightViewPresentationStyle:(LGSideMenuPresentationStyle)rightViewPres

_rightViewPresentationStyle = rightViewPresentationStyle;

[self validateAlwaysVisibleConflict];
[self setNeedsUpdateLayoutsAndStyles];
}

Expand Down Expand Up @@ -1072,6 +1074,7 @@ - (void)setLeftViewAlwaysVisibleOptions:(LGSideMenuAlwaysVisibleOptions)leftView

_leftViewAlwaysVisibleOptions = leftViewAlwaysVisibleOptions;

[self validateAlwaysVisibleConflict];
[self setNeedsUpdateLayoutsAndStyles];
}

Expand All @@ -1080,6 +1083,7 @@ - (void)setRightViewAlwaysVisibleOptions:(LGSideMenuAlwaysVisibleOptions)rightVi

_rightViewAlwaysVisibleOptions = rightViewAlwaysVisibleOptions;

[self validateAlwaysVisibleConflict];
[self setNeedsUpdateLayoutsAndStyles];
}

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 00b5e1d

Please sign in to comment.