react-native-navigation的迁移库

RCCTheSideBarManagerViewController.m 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. ////
  2. //// DarwerTheSideBarManagerViewController.m
  3. //// ReactNativeControllers
  4. ////
  5. //// Created by Ran Greenberg on 22/03/2016.
  6. //// Copyright © 2016 artal. All rights reserved.
  7. ////
  8. //
  9. //#import "RCCTheSideBarManagerViewController.h"
  10. //#import "RCCViewController.h"
  11. //#import "RCCDrawerHelper.h"
  12. //#import "RCTConvert.h"
  13. //
  14. //
  15. //@interface RCCTheSideBarManagerViewController () <TheSidebarControllerDelegate>
  16. //
  17. //@property (nonatomic) BOOL isOpen;
  18. //
  19. //@property (nonatomic) SidebarTransitionStyle animationStyle;
  20. //
  21. //@property (nonatomic, strong) RCCViewController *leftViewController;
  22. //@property (nonatomic, strong) RCCViewController *rightViewController;
  23. //@property (nonatomic, strong) RCCViewController *centerViewController;
  24. //
  25. //
  26. //@property (nonatomic, strong) UIColor *originalWindowBackgroundColor;
  27. //
  28. //@end
  29. //
  30. //@implementation RCCTheSideBarManagerViewController
  31. //
  32. //@synthesize overlayButton = _overlayButton, drawerStyle = _drawerStyle;
  33. //
  34. //
  35. //-(UIButton*)overlayButton {
  36. // if (!_overlayButton) {
  37. // _overlayButton = [RCCDrawerHelper createOverlayButton:self];
  38. // }
  39. // return _overlayButton;
  40. //}
  41. //
  42. //- (instancetype)initWithProps:(NSDictionary *)props children:(NSArray *)children globalProps:(NSDictionary*)globalProps bridge:(RCTBridge *)bridge {
  43. //
  44. // if ([children count] < 1) return nil;
  45. //
  46. // UIViewController *centerVC = [RCCViewController controllerWithLayout:children[0] globalProps:props bridge:bridge];
  47. // UIViewController *leftVC = nil;
  48. // UIViewController *rightVC = nil;
  49. //
  50. // // left
  51. // NSString *componentLeft = props[@"componentLeft"];
  52. // if (componentLeft) {
  53. // leftVC = [[RCCViewController alloc] initWithComponent:componentLeft passProps:props[@"passPropsLeft"] navigatorStyle:nil globalProps:props bridge:bridge];
  54. // }
  55. //
  56. // // right
  57. // NSString *componentRight = props[@"componentRight"];
  58. // if (componentRight) {
  59. // rightVC = [[RCCViewController alloc] initWithComponent:componentRight passProps:props[@"passPropsRight"] navigatorStyle:nil globalProps:props bridge:bridge];
  60. // }
  61. //
  62. // self = [super initWithContentViewController:centerVC
  63. // leftSidebarViewController:leftVC
  64. // rightSidebarViewController:rightVC];
  65. // if (!self) return nil;
  66. //
  67. // self.leftViewController = leftVC;
  68. // self.rightViewController = rightVC;
  69. // self.centerViewController = centerVC;
  70. // self.drawerStyle = props[@"style"];
  71. // self.delegate = self;
  72. // self.isOpen = NO;
  73. // [self setAnimationType:props[@"animationType"]];
  74. // [self setStyle];
  75. //
  76. // return self;
  77. //}
  78. //
  79. //
  80. //-(void)viewDidDisappear:(BOOL)animated {
  81. // [super viewDidDisappear:animated];
  82. //
  83. // UIWindow *appDelegateWindow = [[[UIApplication sharedApplication] delegate] window];
  84. // [appDelegateWindow setBackgroundColor:self.originalWindowBackgroundColor];
  85. //
  86. //}
  87. //
  88. //
  89. //-(void)setStyle:(TheSideBarSide)side {
  90. //
  91. // if(side == TheSideBarSideLeft && !self.leftViewController) return;
  92. // if(side == TheSideBarSideRight && !self.rightViewController) return;
  93. //
  94. // CGRect sideBarFrame = self.view.frame;
  95. //
  96. // switch (side) {
  97. // case TheSideBarSideLeft:
  98. // {
  99. // NSNumber *leftDrawerWidth = self.drawerStyle[@"leftDrawerWidth"];
  100. // if (!leftDrawerWidth) leftDrawerWidth = [NSNumber numberWithInteger:DRAWER_DEFAULT_WIDTH_PERCENTAGE];
  101. //
  102. // self.visibleWidth = self.view.bounds.size.width * MIN(1, (leftDrawerWidth.floatValue/100.0));
  103. // sideBarFrame.size.width = self.view.bounds.size.width * MIN(1, (leftDrawerWidth.floatValue/100.0));
  104. // self.leftViewController.view.frame = sideBarFrame;
  105. // }
  106. // break;
  107. //
  108. // case TheSideBarSideRight:
  109. // {
  110. // NSNumber *rightDrawerWidth = self.drawerStyle[@"rightDrawerWidth"];
  111. // if (!rightDrawerWidth) rightDrawerWidth = [NSNumber numberWithInteger:DRAWER_DEFAULT_WIDTH_PERCENTAGE];
  112. //
  113. // self.visibleWidth = self.view.bounds.size.width * MIN(1, (rightDrawerWidth.floatValue/100.0));
  114. // sideBarFrame.size.width = self.view.bounds.size.width * MIN(1, (rightDrawerWidth.floatValue/100.0));
  115. // sideBarFrame.origin.x = self.view.frame.size.width - self.visibleWidth;
  116. // self.rightViewController.view.frame = sideBarFrame;
  117. // }
  118. // break;
  119. //
  120. // default:
  121. // break;
  122. // }
  123. //}
  124. //
  125. //
  126. //-(void)setStyle {
  127. //
  128. // [self setStyle:TheSideBarSideLeft];
  129. // [self setStyle:TheSideBarSideRight];
  130. //
  131. // NSString *contentOverlayColor = self.drawerStyle[@"contentOverlayColor"];
  132. // if (contentOverlayColor)
  133. // {
  134. // UIColor *color = contentOverlayColor != (id)[NSNull null] ? [RCTConvert UIColor:contentOverlayColor] : nil;
  135. // self.overlayContentColor = color;
  136. // }
  137. //
  138. // UIImage *backgroundImage = nil;
  139. // id icon = self.drawerStyle[@"backgroundImage"];
  140. // UIWindow *appDelegateWindow = [[[UIApplication sharedApplication] delegate] window];
  141. // self.originalWindowBackgroundColor = appDelegateWindow.backgroundColor;
  142. //
  143. // if (icon)
  144. // {
  145. // backgroundImage = [RCTConvert UIImage:icon];
  146. // if (backgroundImage) {
  147. // backgroundImage = [RCCDrawerHelper imageWithImage:backgroundImage scaledToSize:appDelegateWindow.bounds.size];
  148. // [appDelegateWindow setBackgroundColor:[UIColor colorWithPatternImage:backgroundImage]];
  149. // }
  150. // }
  151. //}
  152. //
  153. //
  154. //-(void)setAnimationType:(NSString*)type {
  155. // if ([type isEqualToString:@"airbnb"]) self.animationStyle = SidebarTransitionStyleAirbnb;
  156. // else if ([type isEqualToString:@"facebook"]) self.animationStyle = SidebarTransitionStyleFacebook;
  157. // else if ([type isEqualToString:@"luvocracy"]) self.animationStyle = SidebarTransitionStyleLuvocracy;
  158. // else if ([type isEqualToString:@"wunder-list"]) self.animationStyle = SidebarTransitionStyleWunderlist;
  159. //
  160. // // currently unsuported animation types
  161. // // else if ([type isEqualToString:@"feedly"]) self.animationStyle = SidebarTransitionStyleFeedly;
  162. // // else if ([type isEqualToString:@"flipboard"]) self.animationStyle = SidebarTransitionStyleFlipboard;
  163. //
  164. //
  165. // // default
  166. // else self.animationStyle = SidebarTransitionStyleAirbnb;
  167. //}
  168. //
  169. //- (void)performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams bridge:(RCTBridge *)bridge {
  170. //
  171. // TheSideBarSide side = TheSideBarSideLeft;
  172. //
  173. // if ([actionParams[@"side"] isEqualToString:@"right"]) side = TheSideBarSideRight;
  174. //
  175. // // open
  176. // if ([performAction isEqualToString:@"open"])
  177. // {
  178. // [self openSideMenu:side];
  179. // return;
  180. // }
  181. //
  182. // // close
  183. // if ([performAction isEqualToString:@"close"])
  184. // {
  185. // [self overlayButtonPressed:self.overlayButton];
  186. // return;
  187. // }
  188. //
  189. // // toggle
  190. // if ([performAction isEqualToString:@"toggle"])
  191. // {
  192. // [self setStyle:side];
  193. // if (self.isOpen) {
  194. // [self overlayButtonPressed:self.overlayButton];
  195. // }
  196. // else {
  197. // [self openSideMenu:side];
  198. // }
  199. // self.isOpen = !self.isOpen;
  200. // return;
  201. // }
  202. //
  203. // // setStyle
  204. // if ([performAction isEqualToString:@"setStyle"])
  205. // {
  206. // if (actionParams[@"animationType"]) {
  207. // NSString *animationTypeString = actionParams[@"animationType"];
  208. //
  209. // CGRect leftSideBarFrame = self.leftViewController.view.frame;
  210. // leftSideBarFrame.origin.x = 0;
  211. // self.leftViewController.view.frame = leftSideBarFrame;
  212. //
  213. // CGRect rightSideBarFrame = self.rightViewController.view.frame;
  214. // rightSideBarFrame.origin.x = self.view.frame.size.width - self.visibleWidth;
  215. // self.rightViewController.view.frame = rightSideBarFrame;
  216. //
  217. // [self setAnimationType:animationTypeString];
  218. // }
  219. // return;
  220. // }
  221. //}
  222. //
  223. //
  224. //-(void)openSideMenu:(TheSideBarSide)side{
  225. //
  226. // RCCDrawerSide drawerSide;
  227. //
  228. // switch (side) {
  229. // case TheSideBarSideLeft:
  230. // {
  231. // [self presentLeftSidebarViewControllerWithStyle:self.animationStyle];
  232. // drawerSide = RCCDrawerSideLeft;
  233. // }
  234. //
  235. // break;
  236. // case TheSideBarSideRight:
  237. // {
  238. // [self presentRightSidebarViewControllerWithStyle:self.animationStyle];
  239. // drawerSide = RCCDrawerSideRight;
  240. // }
  241. //
  242. // break;
  243. //
  244. // default:
  245. // break;
  246. // }
  247. //
  248. // [RCCDrawerHelper addOverlayButtonToScreen:self.overlayButton contextView:self.view side:drawerSide sideMenuWidth:self.visibleWidth animationDuration:self.animationDuration];
  249. //}
  250. //
  251. //-(void)overlayButtonPressed:(UIButton*)button {
  252. // [self dismissSidebarViewController];
  253. // [RCCDrawerHelper overlayButtonPressed:button animationDuration:self.animationDuration];
  254. // self.isOpen = NO;
  255. //}
  256. //
  257. //
  258. //@end