react-native-navigation的迁移库

RNNSideMenuPresenter.m 3.8KB

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