react-native-navigation的迁移库

RNNCustomViewController.m 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #import "RNNCustomViewController.h"
  2. #import "RNNNativeViewController.h"
  3. @implementation RNNCustomViewController {
  4. NSString* _text;
  5. }
  6. - (instancetype)initWithProps:(NSDictionary *)props {
  7. self = [super init];
  8. _text = props[@"text"];
  9. return self;
  10. }
  11. - (void)viewDidLoad {
  12. [super viewDidLoad];
  13. [self addTestLabel];
  14. [self addDismissModalButton];
  15. [self addNavigationBarButtons];
  16. [self addPushButton];
  17. [[self view] setBackgroundColor:UIColor.whiteColor];
  18. }
  19. - (void)addDismissModalButton {
  20. UIButton* dismissModalButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.center.x - 70, 300, 140, 50)];
  21. dismissModalButton.backgroundColor = UIColor.systemBlueColor;
  22. dismissModalButton.accessibilityIdentifier = @"EXTERNAL_DISMISS_MODAL_BTN";
  23. [dismissModalButton setTitle:@"Dismiss modal" forState:UIControlStateNormal];
  24. [dismissModalButton addTarget:self action:@selector(dismissModal) forControlEvents:UIControlEventTouchDown];
  25. [self.view addSubview:dismissModalButton];
  26. }
  27. - (void)addPushButton {
  28. UIButton* pushNativeVCButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.center.x - 70, 370, 140, 50)];
  29. pushNativeVCButton.backgroundColor = UIColor.systemBlueColor;
  30. pushNativeVCButton.accessibilityIdentifier = @"PUSH_NATIVE_BTN";
  31. [pushNativeVCButton setTitle:@"Push Native VC" forState:UIControlStateNormal];
  32. [pushNativeVCButton addTarget:self action:@selector(pushNativeVC) forControlEvents:UIControlEventTouchDown];
  33. [self.view addSubview:pushNativeVCButton];
  34. }
  35. - (void)addTestLabel {
  36. UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
  37. label.textAlignment = NSTextAlignmentCenter;
  38. label.numberOfLines = 2;
  39. label.center = self.view.center;
  40. label.text = _text;
  41. label.accessibilityIdentifier = @"TestLabel";
  42. [self.view addSubview:label];
  43. }
  44. - (void)addNavigationBarButtons {
  45. UIBarButtonItem* rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Right button" style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonPressed)];
  46. rightButton.accessibilityIdentifier = @"EXTERNAL_TOP_BAR_RIGHT_BTN";
  47. self.navigationItem.rightBarButtonItem = rightButton;
  48. }
  49. - (void)dismissModal {
  50. [self dismissViewControllerAnimated:YES completion:nil];
  51. }
  52. - (void)pushNativeVC {
  53. RNNNativeViewController* nativeVC = [[RNNNativeViewController alloc] init];
  54. [self.navigationController pushViewController:nativeVC animated:NO];
  55. }
  56. - (void)rightButtonPressed {
  57. }
  58. @end