react-native-navigation的迁移库

RNNSideMenuOptions.m 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #import "RNNSideMenuOptions.h"
  2. #import "RNNSideMenuController.h"
  3. @implementation RNNSideMenuOptions
  4. - (void)applyOn:(UIViewController *)viewController {
  5. RNNSideMenuController* sideMenuController = (RNNSideMenuController*)UIApplication.sharedApplication.delegate.window.rootViewController;
  6. if ([sideMenuController isKindOfClass:[RNNSideMenuController class]]) {
  7. if (self.leftSideVisible) {
  8. if (self.leftSideVisible.boolValue) {
  9. [sideMenuController showSideMenu:MMDrawerSideLeft animated:YES];
  10. } else {
  11. [sideMenuController hideSideMenu:MMDrawerSideLeft animated:YES];
  12. }
  13. }
  14. if (self.rightSideVisible) {
  15. if (self.rightSideVisible.boolValue) {
  16. [sideMenuController showSideMenu:MMDrawerSideRight animated:YES];
  17. } else {
  18. [sideMenuController hideSideMenu:MMDrawerSideRight animated:YES];
  19. }
  20. }
  21. if (self.leftSideEnabled) {
  22. sideMenuController.sideMenu.leftSideEnabled = [self.leftSideEnabled boolValue];
  23. }
  24. if (self.rightSideEnabled) {
  25. sideMenuController.sideMenu.rightSideEnabled = [self.rightSideEnabled boolValue];
  26. }
  27. [self resetOptions];
  28. }
  29. }
  30. -(void)mergeWith:(NSDictionary *)otherOptions {
  31. self.leftSideVisible = [[otherOptions valueForKey:@"left"] valueForKey:@"visible"];
  32. self.rightSideVisible = [[otherOptions valueForKey:@"right"] valueForKey:@"visible"];
  33. self.leftSideEnabled = [[otherOptions valueForKey:@"left"] valueForKey:@"enabled"];
  34. self.rightSideEnabled = [[otherOptions valueForKey:@"right"] valueForKey:@"enabled"];
  35. }
  36. -(void)resetOptions {
  37. self.leftSideVisible = nil;
  38. self.rightSideVisible = nil;
  39. self.leftSideEnabled = nil;
  40. self.rightSideEnabled = nil;
  41. }
  42. @end