react-native-navigation 7.29.0 → 7.29.1-snapshot.730

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/ReactNativeNavigation.podspec +7 -7
  2. package/autolink/fixtures/rn68/AppDelegate.mm.template +108 -0
  3. package/autolink/fixtures/rn68/MainActivity.java.template +40 -0
  4. package/autolink/fixtures/rn69/AppDelegate.mm.template +133 -0
  5. package/autolink/fixtures/rn69/MainActivity.java.template +48 -0
  6. package/autolink/postlink/__snapshots__/activityLinker.test.js.snap +68 -0
  7. package/autolink/postlink/__snapshots__/appDelegateLinker.test.js.snap +241 -0
  8. package/autolink/postlink/activityLinker.js +14 -11
  9. package/autolink/postlink/appDelegateLinker.js +4 -0
  10. package/autolink/postlink/path.js +0 -2
  11. package/jest-setup.js +0 -3
  12. package/jest.config.js +2 -1
  13. package/lib/Mock/Components/NavigationButton.tsx +4 -2
  14. package/lib/android/app/build.gradle +3 -3
  15. package/lib/android/app/src/main/java/com/reactnativenavigation/options/TopBarOptions.java +8 -0
  16. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +10 -4
  17. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonController.kt +2 -0
  18. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt +5 -0
  19. package/lib/android/build.gradle +1 -0
  20. package/lib/dist/Mock/Components/NavigationButton.js +2 -1
  21. package/lib/dist/src/interfaces/Options.d.ts +2 -0
  22. package/lib/ios/RNNButtonOptions.h +3 -1
  23. package/lib/ios/RNNButtonOptions.m +7 -3
  24. package/lib/ios/RNNButtonsPresenter.h +6 -2
  25. package/lib/ios/RNNButtonsPresenter.m +16 -4
  26. package/lib/ios/RNNComponentPresenter.m +10 -2
  27. package/lib/ios/RNNIconDrawer.m +1 -1
  28. package/lib/ios/RNNTitleViewHelper.h +8 -0
  29. package/lib/ios/RNNTitleViewHelper.m +16 -0
  30. package/lib/ios/RNNTopBarOptions.h +2 -0
  31. package/lib/ios/RNNTopBarOptions.m +6 -0
  32. package/lib/ios/RNNUIBarButtonItem.h +2 -1
  33. package/lib/ios/RNNUIBarButtonItem.m +31 -8
  34. package/lib/ios/TopBarTitlePresenter.m +7 -0
  35. package/lib/src/interfaces/Options.ts +2 -0
  36. package/package.json +19 -19
  37. package/react-native.config.js +0 -3
@@ -69,19 +69,24 @@ class ActivityLinker {
69
69
  }
70
70
 
71
71
  _extendNavigationActivity(activityContent) {
72
+ if (this._hasAlreadyExtendNavigationActivity(activityContent)) {
73
+ warnn(' MainActivity already extends NavigationActivity');
74
+ return activityContent;
75
+ }
76
+
72
77
  if (this._doesActivityExtendReactActivity(activityContent)) {
73
78
  debugn(' Extending NavigationActivity');
74
79
  return activityContent
75
80
  .replace(/extends\s+ReactActivity\s*/, 'extends NavigationActivity ')
81
+ .replace(
82
+ /public\s+MainActivityDelegate\s*\(\s*ReactActivity\s+activity,\s*String\s+mainComponentName\s*\)/,
83
+ 'public MainActivityDelegate(NavigationActivity activity, String mainComponentName)'
84
+ )
76
85
  .replace(
77
86
  'import com.facebook.react.ReactActivity;',
78
87
  'import com.reactnativenavigation.NavigationActivity;'
79
88
  );
80
89
  }
81
- if (this._hasAlreadyExtendReactActivity(activityContent)) {
82
- warnn(' MainActivity already extends NavigationActivity');
83
- return activityContent;
84
- }
85
90
 
86
91
  throw new Error(
87
92
  'MainActivity was not successfully replaced. Please check the documentation and proceed manually.'
@@ -92,8 +97,8 @@ class ActivityLinker {
92
97
  return /public\s+class\s+MainActivity\s+extends\s+ReactActivity\s*/.test(activityContent);
93
98
  }
94
99
 
95
- _hasAlreadyExtendReactActivity(activityContent) {
96
- return /public\s+class\s+MainActivity\s+extends\s+ReactActivity\s*/.test(activityContent);
100
+ _hasAlreadyExtendNavigationActivity(activityContent) {
101
+ return /public\s+class\s+MainActivity\s+extends\s+NavigationActivity\s*/.test(activityContent);
97
102
  }
98
103
 
99
104
  _removeCreateReactActivityDelegate(activityContent) {
@@ -101,19 +106,17 @@ class ActivityLinker {
101
106
  debugn(' Removing createReactActivityDelegate function');
102
107
  return activityContent.replace(
103
108
  /\/\*\*(\s+\*.+)+\s+@Override\s+protected ReactActivityDelegate createReactActivityDelegate\(\) {(\s*[\w*(,);])*\s*}/,
104
- '',
109
+ ''
105
110
  );
106
111
  } else {
107
- warnn(
108
- ' createReactActivityDelegate is already not defined in MainActivity',
109
- );
112
+ warnn(' createReactActivityDelegate is already not defined in MainActivity');
110
113
  return activityContent;
111
114
  }
112
115
  }
113
116
 
114
117
  _hasCreateReactActivityDelegate(activityContent) {
115
118
  return /\/\*\*(\s+\*.+)+\s+@Override\s+protected ReactActivityDelegate createReactActivityDelegate\(\) {(\s*[\w*(,);])*\s*}/.test(
116
- activityContent,
119
+ activityContent
117
120
  );
118
121
  }
119
122
  }
@@ -153,7 +153,11 @@ class AppDelegateLinker {
153
153
  /rootViewController\.view\s+=\s+rootView;\s+/,
154
154
  /self.window.rootViewController\s+=\s+rootViewController;\s+/,
155
155
  /\[self.window\s+makeKeyAndVisible];\s+/,
156
+ // Added from RN 0.69
157
+ /NSDictionary\s+\*initProps\s+=\s+\[self prepareInitialProps];\s+/,
158
+ /UIView \*rootView = RCTAppSetupDefaultRootView\(bridge, @".*", initProps\);/,
156
159
  ];
160
+
157
161
  let elementsRemovedCount = 0;
158
162
 
159
163
  toRemove.forEach((element) => {
@@ -3,8 +3,6 @@ var ignoreFolders = {
3
3
  ignore: ['node_modules/**', '**/build/**', '**/Build/**', '**/DerivedData/**', '**/*-tvOS*/**'],
4
4
  };
5
5
 
6
- var manifestPath = glob.sync('**/AndroidManifest.xml', ignoreFolders)[0];
7
-
8
6
  exports.mainActivityJava = glob.sync('**/MainActivity.java', ignoreFolders)[0];
9
7
  exports.mainActivityKotlin = glob.sync('**/MainActivity.kt', ignoreFolders)[0];
10
8
  var mainApplicationJava = glob.sync('**/MainApplication.java', ignoreFolders)[0];
package/jest-setup.js CHANGED
@@ -4,9 +4,6 @@ mockDetox(() => require('./playground/index'));
4
4
 
5
5
  beforeEach(() => {
6
6
  const { mockNativeComponents } = require('react-native-navigation/Mock');
7
- setTimeout = (func) => {
8
- func();
9
- };
10
7
  mockNativeComponents();
11
8
  mockUILib();
12
9
  });
package/jest.config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  preset: 'react-native',
3
3
  transformIgnorePatterns: [
4
- 'node_modules/(?!(@react-native|react-native|react-native-ui-lib|react-native-animatable)/)',
4
+ 'node_modules/(?!(@react-native|react-native|react-native-ui-lib|react-native-animatable|react-native-reanimated)/)',
5
5
  ],
6
6
  transform: {
7
7
  '\\.[jt]sx?$': 'babel-jest',
@@ -12,6 +12,7 @@ module.exports = {
12
12
  '<rootDir>/integration/',
13
13
  '<rootDir>/scripts/',
14
14
  '<rootDir>/e2e/',
15
+ '<rootDir>/autolink/',
15
16
  ],
16
17
  setupFilesAfterEnv: ['./jest-setup.js'],
17
18
  testPathIgnorePatterns: ['/node_modules/'],
@@ -45,8 +45,10 @@ export const NavigationButton = class extends Component<ButtonProps> {
45
45
  <TouchableOpacity
46
46
  onPress={() => {
47
47
  if (this.ref) {
48
- // @ts-ignore
49
- this.invokeOnClick(this.ref!._reactInternalFiber.return.stateNode);
48
+ this.invokeOnClick(
49
+ // @ts-ignore
50
+ (this.ref!._reactInternalFiber || this.ref!._reactInternals).return.stateNode
51
+ );
50
52
  }
51
53
 
52
54
  events.invokeNavigationButtonPressed({
@@ -65,11 +65,11 @@ android {
65
65
  }
66
66
  }
67
67
  compileOptions {
68
- sourceCompatibility JavaVersion.VERSION_1_8
69
- targetCompatibility JavaVersion.VERSION_1_8
68
+ sourceCompatibility JavaVersion.VERSION_11
69
+ targetCompatibility JavaVersion.VERSION_11
70
70
  }
71
71
  kotlinOptions {
72
- jvmTarget = JavaVersion.VERSION_1_8
72
+ jvmTarget = JavaVersion.VERSION_11
73
73
  }
74
74
 
75
75
  flavorDimensions "RNN.reactNativeVersion"
@@ -50,6 +50,8 @@ public class TopBarOptions {
50
50
  options.leftButtonColor = ThemeColour.parse(context, json.optJSONObject("leftButtonColor"));
51
51
  options.leftButtonDisabledColor = ThemeColour.parse(context, json.optJSONObject("leftButtonDisabledColor"));
52
52
  options.rightButtonDisabledColor = ThemeColour.parse(context, json.optJSONObject("rightButtonDisabledColor"));
53
+ options.leftButtonBackgroundColor = ThemeColour.parse(context, json.optJSONObject("leftButtonBackgroundColor"));
54
+ options.rightButtonBackgroundColor = ThemeColour.parse(context, json.optJSONObject("rightButtonBackgroundColor"));
53
55
 
54
56
  options.validate();
55
57
  return options;
@@ -76,6 +78,8 @@ public class TopBarOptions {
76
78
  public ThemeColour leftButtonColor = new NullThemeColour();
77
79
  public ThemeColour rightButtonDisabledColor = new NullThemeColour();
78
80
  public ThemeColour leftButtonDisabledColor = new NullThemeColour();
81
+ public ThemeColour rightButtonBackgroundColor = new NullThemeColour();
82
+ public ThemeColour leftButtonBackgroundColor = new NullThemeColour();
79
83
 
80
84
  public TopBarOptions copy() {
81
85
  TopBarOptions result = new TopBarOptions();
@@ -94,6 +98,8 @@ public class TopBarOptions {
94
98
  if (other.leftButtonColor.hasValue()) leftButtonColor = other.leftButtonColor;
95
99
  if (other.rightButtonDisabledColor.hasValue()) rightButtonDisabledColor = other.rightButtonDisabledColor;
96
100
  if (other.leftButtonDisabledColor.hasValue()) leftButtonDisabledColor = other.leftButtonDisabledColor;
101
+ if (other.rightButtonBackgroundColor.hasValue()) rightButtonBackgroundColor = other.rightButtonBackgroundColor;
102
+ if (other.leftButtonBackgroundColor.hasValue()) rightButtonBackgroundColor = other.rightButtonBackgroundColor;
97
103
 
98
104
  if (other.testId.hasValue()) testId = other.testId;
99
105
  if (other.visible.hasValue()) visible = other.visible;
@@ -122,6 +128,8 @@ public class TopBarOptions {
122
128
  if (!leftButtonColor.hasValue()) leftButtonColor = defaultOptions.leftButtonColor;
123
129
  if (!rightButtonDisabledColor.hasValue()) rightButtonDisabledColor = defaultOptions.rightButtonDisabledColor;
124
130
  if (!leftButtonDisabledColor.hasValue()) leftButtonDisabledColor = defaultOptions.leftButtonDisabledColor;
131
+ if (!rightButtonBackgroundColor.hasValue()) rightButtonBackgroundColor = defaultOptions.rightButtonBackgroundColor;
132
+ if (!leftButtonBackgroundColor.hasValue()) rightButtonBackgroundColor = defaultOptions.rightButtonBackgroundColor;
125
133
 
126
134
  if (!visible.hasValue()) visible = defaultOptions.visible;
127
135
  if (!animate.hasValue()) animate = defaultOptions.animate;
@@ -458,12 +458,12 @@ public class StackPresenter {
458
458
  private void mergeButtons(TopBarOptions options, TopBarOptions optionsToMerge, View child, StackController stack) {
459
459
  mergeRightButtons(options, optionsToMerge.buttons, child);
460
460
  mergeLeftButton(options, optionsToMerge.buttons, child);
461
- mergeLeftButtonsColor(child, optionsToMerge.leftButtonColor, optionsToMerge.leftButtonDisabledColor);
462
- mergeRightButtonsColor(child, optionsToMerge.rightButtonColor, optionsToMerge.rightButtonDisabledColor);
461
+ mergeLeftButtonsColor(child, optionsToMerge.leftButtonColor, optionsToMerge.leftButtonDisabledColor, optionsToMerge.leftButtonBackgroundColor);
462
+ mergeRightButtonsColor(child, optionsToMerge.rightButtonColor, optionsToMerge.rightButtonDisabledColor, optionsToMerge.rightButtonBackgroundColor);
463
463
  mergeBackButton(optionsToMerge.buttons, stack);
464
464
  }
465
465
 
466
- private void mergeLeftButtonsColor(View child, ThemeColour color, ThemeColour disabledColor) {
466
+ private void mergeLeftButtonsColor(View child, ThemeColour color, ThemeColour disabledColor, ThemeColour backgroundColor) {
467
467
  if (color.hasValue() || disabledColor.hasValue()) {
468
468
  Map<String, ButtonController> stringButtonControllerMap = componentLeftButtons.get(child);
469
469
  if (stringButtonControllerMap != null) {
@@ -474,12 +474,15 @@ public class StackPresenter {
474
474
  if (disabledColor.hasValue()) {
475
475
  btnController.applyDisabledColor(topBarController.getView().getLeftButtonBar(), disabledColor);
476
476
  }
477
+ if (backgroundColor.hasValue()) {
478
+ btnController.applyBackgroundColor(topBarController.getView().getLeftButtonBar(), backgroundColor);
479
+ }
477
480
  });
478
481
  }
479
482
  }
480
483
  }
481
484
 
482
- private void mergeRightButtonsColor(View child, ThemeColour color, ThemeColour disabledColor) {
485
+ private void mergeRightButtonsColor(View child, ThemeColour color, ThemeColour disabledColor, ThemeColour backgroundColor) {
483
486
  if (color.hasValue() || disabledColor.hasValue()) {
484
487
  Map<String, ButtonController> stringButtonControllerMap = componentRightButtons.get(child);
485
488
  if (stringButtonControllerMap != null) {
@@ -490,6 +493,9 @@ public class StackPresenter {
490
493
  if (disabledColor.hasValue()) {
491
494
  btnController.applyDisabledColor(topBarController.getView().getRightButtonBar(), disabledColor);
492
495
  }
496
+ if (backgroundColor.hasValue()) {
497
+ btnController.applyBackgroundColor(topBarController.getView().getRightButtonBar(), backgroundColor);
498
+ }
493
499
  });
494
500
  }
495
501
  }
@@ -81,6 +81,8 @@ open class ButtonController(activity: Activity,
81
81
 
82
82
  open fun applyDisabledColor(toolbar: Toolbar, disabledColour: ThemeColour) = this.menuItem?.let { presenter.applyDisabledColor(toolbar, it, disabledColour) }
83
83
 
84
+ open fun applyBackgroundColor(toolbar: Toolbar, color: ThemeColour) = this.menuItem?.let { presenter.applyBackgroundColor(toolbar, it, color) }
85
+
84
86
  fun addToMenu(buttonBar: ButtonBar, order: Int) {
85
87
  if (button.component.hasValue() && buttonBar.containsButton(menuItem, order)) return
86
88
  buttonBar.menu.removeItem(button.intId)
@@ -71,6 +71,11 @@ open class ButtonPresenter(private val context: Context, private val button: But
71
71
  }
72
72
  }
73
73
 
74
+ fun applyBackgroundColor(toolbar: Toolbar, menuItem: MenuItem, color: ThemeColour) {
75
+ button.iconBackground.color = color
76
+ applyIcon(menuItem)
77
+ }
78
+
74
79
  private fun applyAccessibilityLabel(menuItem: MenuItem) {
75
80
  if (button.accessibilityLabel.hasValue()) {
76
81
  if (button.component.hasValue()) {
@@ -3,6 +3,7 @@
3
3
  buildscript {
4
4
  ext {
5
5
  RNNKotlinVersion = '1.4.31'
6
+ appCompatVersion = '1.6.0-alpha05'
6
7
  }
7
8
 
8
9
  repositories {
@@ -31,8 +31,9 @@ const NavigationButton = class extends react_1.Component {
31
31
  const props = react_native_navigation_1.Navigation.mock.store.getPropsForId(buttonComponentId);
32
32
  return (react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => {
33
33
  if (this.ref) {
34
+ this.invokeOnClick(
34
35
  // @ts-ignore
35
- this.invokeOnClick(this.ref._reactInternalFiber.return.stateNode);
36
+ (this.ref._reactInternalFiber || this.ref._reactInternals).return.stateNode);
36
37
  }
37
38
  EventsStore_1.events.invokeNavigationButtonPressed({
38
39
  buttonId: button.id,
@@ -568,6 +568,8 @@ export interface OptionsTopBar {
568
568
  */
569
569
  leftButtonColor?: Color;
570
570
  rightButtonColor?: Color;
571
+ leftButtonBackgroundColor?: Color;
572
+ rightButtonBackgroundColor?: Color;
571
573
  leftButtonDisabledColor?: Color;
572
574
  rightButtonDisabledColor?: Color;
573
575
  /**
@@ -25,7 +25,7 @@
25
25
 
26
26
  - (RNNButtonOptions *)withDefault:(RNNButtonOptions *)defaultOptions;
27
27
 
28
- - (UIColor *)resolveColor;
28
+ - (Color *)resolveColor;
29
29
 
30
30
  - (RNNButtonOptions *)withDefaultColor:(Color *)color disabledColor:(Color *)disabledColor;
31
31
 
@@ -33,4 +33,6 @@
33
33
 
34
34
  - (BOOL)isEnabled;
35
35
 
36
+ - (UIControlState)state;
37
+
36
38
  @end
@@ -93,11 +93,11 @@
93
93
  return [self.enabled withDefault:YES];
94
94
  }
95
95
 
96
- - (UIColor *)resolveColor {
96
+ - (Color *)resolveColor {
97
97
  if (![_enabled withDefault:YES] && _disabledColor.hasValue)
98
- return _disabledColor.get;
98
+ return _disabledColor;
99
99
  else
100
- return [_color withDefault:nil];
100
+ return _color;
101
101
  }
102
102
 
103
103
  - (RNNButtonOptions *)withDefault:(RNNButtonOptions *)defaultOptions {
@@ -116,4 +116,8 @@
116
116
  return self;
117
117
  }
118
118
 
119
+ - (UIControlState)state {
120
+ return self.isEnabled ? UIControlStateNormal : UIControlStateDisabled;
121
+ }
122
+
119
123
  @end
@@ -20,9 +20,13 @@
20
20
  defaultDisabledColor:(Color *)defaultDisabledColor
21
21
  animated:(BOOL)animated;
22
22
 
23
- - (void)applyLeftButtonsColor:(UIColor *)color;
23
+ - (void)applyLeftButtonsColor:(Color *)color;
24
24
 
25
- - (void)applyRightButtonsColor:(UIColor *)color;
25
+ - (void)applyRightButtonsColor:(Color *)color;
26
+
27
+ - (void)applyLeftButtonsBackgroundColor:(Color *)color;
28
+
29
+ - (void)applyRightButtonsBackgroundColor:(Color *)color;
26
30
 
27
31
  - (void)componentWillAppear;
28
32
 
@@ -47,15 +47,27 @@
47
47
  defaultDisabledColor:defaultDisabledColor];
48
48
  }
49
49
 
50
- - (void)applyLeftButtonsColor:(UIColor *)color {
50
+ - (void)applyLeftButtonsColor:(Color *)color {
51
51
  for (RNNUIBarButtonItem *button in self.viewController.navigationItem.leftBarButtonItems) {
52
- [button applyColor:color];
52
+ [button mergeColor:color];
53
53
  }
54
54
  }
55
55
 
56
- - (void)applyRightButtonsColor:(UIColor *)color {
56
+ - (void)applyRightButtonsColor:(Color *)color {
57
57
  for (RNNUIBarButtonItem *button in self.viewController.navigationItem.rightBarButtonItems) {
58
- [button applyColor:color];
58
+ [button mergeColor:color];
59
+ }
60
+ }
61
+
62
+ - (void)applyRightButtonsBackgroundColor:(Color *)color {
63
+ for (RNNUIBarButtonItem *button in self.viewController.navigationItem.rightBarButtonItems) {
64
+ [button mergeBackgroundColor:color];
65
+ }
66
+ }
67
+
68
+ - (void)applyLeftButtonsBackgroundColor:(Color *)color {
69
+ for (RNNUIBarButtonItem *button in self.viewController.navigationItem.leftBarButtonItems) {
70
+ [button mergeBackgroundColor:color];
59
71
  }
60
72
  }
61
73
 
@@ -209,11 +209,19 @@
209
209
  }
210
210
 
211
211
  if (mergeOptions.topBar.leftButtonColor.hasValue) {
212
- [_buttonsPresenter applyLeftButtonsColor:mergeOptions.topBar.leftButtonColor.get];
212
+ [_buttonsPresenter applyLeftButtonsColor:mergeOptions.topBar.leftButtonColor];
213
213
  }
214
214
 
215
215
  if (mergeOptions.topBar.rightButtonColor.hasValue) {
216
- [_buttonsPresenter applyRightButtonsColor:mergeOptions.topBar.rightButtonColor.get];
216
+ [_buttonsPresenter applyRightButtonsColor:mergeOptions.topBar.rightButtonColor];
217
+ }
218
+
219
+ if (mergeOptions.topBar.rightButtonBackgroundColor.hasValue) {
220
+ [_buttonsPresenter applyRightButtonsBackgroundColor:mergeOptions.topBar.rightButtonBackgroundColor];
221
+ }
222
+
223
+ if (mergeOptions.topBar.leftButtonBackgroundColor.hasValue) {
224
+ [_buttonsPresenter applyLeftButtonsBackgroundColor:mergeOptions.topBar.leftButtonBackgroundColor];
217
225
  }
218
226
 
219
227
  if (mergeOptions.overlay.interceptTouchOutside.hasValue) {
@@ -29,7 +29,7 @@
29
29
  UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
30
30
  UIGraphicsEndImageContext();
31
31
 
32
- return [newImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
32
+ return newImage;
33
33
  }
34
34
 
35
35
  @end
@@ -8,6 +8,10 @@
8
8
 
9
9
  @property(nonatomic, strong) UILabel *subtitleLabel;
10
10
 
11
+ - (void)setTitleColor:(UIColor *)color;
12
+
13
+ - (void)setSubtitleColor:(UIColor *)color;
14
+
11
15
  @end
12
16
 
13
17
  @interface RNNTitleViewHelper : NSObject
@@ -21,4 +25,8 @@
21
25
 
22
26
  - (void)setup;
23
27
 
28
+ - (void)setTitleColor:(UIColor *)color;
29
+
30
+ - (void)setSubtitleColor:(UIColor *)color;
31
+
24
32
  @end
@@ -16,6 +16,14 @@
16
16
  self.frame.size.width, _subtitleLabel.frame.size.height)];
17
17
  }
18
18
 
19
+ - (void)setTitleColor:(UIColor *)color {
20
+ _titleLabel.textColor = color;
21
+ }
22
+
23
+ - (void)setSubtitleColor:(UIColor *)color {
24
+ _subtitleLabel.textColor = color;
25
+ }
26
+
19
27
  @end
20
28
 
21
29
  @interface RNNTitleViewHelper ()
@@ -170,4 +178,12 @@
170
178
  return titleLabel;
171
179
  }
172
180
 
181
+ - (void)setTitleColor:(UIColor *)color {
182
+ [_titleView setTitleColor:color];
183
+ }
184
+
185
+ - (void)setSubtitleColor:(UIColor *)color {
186
+ [_titleView setSubtitleColor:color];
187
+ }
188
+
173
189
  @end
@@ -20,6 +20,8 @@
20
20
  @property(nonatomic, strong) Color *rightButtonColor;
21
21
  @property(nonatomic, strong) Color *leftButtonDisabledColor;
22
22
  @property(nonatomic, strong) Color *rightButtonDisabledColor;
23
+ @property(nonatomic, strong) Color *leftButtonBackgroundColor;
24
+ @property(nonatomic, strong) Color *rightButtonBackgroundColor;
23
25
  @property(nonatomic, strong) Bool *drawBehind;
24
26
  @property(nonatomic, strong) Bool *noBorder;
25
27
  @property(nonatomic, strong) Color *borderColor;
@@ -14,6 +14,8 @@
14
14
  self.rightButtonColor = [ColorParser parse:dict key:@"rightButtonColor"];
15
15
  self.leftButtonDisabledColor = [ColorParser parse:dict key:@"leftButtonDisabledColor"];
16
16
  self.rightButtonDisabledColor = [ColorParser parse:dict key:@"rightButtonDisabledColor"];
17
+ self.leftButtonBackgroundColor = [ColorParser parse:dict key:@"leftButtonBackgroundColor"];
18
+ self.rightButtonBackgroundColor = [ColorParser parse:dict key:@"rightButtonBackgroundColor"];
17
19
  self.drawBehind = [BoolParser parse:dict key:@"drawBehind"];
18
20
  self.noBorder = [BoolParser parse:dict key:@"noBorder"];
19
21
  self.borderColor = [ColorParser parse:dict key:@"borderColor"];
@@ -63,6 +65,10 @@
63
65
  self.leftButtonDisabledColor = options.leftButtonDisabledColor;
64
66
  if (options.rightButtonDisabledColor.hasValue)
65
67
  self.rightButtonDisabledColor = options.rightButtonDisabledColor;
68
+ if (options.leftButtonBackgroundColor.hasValue)
69
+ self.leftButtonBackgroundColor = options.leftButtonBackgroundColor;
70
+ if (options.rightButtonBackgroundColor.hasValue)
71
+ self.rightButtonBackgroundColor = options.rightButtonBackgroundColor;
66
72
  if (options.drawBehind.hasValue)
67
73
  self.drawBehind = options.drawBehind;
68
74
  if (options.noBorder.hasValue)
@@ -26,7 +26,8 @@ typedef void (^RNNButtonPressCallback)(NSString *buttonId);
26
26
  - (instancetype)initWithSystemItem:(RNNButtonOptions *)buttonOptions
27
27
  onPress:(RNNButtonPressCallback)onPress;
28
28
 
29
- - (void)applyColor:(UIColor *)color;
29
+ - (void)mergeColor:(Color *)color;
30
+ - (void)mergeBackgroundColor:(Color *)color;
30
31
 
31
32
  - (void)notifyWillAppear;
32
33
  - (void)notifyDidAppear;
@@ -11,7 +11,10 @@
11
11
 
12
12
  @end
13
13
 
14
- @implementation RNNUIBarButtonItem
14
+ @implementation RNNUIBarButtonItem {
15
+ RNNIconCreator* _iconCreator;
16
+ RNNButtonOptions* _buttonOptions;
17
+ }
15
18
 
16
19
  - (instancetype)init {
17
20
  self = [super init];
@@ -52,16 +55,17 @@
52
55
  - (instancetype)initCustomIcon:(RNNButtonOptions *)buttonOptions
53
56
  iconCreator:(RNNIconCreator *)iconCreator
54
57
  onPress:(RNNButtonPressCallback)onPress {
55
- UIImage *icon = [iconCreator create:buttonOptions];
58
+ _iconCreator = iconCreator;
59
+ UIImage *icon = [_iconCreator create:buttonOptions];
56
60
  UIButton *button =
57
61
  [[UIButton alloc] initWithFrame:CGRectMake(0, 0, icon.size.width, icon.size.height)];
58
-
59
62
  [button addTarget:self
60
63
  action:@selector(onButtonPressed:)
61
64
  forControlEvents:UIControlEventTouchUpInside];
62
65
  [button setImage:icon
63
66
  forState:buttonOptions.isEnabled ? UIControlStateNormal : UIControlStateDisabled];
64
-
67
+ [button.widthAnchor constraintEqualToConstant:icon.size.width].active = YES;
68
+ [button.heightAnchor constraintEqualToConstant:icon.size.height].active = YES;
65
69
  self = [super initWithCustomView:button];
66
70
  [self applyOptions:buttonOptions];
67
71
  self.onPress = onPress;
@@ -125,6 +129,7 @@
125
129
  }
126
130
 
127
131
  - (void)applyOptions:(RNNButtonOptions *)buttonOptions {
132
+ _buttonOptions = buttonOptions;
128
133
  self.buttonId = buttonOptions.identifier.get;
129
134
  self.accessibilityLabel = [buttonOptions.accessibilityLabel withDefault:nil];
130
135
  self.enabled = [buttonOptions.enabled withDefault:YES];
@@ -134,17 +139,35 @@
134
139
  [self applyDisabledTitleTextAttributes:buttonOptions];
135
140
  }
136
141
 
137
- - (void)applyColor:(UIColor *)color {
138
- if (color) {
142
+ - (void)applyColor:(Color *)color {
143
+ if (color.hasValue) {
139
144
  NSMutableDictionary *titleTextAttributes = [NSMutableDictionary
140
145
  dictionaryWithDictionary:[self titleTextAttributesForState:UIControlStateNormal]];
141
- [titleTextAttributes setValue:color forKey:NSForegroundColorAttributeName];
146
+ [titleTextAttributes setValue:color.get forKey:NSForegroundColorAttributeName];
142
147
  [self setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
143
148
  [self setTitleTextAttributes:titleTextAttributes forState:UIControlStateHighlighted];
144
149
  } else
145
150
  self.image = [self.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
146
151
 
147
- self.tintColor = color;
152
+ self.tintColor = color.get;
153
+ }
154
+
155
+ - (void)mergeBackgroundColor:(Color *)color {
156
+ _buttonOptions.iconBackground.color = color;
157
+ [self redrawIcon];
158
+ }
159
+
160
+ - (void)mergeColor:(Color *)color {
161
+ _buttonOptions.color = color;
162
+ [self applyColor:color];
163
+ [self redrawIcon];
164
+ }
165
+
166
+ - (void)redrawIcon {
167
+ if (_buttonOptions.icon.hasValue && [self.customView isKindOfClass:UIButton.class]) {
168
+ UIImage* icon = [_iconCreator create:_buttonOptions];
169
+ [(UIButton *)self.customView setImage:icon forState:_buttonOptions.state];
170
+ }
148
171
  }
149
172
 
150
173
  - (void)applyTitleTextAttributes:(RNNButtonOptions *)button {
@@ -33,6 +33,13 @@
33
33
  [self removeTitleComponents];
34
34
  self.boundViewController.navigationItem.title = resolvedOptions.title.text.get;
35
35
  }
36
+
37
+ if (options.title.color.hasValue) {
38
+ [_titleViewHelper setTitleColor:options.title.color.get];
39
+ }
40
+ if (options.subtitle.color.hasValue) {
41
+ [_titleViewHelper setSubtitleColor:options.subtitle.color.get];
42
+ }
36
43
  }
37
44
 
38
45
  - (void)setTitleViewWithSubtitle:(RNNTopBarOptions *)options {
@@ -637,6 +637,8 @@ export interface OptionsTopBar {
637
637
 
638
638
  leftButtonColor?: Color;
639
639
  rightButtonColor?: Color;
640
+ leftButtonBackgroundColor?: Color;
641
+ rightButtonBackgroundColor?: Color;
640
642
  leftButtonDisabledColor?: Color;
641
643
  rightButtonDisabledColor?: Color;
642
644
  /**