react-native-navigation 7.33.0-alpha.9 → 7.33.1
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.
- package/lib/Mock/Components/LayoutComponent.tsx +2 -4
- package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +31 -80
- package/lib/dist/Mock/Components/LayoutComponent.js +1 -1
- package/lib/dist/src/commands/LayoutTreeCrawler.js +1 -1
- package/lib/dist/src/components/Store.d.ts +1 -0
- package/lib/dist/src/components/Store.js +3 -0
- package/lib/ios/BottomTabsTogetherAttacher.m +1 -1
- package/lib/ios/RCTConvert+Interpolation.m +13 -12
- package/lib/ios/RNNBaseIconCreator.h +2 -2
- package/lib/ios/RNNBaseIconCreator.m +31 -31
- package/lib/ios/RNNBottomTabsController.h +0 -2
- package/lib/ios/RNNBottomTabsController.m +16 -19
- package/lib/ios/RNNButtonBuilder.m +2 -2
- package/lib/ios/RNNComponentPresenter.m +6 -4
- package/lib/ios/RNNComponentRootView.m +0 -1
- package/lib/ios/RNNDynamicIconCreator.h +1 -1
- package/lib/ios/RNNDynamicIconCreator.m +29 -16
- package/lib/ios/RNNFontAttributesCreator.m +1 -0
- package/lib/ios/RNNIconCreator.h +1 -1
- package/lib/ios/RNNIconCreator.m +6 -5
- package/lib/ios/RNNLayoutManager.m +0 -10
- package/lib/ios/RNNLayoutProtocol.h +0 -2
- package/lib/ios/RNNTabBarItemCreator.m +8 -8
- package/lib/ios/RNNUIBarButtonItem.m +3 -3
- package/lib/ios/TopBarTitlePresenter.m +1 -1
- package/lib/src/commands/LayoutTreeCrawler.ts +1 -1
- package/lib/src/components/Store.ts +4 -0
- package/package.json +1 -1
|
@@ -19,10 +19,8 @@ export const LayoutComponent = class extends Component<ComponentProps> {
|
|
|
19
19
|
return <View />;
|
|
20
20
|
}
|
|
21
21
|
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
22
|
-
|
|
23
|
-
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}
|
|
24
|
-
error,
|
|
25
|
-
errorInfo
|
|
22
|
+
throw new Error(
|
|
23
|
+
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`
|
|
26
24
|
);
|
|
27
25
|
}
|
|
28
26
|
};
|
|
@@ -2,44 +2,17 @@ package com.reactnativenavigation.views.stack.topbar.titlebar
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import android.view.View
|
|
5
6
|
import android.view.ViewGroup
|
|
6
7
|
import androidx.core.view.children
|
|
7
8
|
import com.facebook.react.ReactInstanceManager
|
|
8
9
|
import com.reactnativenavigation.react.ReactView
|
|
9
10
|
|
|
10
|
-
|
|
11
11
|
@SuppressLint("ViewConstructor")
|
|
12
12
|
class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
|
|
13
13
|
componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
|
|
14
|
-
|
|
15
|
-
private data class Coordinates(var left: Int = Int.MAX_VALUE,
|
|
16
|
-
var top: Int = Int.MAX_VALUE,
|
|
17
|
-
var right: Int = 0,
|
|
18
|
-
var bottom: Int = 0) {
|
|
19
|
-
fun width(): Int {
|
|
20
|
-
return if (left < Int.MAX_VALUE) right - left else 0
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fun height(): Int {
|
|
24
|
-
return if (top < Int.MAX_VALUE) bottom - top else 0
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
fun set(left: Int, top: Int, right: Int, bottom: Int) {
|
|
28
|
-
this.left = left
|
|
29
|
-
this.top = top
|
|
30
|
-
this.right = right
|
|
31
|
-
this.bottom = bottom
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private val titleCoordinates = Coordinates()
|
|
36
|
-
|
|
37
14
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
38
|
-
|
|
39
|
-
setSize(titleCoordinates)
|
|
40
|
-
}
|
|
41
|
-
super.onMeasure(interceptReactRootViewMeasureSpecWidth(widthMeasureSpec),
|
|
42
|
-
interceptReactRootViewMeasureSpecHeight(heightMeasureSpec))
|
|
15
|
+
super.onMeasure(interceptReactRootViewMeasureSpecWidth(widthMeasureSpec), interceptReactRootViewMeasureSpecHeight(heightMeasureSpec))
|
|
43
16
|
}
|
|
44
17
|
|
|
45
18
|
private fun interceptReactRootViewMeasureSpecWidth(widthMeasureSpec: Int): Int {
|
|
@@ -48,9 +21,9 @@ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceMa
|
|
|
48
21
|
// It's causing infinite measurements, that hung up the UI.
|
|
49
22
|
// Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
|
|
50
23
|
// See for more details https://github.com/wix/react-native-navigation/pull/7096
|
|
51
|
-
val
|
|
52
|
-
|
|
53
|
-
|
|
24
|
+
val measuredWidth = this.getLastRootViewChildMaxWidth()
|
|
25
|
+
|
|
26
|
+
return MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY)
|
|
54
27
|
}
|
|
55
28
|
|
|
56
29
|
private fun interceptReactRootViewMeasureSpecHeight(heightMeasureSpec: Int): Int {
|
|
@@ -59,62 +32,40 @@ class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceMa
|
|
|
59
32
|
// It's causing infinite measurements, that hung up the UI.
|
|
60
33
|
// Intercepting largest child by height, and use its height as (parent) ReactRootView width fixed that.
|
|
61
34
|
// See for more details https://github.com/wix/react-native-navigation/pull/7096
|
|
35
|
+
val measuredHeight = this.getLastRootViewChild()?.height
|
|
62
36
|
|
|
63
|
-
|
|
64
|
-
return if (height > 0) MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY) else
|
|
37
|
+
return if (measuredHeight != null) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
|
|
65
38
|
heightMeasureSpec
|
|
66
39
|
}
|
|
67
40
|
|
|
68
|
-
private fun
|
|
69
|
-
if (
|
|
70
|
-
|
|
41
|
+
private fun getLastRootViewChildMaxWidth(): Int {
|
|
42
|
+
if (rootViewGroup.children.count() == 0) {
|
|
43
|
+
return 0
|
|
71
44
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
val location = IntArray(2)
|
|
78
|
-
child.getLocationOnScreen(location)
|
|
79
|
-
val left = location[0]
|
|
80
|
-
val top = location[1]
|
|
81
|
-
val height = child.bottom - child.top
|
|
82
|
-
val width = child.right - child.left
|
|
83
|
-
if (width < context.resources.displayMetrics.widthPixels) {
|
|
84
|
-
coordinates.set(left, top, left + width, top + height)
|
|
85
|
-
return true
|
|
86
|
-
}
|
|
45
|
+
var maxWidth = rootViewGroup.width
|
|
46
|
+
var next = rootViewGroup as Any
|
|
47
|
+
while(next is ViewGroup) { //try {
|
|
48
|
+
if (next.width > maxWidth) {
|
|
49
|
+
maxWidth = next.width
|
|
87
50
|
}
|
|
51
|
+
if (next.children.count() == 0) break
|
|
52
|
+
next.children.first().also { next = it }
|
|
88
53
|
}
|
|
89
|
-
|
|
90
|
-
return false
|
|
54
|
+
return maxWidth
|
|
91
55
|
}
|
|
92
56
|
|
|
93
|
-
private fun
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (child is ViewGroup) {
|
|
97
|
-
val childCoordinates = Coordinates()
|
|
98
|
-
setSizeByAllChildren(child, childCoordinates)
|
|
99
|
-
coordinates.left = coordinates.left.coerceAtMost(childCoordinates.left)
|
|
100
|
-
coordinates.right = coordinates.right.coerceAtLeast(childCoordinates.right)
|
|
101
|
-
coordinates.top = coordinates.top.coerceAtMost(childCoordinates.top)
|
|
102
|
-
coordinates.bottom = coordinates.bottom.coerceAtLeast(childCoordinates.bottom)
|
|
103
|
-
} else {
|
|
104
|
-
val location = IntArray(2)
|
|
105
|
-
child.getLocationOnScreen(location)
|
|
106
|
-
val childLeft = location[0]
|
|
107
|
-
val childRight = childLeft + child.measuredWidth
|
|
108
|
-
val childTop = location[1]
|
|
109
|
-
val childBottom = childTop + child.measuredHeight
|
|
110
|
-
|
|
111
|
-
coordinates.left = coordinates.left.coerceAtMost(childLeft)
|
|
112
|
-
coordinates.right = coordinates.right.coerceAtLeast(childRight)
|
|
113
|
-
coordinates.top = coordinates.top.coerceAtMost(childTop)
|
|
114
|
-
coordinates.bottom = coordinates.bottom.coerceAtLeast(childBottom)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
57
|
+
private fun getLastRootViewChild(): View? {
|
|
58
|
+
if (rootViewGroup.children.count() == 0) {
|
|
59
|
+
return null
|
|
117
60
|
}
|
|
118
|
-
|
|
61
|
+
var rootViewGroupLastChild: View = rootViewGroup
|
|
62
|
+
var next = rootViewGroup as Any
|
|
63
|
+
while(next is ViewGroup) { //try {
|
|
64
|
+
rootViewGroupLastChild = next
|
|
65
|
+
if (next.children.count() == 0) break
|
|
66
|
+
next.children.first().also { next = it }
|
|
67
|
+
}
|
|
68
|
+
@Suppress("UNREACHABLE_CODE")
|
|
69
|
+
return rootViewGroupLastChild
|
|
119
70
|
}
|
|
120
|
-
}
|
|
71
|
+
}
|
|
@@ -20,7 +20,7 @@ const LayoutComponent = class extends react_1.Component {
|
|
|
20
20
|
return react_1.default.createElement(react_native_1.View, null);
|
|
21
21
|
}
|
|
22
22
|
componentDidCatch(error, errorInfo) {
|
|
23
|
-
|
|
23
|
+
throw new Error(`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
exports.LayoutComponent = LayoutComponent;
|
|
@@ -14,7 +14,7 @@ class LayoutTreeCrawler {
|
|
|
14
14
|
if (node.type === LayoutType_1.LayoutType.Component) {
|
|
15
15
|
this.handleComponent(node);
|
|
16
16
|
}
|
|
17
|
-
const componentProps = this.store.
|
|
17
|
+
const componentProps = this.store.getPendingProps(node.id) || undefined;
|
|
18
18
|
this.optionsProcessor.processOptions(commandName, node.data.options, componentProps);
|
|
19
19
|
node.children.forEach((value) => this.crawl(value, commandName));
|
|
20
20
|
}
|
|
@@ -10,6 +10,7 @@ export declare class Store {
|
|
|
10
10
|
private lazyRegistratorFn;
|
|
11
11
|
updateProps(componentId: string, props: any, callback?: () => void): void;
|
|
12
12
|
setPendingProps(componentId: string, newProps: any): void;
|
|
13
|
+
getPendingProps(componentId: string): any;
|
|
13
14
|
getPropsForId(componentId: string): any;
|
|
14
15
|
mergeNewPropsForId(componentId: string, newProps: any): void;
|
|
15
16
|
clearComponent(componentId: string): void;
|
|
@@ -18,6 +18,9 @@ class Store {
|
|
|
18
18
|
setPendingProps(componentId, newProps) {
|
|
19
19
|
this.pendingPropsById[componentId] = newProps;
|
|
20
20
|
}
|
|
21
|
+
getPendingProps(componentId) {
|
|
22
|
+
return this.pendingPropsById[componentId];
|
|
23
|
+
}
|
|
21
24
|
getPropsForId(componentId) {
|
|
22
25
|
if (this.pendingPropsById[componentId]) {
|
|
23
26
|
this.propsById[componentId] = this.pendingPropsById[componentId];
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
- (void)attach:(RNNBottomTabsController *)bottomTabsController {
|
|
7
7
|
dispatch_group_t ready = dispatch_group_create();
|
|
8
8
|
|
|
9
|
-
for (UIViewController *vc in bottomTabsController.
|
|
9
|
+
for (UIViewController *vc in bottomTabsController.childViewControllers) {
|
|
10
10
|
dispatch_group_enter(ready);
|
|
11
11
|
[vc setReactViewReadyCallback:^{
|
|
12
12
|
dispatch_group_leave(ready);
|
|
@@ -27,12 +27,12 @@ RCT_CUSTOM_CONVERTER(id<Interpolator>, Interpolator, [RCTConvert interpolatorFro
|
|
|
27
27
|
}
|
|
28
28
|
NSString *interpolation = json[@"type"] ? json[@"type"] : nil;
|
|
29
29
|
|
|
30
|
-
id<Interpolator> (^interpolator)(void) = @{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
id<Interpolator> (^interpolator)(void) = @{@"decelerate" : ^{
|
|
31
|
+
CGFloat factor = [[[NumberParser parse:json key:@"factor"]
|
|
32
|
+
withDefault:[NSNumber numberWithFloat:1.0f]] floatValue];
|
|
33
|
+
return [[DecelerateInterpolator alloc] init:factor];
|
|
34
|
+
}
|
|
35
|
+
,
|
|
36
36
|
@"accelerate" : ^{
|
|
37
37
|
CGFloat factor = [[[NumberParser parse:json key:@"factor"]
|
|
38
38
|
withDefault:[NSNumber numberWithFloat:1.0f]] floatValue];
|
|
@@ -72,13 +72,14 @@ RCT_CUSTOM_CONVERTER(id<Interpolator>, Interpolator, [RCTConvert interpolatorFro
|
|
|
72
72
|
allowsOverdamping:allowsOverdamping
|
|
73
73
|
initialVelocity:initialVelocity];
|
|
74
74
|
},
|
|
75
|
-
|
|
75
|
+
}
|
|
76
|
+
[interpolation];
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
if (interpolator != nil) {
|
|
79
|
+
return interpolator();
|
|
80
|
+
} else {
|
|
81
|
+
return [RCTConvert defaultInterpolator];
|
|
82
|
+
}
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
@end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#import <Foundation/Foundation.h>
|
|
2
1
|
#import "RNNButtonOptions.h"
|
|
3
2
|
#import "RNNIconDrawer.h"
|
|
4
3
|
#import "UIImage+utils.h"
|
|
4
|
+
#import <Foundation/Foundation.h>
|
|
5
5
|
|
|
6
6
|
@interface RNNBaseIconCreator : NSObject
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
- (UIImage *)create:(RNNButtonOptions *)buttonOptions;
|
|
11
11
|
|
|
12
|
-
@property
|
|
12
|
+
@property(nonatomic, retain) RNNIconDrawer *iconDrawer;
|
|
13
13
|
|
|
14
14
|
@end
|
|
15
15
|
|
|
@@ -4,62 +4,62 @@
|
|
|
4
4
|
@implementation RNNBaseIconCreator
|
|
5
5
|
|
|
6
6
|
- (instancetype)initWithIconDrawer:(RNNIconDrawer *)iconDrawer {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
self = [super init];
|
|
8
|
+
self.iconDrawer = iconDrawer;
|
|
9
|
+
return self;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
- (UIImage *)create:(RNNButtonOptions *)buttonOptions {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (buttonOptions.isEnabled)
|
|
14
|
+
return [self createEnabledIcon:buttonOptions];
|
|
15
|
+
else
|
|
16
|
+
return [self createDisabledIcon:buttonOptions];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
- (UIImage *)createEnabledIcon:(RNNButtonOptions *)buttonOptions {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
UIColor *backgroundColor = [buttonOptions.iconBackground.color withDefault:UIColor.clearColor];
|
|
21
|
+
UIColor *tintColor = [buttonOptions.color withDefault:nil];
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
return [self createIcon:buttonOptions tintColor:tintColor backgroundColor:backgroundColor];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
- (UIImage *)createDisabledIcon:(RNNButtonOptions *)buttonOptions {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
UIColor *backgroundColor = [self resolveDisabledBackgroundColor:buttonOptions];
|
|
28
|
+
UIColor *tintColor = [self resolveDisabledIconColor:buttonOptions];
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
return [self createIcon:buttonOptions tintColor:tintColor backgroundColor:backgroundColor];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
- (UIColor *)resolveDisabledIconColor:(RNNButtonOptions *)buttonOptions {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (![buttonOptions.enabled withDefault:YES] && buttonOptions.disabledColor.hasValue)
|
|
35
|
+
return buttonOptions.disabledColor.get;
|
|
36
|
+
else
|
|
37
|
+
return [buttonOptions.color withDefault:nil];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
- (UIColor *)resolveDisabledBackgroundColor:(RNNButtonOptions *)buttonOptions {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
if (![buttonOptions.enabled withDefault:YES] &&
|
|
42
|
+
buttonOptions.iconBackground.disabledColor.hasValue)
|
|
43
|
+
return buttonOptions.iconBackground.disabledColor.get;
|
|
44
|
+
else
|
|
45
|
+
return [buttonOptions.iconBackground.color withDefault:nil];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
- (UIImage *)createIcon:(RNNButtonOptions *)buttonOptions
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
tintColor:(UIColor *)tintColor
|
|
50
|
+
backgroundColor:(UIColor *)backgroundColor {
|
|
51
51
|
@throw @"createIcon should be implemented by subclass";
|
|
52
52
|
return nil;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
- (CGSize)resolveIconSize:(RNNButtonOptions *)buttonOptions {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
CGFloat width =
|
|
57
|
+
[buttonOptions.iconBackground.width withDefault:@(buttonOptions.icon.get.size.width)]
|
|
58
|
+
.floatValue;
|
|
59
|
+
CGFloat height =
|
|
60
|
+
[buttonOptions.iconBackground.height withDefault:@(buttonOptions.icon.get.size.height)]
|
|
61
|
+
.floatValue;
|
|
62
|
+
return CGSizeMake(width, height);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
@end
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
@interface RNNBottomTabsController ()
|
|
5
5
|
@property(nonatomic, strong) BottomTabPresenter *bottomTabPresenter;
|
|
6
6
|
@property(nonatomic, strong) RNNDotIndicatorPresenter *dotIndicatorPresenter;
|
|
7
|
-
@property(nonatomic) BOOL viewWillAppearOnce;
|
|
8
7
|
@property(nonatomic, strong) UILongPressGestureRecognizer *longPressRecognizer;
|
|
9
8
|
|
|
10
9
|
@end
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
_bottomTabsAttacher = bottomTabsAttacher;
|
|
30
29
|
_bottomTabPresenter = bottomTabPresenter;
|
|
31
30
|
_dotIndicatorPresenter = dotIndicatorPresenter;
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
self = [super initWithLayoutInfo:layoutInfo
|
|
34
33
|
creator:creator
|
|
35
34
|
options:options
|
|
@@ -56,18 +55,27 @@
|
|
|
56
55
|
return self;
|
|
57
56
|
}
|
|
58
57
|
|
|
58
|
+
- (void)viewWillAppear:(BOOL)animated {
|
|
59
|
+
[super viewWillAppear:animated];
|
|
60
|
+
// This hack is needed for cases when the initialized state of the tabBar should be hidden
|
|
61
|
+
UINavigationController *firstChild = [self.childViewControllers objectAtIndex:0];
|
|
62
|
+
if ([firstChild isKindOfClass:UINavigationController.class] &&
|
|
63
|
+
firstChild.hidesBottomBarWhenPushed) {
|
|
64
|
+
[firstChild pushViewController:UIViewController.new animated:NO];
|
|
65
|
+
[firstChild popViewControllerAnimated:NO];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (void)viewDidLoad {
|
|
70
|
+
[super viewDidLoad];
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
- (void)createTabBarItems:(NSArray<UIViewController *> *)childViewControllers {
|
|
60
74
|
for (UIViewController *child in childViewControllers) {
|
|
61
75
|
[_bottomTabPresenter applyOptions:child.resolveOptions child:child];
|
|
62
76
|
}
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
- (void)viewWillAppear:(BOOL)animated {
|
|
66
|
-
[super viewWillAppear:animated];
|
|
67
|
-
_viewWillAppearOnce = YES;
|
|
68
|
-
[self loadChildren:self.pendingChildViewControllers];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
79
|
- (void)mergeChildOptions:(RNNNavigationOptions *)options child:(UIViewController *)child {
|
|
72
80
|
[super mergeChildOptions:options child:child];
|
|
73
81
|
UIViewController *childViewController = [self findViewController:child];
|
|
@@ -124,23 +132,12 @@
|
|
|
124
132
|
return self.childViewControllers.count ? self.childViewControllers[_currentTabIndex] : nil;
|
|
125
133
|
}
|
|
126
134
|
|
|
127
|
-
- (NSArray<__kindof UIViewController *> *)childViewControllers {
|
|
128
|
-
return self.pendingChildViewControllers ?: super.childViewControllers;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
135
|
- (void)setSelectedViewController:(__kindof UIViewController *)selectedViewController {
|
|
132
136
|
_previousTabIndex = _currentTabIndex;
|
|
133
137
|
_currentTabIndex = [self.childViewControllers indexOfObject:selectedViewController];
|
|
134
138
|
[super setSelectedViewController:selectedViewController];
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
- (void)loadChildren:(NSArray *)children {
|
|
138
|
-
if (self.viewWillAppearOnce) {
|
|
139
|
-
[super loadChildren:children];
|
|
140
|
-
self.pendingChildViewControllers = nil;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
141
|
- (void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated {
|
|
145
142
|
_tabBarNeedsRestore = YES;
|
|
146
143
|
visible ? [self showTabBar:animated] : [self hideTabBar:animated];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#import "RNNButtonBuilder.h"
|
|
2
|
-
#import "RNNFontAttributesCreator.h"
|
|
3
2
|
#import "RNNDynamicIconCreator.h"
|
|
3
|
+
#import "RNNFontAttributesCreator.h"
|
|
4
4
|
|
|
5
5
|
@implementation RNNButtonBuilder {
|
|
6
6
|
RNNReactComponentRegistry *_componentRegistry;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
} else {
|
|
16
16
|
_iconCreator = [[RNNIconCreator alloc] initWithIconDrawer:RNNIconDrawer.new];
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
return self;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -215,13 +215,15 @@
|
|
|
215
215
|
if (mergeOptions.topBar.rightButtonColor.hasValue) {
|
|
216
216
|
[_buttonsPresenter applyRightButtonsColor:mergeOptions.topBar.rightButtonColor];
|
|
217
217
|
}
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
if (mergeOptions.topBar.rightButtonBackgroundColor.hasValue) {
|
|
220
|
-
[_buttonsPresenter
|
|
220
|
+
[_buttonsPresenter
|
|
221
|
+
applyRightButtonsBackgroundColor:mergeOptions.topBar.rightButtonBackgroundColor];
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
|
|
223
224
|
if (mergeOptions.topBar.leftButtonBackgroundColor.hasValue) {
|
|
224
|
-
[_buttonsPresenter
|
|
225
|
+
[_buttonsPresenter
|
|
226
|
+
applyLeftButtonsBackgroundColor:mergeOptions.topBar.leftButtonBackgroundColor];
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
if (mergeOptions.overlay.interceptTouchOutside.hasValue) {
|
|
@@ -8,22 +8,35 @@
|
|
|
8
8
|
UIImage *iconImage = buttonOptions.icon.get;
|
|
9
9
|
CGSize iconSize = [self resolveIconSize:buttonOptions];
|
|
10
10
|
CGFloat cornerRadius = [buttonOptions.iconBackground.cornerRadius withDefault:@(0)].floatValue;
|
|
11
|
-
UIColor *lightColor = [tintColor
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
UIColor *
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
UIColor *lightColor = [tintColor
|
|
12
|
+
resolvedColorWithTraitCollection:
|
|
13
|
+
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]];
|
|
14
|
+
UIColor *darkColor = [tintColor
|
|
15
|
+
resolvedColorWithTraitCollection:
|
|
16
|
+
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|
|
17
|
+
UIColor *lightBackgroundColor = [backgroundColor
|
|
18
|
+
resolvedColorWithTraitCollection:
|
|
19
|
+
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]];
|
|
20
|
+
UIColor *darkBackgroundColor = [backgroundColor
|
|
21
|
+
resolvedColorWithTraitCollection:
|
|
22
|
+
[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|
|
23
|
+
UIImage *darkImage =
|
|
24
|
+
[[self.iconDrawer draw:iconImage
|
|
25
|
+
imageColor:darkColor
|
|
26
|
+
backgroundColor:darkBackgroundColor
|
|
27
|
+
size:iconSize
|
|
28
|
+
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
29
|
+
UIImage *lightImage =
|
|
30
|
+
[[self.iconDrawer draw:iconImage
|
|
31
|
+
imageColor:lightColor
|
|
32
|
+
backgroundColor:lightBackgroundColor
|
|
33
|
+
size:iconSize
|
|
34
|
+
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
35
|
+
[lightImage.imageAsset
|
|
36
|
+
registerImage:darkImage
|
|
37
|
+
withTraitCollection:[UITraitCollection
|
|
38
|
+
traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|
|
39
|
+
|
|
27
40
|
return lightImage;
|
|
28
41
|
}
|
|
29
42
|
|
package/lib/ios/RNNIconCreator.h
CHANGED
package/lib/ios/RNNIconCreator.m
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
UIImage *iconImage = buttonOptions.icon.get;
|
|
9
9
|
CGSize iconSize = [self resolveIconSize:buttonOptions];
|
|
10
10
|
CGFloat cornerRadius = [buttonOptions.iconBackground.cornerRadius withDefault:@(0)].floatValue;
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
return
|
|
12
|
+
[[self.iconDrawer draw:iconImage
|
|
13
|
+
imageColor:tintColor
|
|
14
|
+
backgroundColor:backgroundColor
|
|
15
|
+
size:iconSize
|
|
16
|
+
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
@end
|
|
@@ -72,16 +72,6 @@
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
if ([parentViewController respondsToSelector:@selector(pendingChildViewControllers)]) {
|
|
76
|
-
NSArray *pendingChildVCs = [parentViewController pendingChildViewControllers];
|
|
77
|
-
for (UIViewController *childVC in pendingChildVCs) {
|
|
78
|
-
UIViewController *result = [self findChildComponentForParent:childVC forId:componentId];
|
|
79
|
-
if (result) {
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
75
|
return nil;
|
|
86
76
|
}
|
|
87
77
|
|
|
@@ -91,14 +91,6 @@
|
|
|
91
91
|
NSNumber *fontSize = [bottomTabOptions.fontSize withDefault:@(10)];
|
|
92
92
|
NSString *fontWeight = [bottomTabOptions.fontWeight withDefault:nil];
|
|
93
93
|
|
|
94
|
-
NSDictionary *selectedAttributes = [RNNFontAttributesCreator
|
|
95
|
-
createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateSelected]
|
|
96
|
-
fontFamily:fontFamily
|
|
97
|
-
fontSize:fontSize
|
|
98
|
-
fontWeight:fontWeight
|
|
99
|
-
color:selectedTextColor];
|
|
100
|
-
[self setSelectedTitleAttributes:tabItem selectedTitleAttributes:selectedAttributes];
|
|
101
|
-
|
|
102
94
|
NSDictionary *normalAttributes = [RNNFontAttributesCreator
|
|
103
95
|
createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateNormal]
|
|
104
96
|
fontFamily:fontFamily
|
|
@@ -106,6 +98,14 @@
|
|
|
106
98
|
fontWeight:fontWeight
|
|
107
99
|
color:textColor];
|
|
108
100
|
[self setTitleAttributes:tabItem titleAttributes:normalAttributes];
|
|
101
|
+
|
|
102
|
+
NSDictionary *selectedAttributes = [RNNFontAttributesCreator
|
|
103
|
+
createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateSelected]
|
|
104
|
+
fontFamily:fontFamily
|
|
105
|
+
fontSize:fontSize
|
|
106
|
+
fontWeight:fontWeight
|
|
107
|
+
color:selectedTextColor];
|
|
108
|
+
[self setSelectedTitleAttributes:tabItem selectedTitleAttributes:selectedAttributes];
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
- (void)setTitleAttributes:(UITabBarItem *)tabItem titleAttributes:(NSDictionary *)titleAttributes {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
@end
|
|
13
13
|
|
|
14
14
|
@implementation RNNUIBarButtonItem {
|
|
15
|
-
RNNIconCreator*
|
|
16
|
-
RNNButtonOptions*
|
|
15
|
+
RNNIconCreator *_iconCreator;
|
|
16
|
+
RNNButtonOptions *_buttonOptions;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
- (instancetype)init {
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
|
|
166
166
|
- (void)redrawIcon {
|
|
167
167
|
if (_buttonOptions.icon.hasValue && [self.customView isKindOfClass:UIButton.class]) {
|
|
168
|
-
UIImage*
|
|
168
|
+
UIImage *icon = [_iconCreator create:_buttonOptions];
|
|
169
169
|
[(UIButton *)self.customView setImage:icon forState:_buttonOptions.state];
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -24,7 +24,7 @@ export class LayoutTreeCrawler {
|
|
|
24
24
|
if (node.type === LayoutType.Component) {
|
|
25
25
|
this.handleComponent(node);
|
|
26
26
|
}
|
|
27
|
-
const componentProps = this.store.
|
|
27
|
+
const componentProps = this.store.getPendingProps(node.id) || undefined;
|
|
28
28
|
this.optionsProcessor.processOptions(commandName, node.data.options, componentProps);
|
|
29
29
|
node.children.forEach((value: LayoutNode) => this.crawl(value, commandName));
|
|
30
30
|
}
|
|
@@ -23,6 +23,10 @@ export class Store {
|
|
|
23
23
|
this.pendingPropsById[componentId] = newProps;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
getPendingProps(componentId: string) {
|
|
27
|
+
return this.pendingPropsById[componentId];
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
getPropsForId(componentId: string) {
|
|
27
31
|
if (this.pendingPropsById[componentId]) {
|
|
28
32
|
this.propsById[componentId] = this.pendingPropsById[componentId];
|