react-native-navigation的迁移库

RNNSideMenuPresenter.m 3.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. }
  25. - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {
  26. [super mergeOptions:newOptions currentOptions:currentOptions defaultOptions:defaultOptions];
  27. RNNSideMenuController* sideMenuController = self.bindedViewController;
  28. if (newOptions.sideMenu.left.enabled.hasValue) {
  29. [sideMenuController side:MMDrawerSideLeft enabled:newOptions.sideMenu.left.enabled.get];
  30. [newOptions.sideMenu.left.enabled consume];
  31. }
  32. if (newOptions.sideMenu.right.enabled.hasValue) {
  33. [sideMenuController side:MMDrawerSideRight enabled:newOptions.sideMenu.right.enabled.get];
  34. [newOptions.sideMenu.right.enabled consume];
  35. }
  36. if (newOptions.sideMenu.left.visible.hasValue) {
  37. [sideMenuController side:MMDrawerSideLeft visible:newOptions.sideMenu.left.visible.get];
  38. [newOptions.sideMenu.left.visible consume];
  39. }
  40. if (newOptions.sideMenu.right.visible.hasValue) {
  41. [sideMenuController side:MMDrawerSideRight visible:newOptions.sideMenu.right.visible.get];
  42. [newOptions.sideMenu.right.visible consume];
  43. }
  44. if (newOptions.sideMenu.left.width.hasValue) {
  45. [sideMenuController side:MMDrawerSideLeft width:newOptions.sideMenu.left.width.get];
  46. }
  47. if (newOptions.sideMenu.right.width.hasValue) {
  48. [sideMenuController side:MMDrawerSideRight width:newOptions.sideMenu.right.width.get];
  49. }
  50. if (newOptions.sideMenu.left.shouldStretchDrawer.hasValue) {
  51. sideMenuController.shouldStretchLeftDrawer = newOptions.sideMenu.left.shouldStretchDrawer.get;
  52. }
  53. if (newOptions.sideMenu.right.shouldStretchDrawer.hasValue) {
  54. sideMenuController.shouldStretchRightDrawer = newOptions.sideMenu.right.shouldStretchDrawer.get;
  55. }
  56. if (newOptions.sideMenu.left.animationVelocity.hasValue) {
  57. sideMenuController.animationVelocityLeft = newOptions.sideMenu.left.animationVelocity.get;
  58. }
  59. if (newOptions.sideMenu.right.animationVelocity.hasValue) {
  60. sideMenuController.animationVelocityRight = newOptions.sideMenu.right.animationVelocity.get;
  61. }
  62. if (newOptions.sideMenu.animationType.hasValue) {
  63. [sideMenuController setAnimationType:newOptions.sideMenu.animationType.get];
  64. }
  65. }
  66. @end