react-native-navigation的迁移库

RNNSideMenuPresenter.m 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #import "RNNSideMenuPresenter.h"
  2. #import "RNNSideMenuController.h"
  3. @implementation RNNSideMenuPresenter
  4. - (void)applyOptions:(RNNNavigationOptions *)initialOptions {
  5. [super applyOptions:initialOptions];
  6. RNNNavigationOptions* options = [initialOptions withDefault:self.defaultOptions];
  7. RNNSideMenuController* sideMenuController = self.bindedViewController;
  8. [sideMenuController side:MMDrawerSideLeft enabled:[options.sideMenu.left.enabled getWithDefaultValue:YES]];
  9. [sideMenuController side:MMDrawerSideRight enabled:[options.sideMenu.right.enabled getWithDefaultValue:YES]];
  10. [sideMenuController setShouldStretchLeftDrawer:[options.sideMenu.left.shouldStretchDrawer getWithDefaultValue:YES]];
  11. [sideMenuController setShouldStretchRightDrawer:[options.sideMenu.right.shouldStretchDrawer getWithDefaultValue:YES]];
  12. [sideMenuController setAnimationVelocityLeft:[options.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
  13. [sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
  14. [sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
  15. if (options.sideMenu.left.width.hasValue) {
  16. [sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
  17. }
  18. if (options.sideMenu.right.width.hasValue) {
  19. [sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get];
  20. }
  21. }
  22. - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
  23. [super mergeOptions:options resolvedOptions:resolvedOptions];
  24. RNNSideMenuController* sideMenuController = self.bindedViewController;
  25. if (options.sideMenu.left.enabled.hasValue) {
  26. [sideMenuController side:MMDrawerSideLeft enabled:options.sideMenu.left.enabled.get];
  27. [options.sideMenu.left.enabled consume];
  28. }
  29. if (options.sideMenu.right.enabled.hasValue) {
  30. [sideMenuController side:MMDrawerSideRight enabled:options.sideMenu.right.enabled.get];
  31. [options.sideMenu.right.enabled consume];
  32. }
  33. if (options.sideMenu.left.visible.hasValue) {
  34. [sideMenuController side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get];
  35. [options.sideMenu.left.visible consume];
  36. }
  37. if (options.sideMenu.right.visible.hasValue) {
  38. [sideMenuController side:MMDrawerSideRight visible:options.sideMenu.right.visible.get];
  39. [options.sideMenu.right.visible consume];
  40. }
  41. if (options.sideMenu.left.width.hasValue) {
  42. [sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
  43. }
  44. if (options.sideMenu.right.width.hasValue) {
  45. [sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get];
  46. }
  47. if (options.sideMenu.left.shouldStretchDrawer.hasValue) {
  48. sideMenuController.shouldStretchLeftDrawer = options.sideMenu.left.shouldStretchDrawer.get;
  49. }
  50. if (options.sideMenu.right.shouldStretchDrawer.hasValue) {
  51. sideMenuController.shouldStretchRightDrawer = options.sideMenu.right.shouldStretchDrawer.get;
  52. }
  53. if (options.sideMenu.left.animationVelocity.hasValue) {
  54. sideMenuController.animationVelocityLeft = options.sideMenu.left.animationVelocity.get;
  55. }
  56. if (options.sideMenu.right.animationVelocity.hasValue) {
  57. sideMenuController.animationVelocityRight = options.sideMenu.right.animationVelocity.get;
  58. }
  59. if (options.sideMenu.animationType.hasValue) {
  60. [sideMenuController setAnimationType:options.sideMenu.animationType.get];
  61. }
  62. }
  63. @end