Merge pull request #9 in BPHVB/mvm_core_ui from feature/detail_view_protocol_right_left_button to develop

* commit '82dabe019b5b933de833bc9d8bfa0be66116f6df':
  rightPanelLinkDict
  code review
  isOverridingLeftButton
  code review
  detail_view_protocol_right_left_button
This commit is contained in:
Pfeil, Scott Robert 2019-02-14 16:20:01 -05:00
commit 8ec19228bf
3 changed files with 39 additions and 5 deletions

View File

@ -324,6 +324,19 @@
return [self.loadObject.pageJSON lenientBoolForKey:@"showRightPanel"];
}
- (BOOL)isOverridingRightButton {
NSDictionary *rightPanelLinkDict = [self.loadObject.pageJSON dict:@"rightPanelButtonLink"];
if (rightPanelLinkDict) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:rightPanelLinkDict
additionalData:nil
delegate:self];
return YES;
} else {
return NO;
}
}
- (void)setSupportShouldBeAccessible:(BOOL)supportShouldBeAccessible {
MVMCoreUISplitViewController *splitViewController = [MVMCoreUISession sharedGlobal].splitViewController;

View File

@ -24,6 +24,12 @@ NS_ASSUME_NONNULL_BEGIN
// Called when the back button is pressed. Overwrite for special functionality.
- (void)backButtonPressed;
// View Controller can override this method and do custom action instead of opening the right panel
- (BOOL)isOverridingRightButton;
// View Controller can override this method and do custom action instead of opening the left panel
- (BOOL)isOverridingLeftButton;
@end
NS_ASSUME_NONNULL_END

View File

@ -142,11 +142,18 @@ CGFloat const PanelAnimationDuration = 0.2;
- (IBAction)leftPanelButtonPressed:(id)sender {
[MVMCoreDispatchUtility performBlockOnMainThread:^{
UIViewController *viewController = self.navigationController.topViewController;
// If Viewcontroller confirms to protocol and implements the the method leftPanelButtonPressed
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
&& [viewController respondsToSelector:@selector(isOverridingLeftButton)]
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) isOverridingLeftButton]) {
return;
}
if (self.mainViewLeading.constant < .1) {
// Hide the keyboard
[self.navigationController.topViewController.view endEditing:YES];
[viewController.view endEditing:YES];
// Show
[self showLeftPanelAnimated:YES];
} else {
@ -169,10 +176,18 @@ CGFloat const PanelAnimationDuration = 0.2;
- (IBAction)rightPanelButtonPressed:(id)sender {
[MVMCoreDispatchUtility performBlockOnMainThread:^{
UIViewController *viewController = self.navigationController.topViewController;
// If Viewcontroller confirms to protocol and implements the the method rightPanelButtonPressed
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
&& [viewController respondsToSelector:@selector(isOverridingRightButton)]
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) isOverridingRightButton]) {
return;
}
if (self.mainViewTrailing.constant < .1) {
// Hide the keyboard
[self.navigationController.topViewController.view endEditing:YES];
[viewController.view endEditing:YES];
// Show
[self showRightPanelAnimated:YES];
} else {