Add overtaking indicator to openPanel callback method.

This commit is contained in:
Hedden, Kyle Matthew 2019-12-04 12:56:38 -05:00 committed by Pfeil, Scott Robert
parent 44fd2dffac
commit 3f9b707d37
2 changed files with 22 additions and 10 deletions

View File

@ -16,7 +16,9 @@ NS_ASSUME_NONNULL_BEGIN
@optional @optional
- (void)panelWillAppear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel; - (void)panelWillAppear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel;
- (void)panelWillAppear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel overtakingDetail:(BOOL)willOvertake;
- (void)panelDidAppear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel; - (void)panelDidAppear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel;
- (void)panelDidAppear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel overtakingDetail:(BOOL)didOvertake;
- (void)panelWillDisappear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel; - (void)panelWillDisappear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel;
- (void)panelDidDisappear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel; - (void)panelDidDisappear:(nonnull NSObject <MVMCoreUIPanelProtocol>*)panel;

View File

@ -357,16 +357,19 @@ CGFloat const PanelAnimationDuration = 0.2;
- (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict { - (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict {
[MVMCoreDispatchUtility performBlockOnMainThread:^{ [MVMCoreDispatchUtility performBlockOnMainThread:^{
if (self.mainViewLeading.constant < .1) { if (self.mainViewLeading.constant < .1) {
BOOL shouldExtendLeftPanel = [self shouldExtendLeftPanel];
if (explict) { if (explict) {
self.explictlyShowingPanel = self.leftPanel; self.explictlyShowingPanel = self.leftPanel;
} }
void (^animations)(void) = [self getLeftPanelShowAnimationBlock]; void (^animations)(void) = [self getLeftPanelShowAnimationBlock];
void (^completion)(BOOL) = ^(BOOL finished){ void (^completion)(BOOL) = ^(BOOL finished){
[self panelDidAppear:self.leftPanel animated:animated]; [self panelDidAppear:self.leftPanel didExtend:shouldExtendLeftPanel animated:animated];
}; };
if (![self shouldExtendLeftPanel]) { if (!shouldExtendLeftPanel) {
if ([self.leftPanel respondsToSelector:@selector(showArrow)]){ if ([self.leftPanel respondsToSelector:@selector(showArrow)]){
[self.leftPanel showArrow]; [self.leftPanel showArrow];
} }
@ -389,7 +392,7 @@ CGFloat const PanelAnimationDuration = 0.2;
} }
self.mainViewCoverView.hidden = NO; self.mainViewCoverView.hidden = NO;
[self panelWillAppear:self.leftPanel animated:animated]; [self panelWillAppear:self.leftPanel willExtend:shouldExtendLeftPanel animated:animated];
if (animated) { if (animated) {
[UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion];
} else { } else {
@ -547,19 +550,22 @@ CGFloat const PanelAnimationDuration = 0.2;
- (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict { - (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict {
[MVMCoreDispatchUtility performBlockOnMainThread:^{ [MVMCoreDispatchUtility performBlockOnMainThread:^{
if (self.mainViewTrailing.constant < .1) { if (self.mainViewTrailing.constant < .1) {
BOOL shouldExtendRightPanel = [self shouldExtendRightPanel];
if (explict) { if (explict) {
self.explictlyShowingPanel = self.rightPanel; self.explictlyShowingPanel = self.rightPanel;
} }
void (^animations)(void) = [self getRightPanelShowAnimationBlock]; void (^animations)(void) = [self getRightPanelShowAnimationBlock];
void (^completion)(BOOL) = ^(BOOL finished){ void (^completion)(BOOL) = ^(BOOL finished){
[self panelDidAppear:self.rightPanel animated:animated]; [self panelDidAppear:self.rightPanel didExtend:shouldExtendRightPanel animated:animated];
self.mainView.accessibilityElementsHidden = YES; self.mainView.accessibilityElementsHidden = YES;
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.rightPanel); UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.rightPanel);
}; };
self.mainViewCoverView.hidden = NO; self.mainViewCoverView.hidden = NO;
if (![self shouldExtendRightPanel]) { if (!shouldExtendRightPanel) {
if ([self.rightPanel respondsToSelector:@selector(showArrow)]){ if ([self.rightPanel respondsToSelector:@selector(showArrow)]){
[self.rightPanel showArrow]; [self.rightPanel showArrow];
} }
@ -579,7 +585,7 @@ CGFloat const PanelAnimationDuration = 0.2;
self.rightPanelSeparator = rightPanelSeparator; self.rightPanelSeparator = rightPanelSeparator;
} }
[self panelWillAppear:self.rightPanel animated:animated]; [self panelWillAppear:self.rightPanel willExtend:shouldExtendRightPanel animated:animated];
if (animated) { if (animated) {
[UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion];
} else { } else {
@ -612,7 +618,7 @@ CGFloat const PanelAnimationDuration = 0.2;
[self hideRightPanelIfNeededAnimated:YES]; [self hideRightPanelIfNeededAnimated:YES];
} }
- (void)panelWillAppear:(UIViewController <MVMCoreUIPanelProtocol> *)panel animated:(BOOL)animated { - (void)panelWillAppear:(UIViewController <MVMCoreUIPanelProtocol> *)panel willExtend:(BOOL)willExtend animated:(BOOL)animated {
if ([panel respondsToSelector:@selector(willAppear:)]) { if ([panel respondsToSelector:@selector(willAppear:)]) {
[panel willAppear:animated]; [panel willAppear:animated];
} else { } else {
@ -621,13 +627,15 @@ CGFloat const PanelAnimationDuration = 0.2;
UIViewController *controller = [self getCurrentDetailViewController]; UIViewController *controller = [self getCurrentDetailViewController];
if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) {
UIViewController <MVMCoreUIDetailViewProtocol>* protocolController = (UIViewController <MVMCoreUIDetailViewProtocol>*)controller; UIViewController <MVMCoreUIDetailViewProtocol>* protocolController = (UIViewController <MVMCoreUIDetailViewProtocol>*)controller;
if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { if ([protocolController respondsToSelector:@selector(panelWillAppear:overtakingDetail:)]) {
[protocolController panelWillAppear:panel overtakingDetail:!willExtend];
} else if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) {
[protocolController panelWillAppear:panel]; [protocolController panelWillAppear:panel];
} }
} }
} }
- (void)panelDidAppear:(UIViewController <MVMCoreUIPanelProtocol> *)panel animated:(BOOL)animated { - (void)panelDidAppear:(UIViewController <MVMCoreUIPanelProtocol> *)panel didExtend:(BOOL)didExtend animated:(BOOL)animated {
if ([panel respondsToSelector:@selector(didAppear:)]) { if ([panel respondsToSelector:@selector(didAppear:)]) {
[panel didAppear:animated]; [panel didAppear:animated];
} else { } else {
@ -636,7 +644,9 @@ CGFloat const PanelAnimationDuration = 0.2;
UIViewController *controller = [self getCurrentDetailViewController]; UIViewController *controller = [self getCurrentDetailViewController];
if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) {
UIViewController <MVMCoreUIDetailViewProtocol>* protocolController = (UIViewController <MVMCoreUIDetailViewProtocol>*)controller; UIViewController <MVMCoreUIDetailViewProtocol>* protocolController = (UIViewController <MVMCoreUIDetailViewProtocol>*)controller;
if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { if ([protocolController respondsToSelector:@selector(panelDidAppear:overtakingDetail:)]) {
[protocolController panelDidAppear:panel overtakingDetail:!didExtend];
} else if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) {
[protocolController panelDidAppear:panel]; [protocolController panelDidAppear:panel];
} }
} }