react-native-navigation的迁移库

RNNSideMenuPresenter.m 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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* sideMenu = self.boundViewController;
  12. [sideMenu side:MMDrawerSideLeft enabled:[withDefault.sideMenu.left.enabled getWithDefaultValue:YES]];
  13. [sideMenu side:MMDrawerSideRight enabled:[withDefault.sideMenu.right.enabled getWithDefaultValue:YES]];
  14. [sideMenu setShouldStretchLeftDrawer:[withDefault.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]];
  15. [sideMenu setShouldStretchRightDrawer:[withDefault.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]];
  16. [sideMenu setAnimationVelocityLeft:[withDefault.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
  17. [sideMenu setAnimationVelocityRight:[withDefault.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
  18. [sideMenu setAnimationType:[withDefault.sideMenu.animationType getWithDefaultValue:nil]];
  19. if (withDefault.sideMenu.left.width.hasValue) {
  20. [sideMenu side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get];
  21. }
  22. if (withDefault.sideMenu.right.width.hasValue) {
  23. [sideMenu side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get];
  24. }
  25. if (withDefault.sideMenu.left.visible.hasValue) {
  26. [sideMenu side:MMDrawerSideLeft visible:withDefault.sideMenu.left.visible.get];
  27. [withDefault.sideMenu.left.visible consume];
  28. }
  29. if (withDefault.sideMenu.right.visible.hasValue) {
  30. [sideMenu 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* sideMenu = self.boundViewController;
  38. if (withDefault.sideMenu.left.width.hasValue) {
  39. [sideMenu side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get];
  40. }
  41. if (withDefault.sideMenu.right.width.hasValue) {
  42. [sideMenu side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get];
  43. }
  44. [sideMenu setOpenDrawerGestureModeMask:[[withDefault.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]];
  45. }
  46. - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
  47. [super mergeOptions:options resolvedOptions:currentOptions];
  48. RNNSideMenuController* sideMenu = self.boundViewController;
  49. if (options.sideMenu.left.enabled.hasValue) {
  50. [sideMenu side:MMDrawerSideLeft enabled:options.sideMenu.left.enabled.get];
  51. }
  52. if (options.sideMenu.right.enabled.hasValue) {
  53. [sideMenu side:MMDrawerSideRight enabled:options.sideMenu.right.enabled.get];
  54. }
  55. if (options.sideMenu.left.visible.hasValue) {
  56. [sideMenu side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get];
  57. [options.sideMenu.left.visible consume];
  58. }
  59. if (options.sideMenu.right.visible.hasValue) {
  60. [sideMenu side:MMDrawerSideRight visible:options.sideMenu.right.visible.get];
  61. [options.sideMenu.right.visible consume];
  62. }
  63. if (options.sideMenu.left.width.hasValue) {
  64. [sideMenu side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
  65. }
  66. if (options.sideMenu.right.width.hasValue) {
  67. [sideMenu side:MMDrawerSideRight width:options.sideMenu.right.width.get];
  68. }
  69. if (options.sideMenu.left.shouldStretchDrawer.hasValue) {
  70. sideMenu.shouldStretchLeftDrawer = options.sideMenu.left.shouldStretchDrawer.get;
  71. }
  72. if (options.sideMenu.right.shouldStretchDrawer.hasValue) {
  73. sideMenu.shouldStretchRightDrawer = options.sideMenu.right.shouldStretchDrawer.get;
  74. }
  75. if (options.sideMenu.left.animationVelocity.hasValue) {
  76. sideMenu.animationVelocityLeft = options.sideMenu.left.animationVelocity.get;
  77. }
  78. if (options.sideMenu.right.animationVelocity.hasValue) {
  79. sideMenu.animationVelocityRight = options.sideMenu.right.animationVelocity.get;
  80. }
  81. if (options.sideMenu.animationType.hasValue) {
  82. [sideMenu setAnimationType:options.sideMenu.animationType.get];
  83. }
  84. }
  85. @end