react-native-navigation的迁移库

RNNSideMenuPresenter.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
  11. RNNSideMenuController* sideMenuController = self.boundViewController;
  12. [sideMenuController side:MMDrawerSideLeft enabled:[withDefault.sideMenu.left.enabled getWithDefaultValue:YES]];
  13. [sideMenuController side:MMDrawerSideRight enabled:[withDefault.sideMenu.right.enabled getWithDefaultValue:YES]];
  14. [sideMenuController setShouldStretchLeftDrawer:[withDefault.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]];
  15. [sideMenuController setShouldStretchRightDrawer:[withDefault.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]];
  16. [sideMenuController setAnimationVelocityLeft:[withDefault.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
  17. [sideMenuController setAnimationVelocityRight:[withDefault.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
  18. [sideMenuController setAnimationType:[withDefault.sideMenu.animationType getWithDefaultValue:nil]];
  19. if (withDefault.sideMenu.left.width.hasValue) {
  20. [sideMenuController side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get];
  21. }
  22. if (withDefault.sideMenu.right.width.hasValue) {
  23. [sideMenuController side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get];
  24. }
  25. if (withDefault.sideMenu.left.visible.hasValue) {
  26. [sideMenuController side:MMDrawerSideLeft visible:withDefault.sideMenu.left.visible.get];
  27. [withDefault.sideMenu.left.visible consume];
  28. }
  29. if (withDefault.sideMenu.right.visible.hasValue) {
  30. [sideMenuController side:MMDrawerSideRight visible:withDefault.sideMenu.right.visible.get];
  31. [withDefault.sideMenu.right.visible consume];
  32. }
  33. }
  34. - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
  35. [super applyOptionsOnInit:initialOptions];
  36. RNNNavigationOptions *withDefault = [initialOptions withDefault:[self defaultOptions]];
  37. RNNSideMenuController* sideMenuController = self.boundViewController;
  38. if (withDefault.sideMenu.left.width.hasValue) {
  39. [sideMenuController side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get];
  40. }
  41. if (withDefault.sideMenu.right.width.hasValue) {
  42. [sideMenuController side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get];
  43. }
  44. [sideMenuController setOpenDrawerGestureModeMask:[[withDefault.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]];
  45. }
  46. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions {
  47. [super mergeOptions:newOptions currentOptions:currentOptions];
  48. RNNSideMenuController* sideMenuController = self.boundViewController;
  49. if (newOptions.sideMenu.left.enabled.hasValue) {
  50. [sideMenuController side:MMDrawerSideLeft enabled:newOptions.sideMenu.left.enabled.get];
  51. }
  52. if (newOptions.sideMenu.right.enabled.hasValue) {
  53. [sideMenuController side:MMDrawerSideRight enabled:newOptions.sideMenu.right.enabled.get];
  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