react-native-navigation的迁移库

RNNSideMenuPresenter.m 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #import "RNNSideMenuPresenter.h"
  2. #import "RNNSideMenuController.h"
  3. @implementation RNNSideMenuPresenter
  4. - (void)applyOptions:(RNNNavigationOptions *)options {
  5. [super applyOptions:options];
  6. RNNSideMenuController* sideMenuController = self.boundViewController;
  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. if (options.sideMenu.left.visible.hasValue) {
  21. [sideMenuController side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get];
  22. [options.sideMenu.left.visible consume];
  23. }
  24. if (options.sideMenu.right.visible.hasValue) {
  25. [sideMenuController side:MMDrawerSideRight visible:options.sideMenu.right.visible.get];
  26. [options.sideMenu.right.visible consume];
  27. }
  28. }
  29. - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
  30. [super applyOptionsOnInit:initialOptions];
  31. RNNSideMenuController* sideMenuController = self.boundViewController;
  32. if (initialOptions.sideMenu.left.width.hasValue) {
  33. [sideMenuController side:MMDrawerSideLeft width:initialOptions.sideMenu.left.width.get];
  34. }
  35. if (initialOptions.sideMenu.right.width.hasValue) {
  36. [sideMenuController side:MMDrawerSideRight width:initialOptions.sideMenu.right.width.get];
  37. }
  38. [sideMenuController setOpenDrawerGestureModeMask:[[initialOptions.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]];
  39. }
  40. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  41. [super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions];
  42. RNNSideMenuController* sideMenuController = self.boundViewController;
  43. if (newOptions.sideMenu.left.enabled.hasValue) {
  44. [sideMenuController side:MMDrawerSideLeft enabled:newOptions.sideMenu.left.enabled.get];
  45. [newOptions.sideMenu.left.enabled consume];
  46. }
  47. if (newOptions.sideMenu.right.enabled.hasValue) {
  48. [sideMenuController side:MMDrawerSideRight enabled:newOptions.sideMenu.right.enabled.get];
  49. [newOptions.sideMenu.right.enabled consume];
  50. }
  51. if (newOptions.sideMenu.left.visible.hasValue) {
  52. [sideMenuController side:MMDrawerSideLeft visible:newOptions.sideMenu.left.visible.get];
  53. [newOptions.sideMenu.left.visible consume];
  54. }
  55. if (newOptions.sideMenu.right.visible.hasValue) {
  56. [sideMenuController side:MMDrawerSideRight visible:newOptions.sideMenu.right.visible.get];
  57. [newOptions.sideMenu.right.visible consume];
  58. }
  59. if (newOptions.sideMenu.left.width.hasValue) {
  60. [sideMenuController side:MMDrawerSideLeft width:newOptions.sideMenu.left.width.get];
  61. }
  62. if (newOptions.sideMenu.right.width.hasValue) {
  63. [sideMenuController side:MMDrawerSideRight width:newOptions.sideMenu.right.width.get];
  64. }
  65. if (newOptions.sideMenu.left.shouldStretchDrawer.hasValue) {
  66. sideMenuController.shouldStretchLeftDrawer = newOptions.sideMenu.left.shouldStretchDrawer.get;
  67. }
  68. if (newOptions.sideMenu.right.shouldStretchDrawer.hasValue) {
  69. sideMenuController.shouldStretchRightDrawer = newOptions.sideMenu.right.shouldStretchDrawer.get;
  70. }
  71. if (newOptions.sideMenu.left.animationVelocity.hasValue) {
  72. sideMenuController.animationVelocityLeft = newOptions.sideMenu.left.animationVelocity.get;
  73. }
  74. if (newOptions.sideMenu.right.animationVelocity.hasValue) {
  75. sideMenuController.animationVelocityRight = newOptions.sideMenu.right.animationVelocity.get;
  76. }
  77. if (newOptions.sideMenu.animationType.hasValue) {
  78. [sideMenuController setAnimationType:newOptions.sideMenu.animationType.get];
  79. }
  80. }
  81. @end