react-native-navigation的迁移库

RNNSideMenuPresenter.m 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #import "RNNSideMenuPresenter.h"
  2. #import "RNNSideMenuController.h"
  3. @implementation RNNSideMenuPresenter
  4. - (void)applyOptions:(RNNNavigationOptions *)options {
  5. [super applyOptions:options];
  6. RNNSideMenuController* sideMenuController = self.bindedViewController;
  7. [sideMenuController side:MMDrawerSideLeft enabled:[options.sideMenu.left.enabled getWithDefaultValue:YES]];
  8. [sideMenuController side:MMDrawerSideRight enabled:[options.sideMenu.right.enabled getWithDefaultValue:YES]];
  9. [sideMenuController setShouldStretchLeftDrawer:[options.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]];
  10. [sideMenuController setShouldStretchRightDrawer:[options.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]];
  11. [sideMenuController setAnimationVelocityLeft:[options.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
  12. [sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
  13. [sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
  14. if (options.sideMenu.left.width.hasValue) {
  15. [sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
  16. }
  17. if (options.sideMenu.right.width.hasValue) {
  18. [sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get];
  19. }
  20. }
  21. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  22. [super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions];
  23. RNNSideMenuController* sideMenuController = self.bindedViewController;
  24. if (newOptions.sideMenu.left.enabled.hasValue) {
  25. [sideMenuController side:MMDrawerSideLeft enabled:newOptions.sideMenu.left.enabled.get];
  26. [newOptions.sideMenu.left.enabled consume];
  27. }
  28. if (newOptions.sideMenu.right.enabled.hasValue) {
  29. [sideMenuController side:MMDrawerSideRight enabled:newOptions.sideMenu.right.enabled.get];
  30. [newOptions.sideMenu.right.enabled consume];
  31. }
  32. if (newOptions.sideMenu.left.visible.hasValue) {
  33. [sideMenuController side:MMDrawerSideLeft visible:newOptions.sideMenu.left.visible.get];
  34. [newOptions.sideMenu.left.visible consume];
  35. }
  36. if (newOptions.sideMenu.right.visible.hasValue) {
  37. [sideMenuController side:MMDrawerSideRight visible:newOptions.sideMenu.right.visible.get];
  38. [newOptions.sideMenu.right.visible consume];
  39. }
  40. if (newOptions.sideMenu.left.width.hasValue) {
  41. [sideMenuController side:MMDrawerSideLeft width:newOptions.sideMenu.left.width.get];
  42. }
  43. if (newOptions.sideMenu.right.width.hasValue) {
  44. [sideMenuController side:MMDrawerSideRight width:newOptions.sideMenu.right.width.get];
  45. }
  46. if (newOptions.sideMenu.left.shouldStretchDrawer.hasValue) {
  47. sideMenuController.shouldStretchLeftDrawer = newOptions.sideMenu.left.shouldStretchDrawer.get;
  48. }
  49. if (newOptions.sideMenu.right.shouldStretchDrawer.hasValue) {
  50. sideMenuController.shouldStretchRightDrawer = newOptions.sideMenu.right.shouldStretchDrawer.get;
  51. }
  52. if (newOptions.sideMenu.left.animationVelocity.hasValue) {
  53. sideMenuController.animationVelocityLeft = newOptions.sideMenu.left.animationVelocity.get;
  54. }
  55. if (newOptions.sideMenu.right.animationVelocity.hasValue) {
  56. sideMenuController.animationVelocityRight = newOptions.sideMenu.right.animationVelocity.get;
  57. }
  58. if (newOptions.sideMenu.animationType.hasValue) {
  59. [sideMenuController setAnimationType:newOptions.sideMenu.animationType.get];
  60. }
  61. }
  62. @end