react-native-navigation的迁移库

RNNSideMenuPresenter.m 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #import "RNNSideMenuPresenter.h"
  2. #import "RNNSideMenuController.h"
  3. @implementation RNNSideMenuPresenter
  4. -(instancetype)initWithDefaultOptions:(RNNNavigationOptions *)defaultOptions {
  5. self = [super initWithDefaultOptions:defaultOptions];
  6. return self;
  7. }
  8. - (void)applyOptions:(RNNNavigationOptions *)options {
  9. [super applyOptions:options];
  10. RNNSideMenuController* sideMenuController = self.boundViewController;
  11. [sideMenuController side:MMDrawerSideLeft enabled:[options.sideMenu.left.enabled getWithDefaultValue:YES]];
  12. [sideMenuController side:MMDrawerSideRight enabled:[options.sideMenu.right.enabled getWithDefaultValue:YES]];
  13. [sideMenuController setShouldStretchLeftDrawer:[options.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]];
  14. [sideMenuController setShouldStretchRightDrawer:[options.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]];
  15. [sideMenuController setAnimationVelocityLeft:[options.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
  16. [sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
  17. [sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
  18. if (options.sideMenu.left.width.hasValue) {
  19. [sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
  20. }
  21. if (options.sideMenu.right.width.hasValue) {
  22. [sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get];
  23. }
  24. if (options.sideMenu.left.visible.hasValue) {
  25. [sideMenuController side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get];
  26. [options.sideMenu.left.visible consume];
  27. }
  28. if (options.sideMenu.right.visible.hasValue) {
  29. [sideMenuController side:MMDrawerSideRight visible:options.sideMenu.right.visible.get];
  30. [options.sideMenu.right.visible consume];
  31. }
  32. }
  33. - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
  34. [super applyOptionsOnInit:initialOptions];
  35. RNNSideMenuController* sideMenuController = self.boundViewController;
  36. if (initialOptions.sideMenu.left.width.hasValue) {
  37. [sideMenuController side:MMDrawerSideLeft width:initialOptions.sideMenu.left.width.get];
  38. }
  39. if (initialOptions.sideMenu.right.width.hasValue) {
  40. [sideMenuController side:MMDrawerSideRight width:initialOptions.sideMenu.right.width.get];
  41. }
  42. [sideMenuController setOpenDrawerGestureModeMask:[[initialOptions.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]];
  43. }
  44. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions {
  45. [super mergeOptions:newOptions currentOptions:currentOptions];
  46. RNNSideMenuController* sideMenuController = self.boundViewController;
  47. if (newOptions.sideMenu.left.enabled.hasValue) {
  48. [sideMenuController side:MMDrawerSideLeft enabled:newOptions.sideMenu.left.enabled.get];
  49. [newOptions.sideMenu.left.enabled consume];
  50. }
  51. if (newOptions.sideMenu.right.enabled.hasValue) {
  52. [sideMenuController side:MMDrawerSideRight enabled:newOptions.sideMenu.right.enabled.get];
  53. [newOptions.sideMenu.right.enabled consume];
  54. }
  55. if (newOptions.sideMenu.left.visible.hasValue) {
  56. [sideMenuController side:MMDrawerSideLeft visible:newOptions.sideMenu.left.visible.get];
  57. [newOptions.sideMenu.left.visible consume];
  58. }
  59. if (newOptions.sideMenu.right.visible.hasValue) {
  60. [sideMenuController side:MMDrawerSideRight visible:newOptions.sideMenu.right.visible.get];
  61. [newOptions.sideMenu.right.visible consume];
  62. }
  63. if (newOptions.sideMenu.left.width.hasValue) {
  64. [sideMenuController side:MMDrawerSideLeft width:newOptions.sideMenu.left.width.get];
  65. }
  66. if (newOptions.sideMenu.right.width.hasValue) {
  67. [sideMenuController side:MMDrawerSideRight width:newOptions.sideMenu.right.width.get];
  68. }
  69. if (newOptions.sideMenu.left.shouldStretchDrawer.hasValue) {
  70. sideMenuController.shouldStretchLeftDrawer = newOptions.sideMenu.left.shouldStretchDrawer.get;
  71. }
  72. if (newOptions.sideMenu.right.shouldStretchDrawer.hasValue) {
  73. sideMenuController.shouldStretchRightDrawer = newOptions.sideMenu.right.shouldStretchDrawer.get;
  74. }
  75. if (newOptions.sideMenu.left.animationVelocity.hasValue) {
  76. sideMenuController.animationVelocityLeft = newOptions.sideMenu.left.animationVelocity.get;
  77. }
  78. if (newOptions.sideMenu.right.animationVelocity.hasValue) {
  79. sideMenuController.animationVelocityRight = newOptions.sideMenu.right.animationVelocity.get;
  80. }
  81. if (newOptions.sideMenu.animationType.hasValue) {
  82. [sideMenuController setAnimationType:newOptions.sideMenu.animationType.get];
  83. }
  84. }
  85. @end