react-native-navigation的迁移库

RNNSideMenuPresenter.m 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. [sideMenu.view setBackgroundColor:[withDefault.layout.backgroundColor getWithDefaultValue:nil]];
  34. }
  35. - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
  36. [super applyOptionsOnInit:initialOptions];
  37. RNNNavigationOptions *withDefault = [initialOptions withDefault:[self defaultOptions]];
  38. RNNSideMenuController* sideMenu = self.boundViewController;
  39. if (withDefault.sideMenu.left.width.hasValue) {
  40. [sideMenu side:MMDrawerSideLeft width:withDefault.sideMenu.left.width.get];
  41. }
  42. if (withDefault.sideMenu.right.width.hasValue) {
  43. [sideMenu side:MMDrawerSideRight width:withDefault.sideMenu.right.width.get];
  44. }
  45. [sideMenu setOpenDrawerGestureModeMask:[[withDefault.sideMenu.openGestureMode getWithDefaultValue:@(MMOpenDrawerGestureModeAll)] integerValue]];
  46. }
  47. - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)currentOptions {
  48. [super mergeOptions:options resolvedOptions:currentOptions];
  49. RNNSideMenuController* sideMenu = self.boundViewController;
  50. if (options.sideMenu.left.enabled.hasValue) {
  51. [sideMenu side:MMDrawerSideLeft enabled:options.sideMenu.left.enabled.get];
  52. }
  53. if (options.sideMenu.right.enabled.hasValue) {
  54. [sideMenu side:MMDrawerSideRight enabled:options.sideMenu.right.enabled.get];
  55. }
  56. if (options.sideMenu.left.visible.hasValue) {
  57. [sideMenu side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get];
  58. [options.sideMenu.left.visible consume];
  59. }
  60. if (options.sideMenu.right.visible.hasValue) {
  61. [sideMenu side:MMDrawerSideRight visible:options.sideMenu.right.visible.get];
  62. [options.sideMenu.right.visible consume];
  63. }
  64. if (options.sideMenu.left.width.hasValue) {
  65. [sideMenu side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
  66. }
  67. if (options.sideMenu.right.width.hasValue) {
  68. [sideMenu side:MMDrawerSideRight width:options.sideMenu.right.width.get];
  69. }
  70. if (options.sideMenu.left.shouldStretchDrawer.hasValue) {
  71. sideMenu.shouldStretchLeftDrawer = options.sideMenu.left.shouldStretchDrawer.get;
  72. }
  73. if (options.sideMenu.right.shouldStretchDrawer.hasValue) {
  74. sideMenu.shouldStretchRightDrawer = options.sideMenu.right.shouldStretchDrawer.get;
  75. }
  76. if (options.sideMenu.left.animationVelocity.hasValue) {
  77. sideMenu.animationVelocityLeft = options.sideMenu.left.animationVelocity.get;
  78. }
  79. if (options.sideMenu.right.animationVelocity.hasValue) {
  80. sideMenu.animationVelocityRight = options.sideMenu.right.animationVelocity.get;
  81. }
  82. if (options.sideMenu.animationType.hasValue) {
  83. [sideMenu setAnimationType:options.sideMenu.animationType.get];
  84. }
  85. if (options.layout.backgroundColor.hasValue) {
  86. [sideMenu.view setBackgroundColor:options.layout.backgroundColor.get];
  87. }
  88. }
  89. @end