react-native-navigation 7.43.0 → 7.44.0
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/ComponentScreen.tsx +29 -15
- package/lib/Mock/Components/LayoutComponent.tsx +2 -2
- package/lib/Mock/index.js +2 -2
- package/lib/android/app/build.gradle +1 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/FeatureToggles.kt +62 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java +2 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java +20 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/ValueAnimationOptions.kt +3 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java +3 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/modal/ModalHostLayout.kt +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ColorUtils.java +11 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java +3 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactViewGroup.kt +4 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/StubAnimationListener.kt +19 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/SystemUiUtils.kt +17 -16
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ViewUtils.java +6 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenter.java +0 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAnimator.kt +2 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +4 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java +7 -14
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentPresenter.java +18 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +24 -12
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +52 -24
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +20 -10
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/{TopBarAnimator.kt → TopBarAppearanceAnimator.kt} +4 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarCollapseBehavior.kt +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarController.kt +154 -26
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/statusbar/StatusBarPresenter.kt +212 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/LayoutDirectionApplier.kt +8 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +12 -107
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/StatusBarColorAnimator.kt +28 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +34 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerVisibilityInfo.kt +5 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/{BaseViewAnimator.kt → BaseViewAppearanceAnimator.kt} +4 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/ColorAnimator.kt +22 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreator.kt +8 -8
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/ViewAnimatorCreator.kt +2 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/ViewBkgColorProperty.kt +17 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/BackgroundColorAnimator.kt +6 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/BackgroundColorEvaluator.kt +4 -2
- package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +6 -6
- package/lib/dist/Mock/Application.d.ts +4 -6
- package/lib/dist/Mock/Components/BottomTabs.d.ts +9 -13
- package/lib/dist/Mock/Components/ComponentScreen.d.ts +5 -7
- package/lib/dist/Mock/Components/ComponentScreen.js +10 -3
- package/lib/dist/Mock/Components/LayoutComponent.d.ts +9 -13
- package/lib/dist/Mock/Components/Modals.d.ts +9 -13
- package/lib/dist/Mock/Components/NavigationButton.d.ts +11 -15
- package/lib/dist/Mock/Components/Overlays.d.ts +9 -13
- package/lib/dist/Mock/Components/Stack.d.ts +9 -13
- package/lib/dist/Mock/Components/TopBar.d.ts +7 -9
- package/lib/dist/Mock/connect.js +2 -1
- package/lib/dist/Mock/index.js +2 -2
- package/lib/dist/src/adapters/NativeEventsReceiver.js +1 -1
- package/lib/dist/src/adapters/TouchablePreview.d.ts +2 -2
- package/lib/dist/src/commands/LayoutType.js +1 -1
- package/lib/dist/src/commands/OptionsProcessor.js +8 -1
- package/lib/dist/src/components/Modal.d.ts +1 -1
- package/lib/dist/src/interfaces/CommandName.js +1 -1
- package/lib/dist/src/interfaces/Options.d.ts +33 -3
- package/lib/dist/src/interfaces/Options.js +2 -2
- package/lib/dist/src/types.d.ts +1 -0
- package/lib/ios/BottomTabsBasePresenter.m +3 -2
- package/lib/ios/RNNAppDelegate.mm +1 -2
- package/lib/ios/RNNConvert.h +2 -0
- package/lib/ios/RNNConvert.m +4 -0
- package/lib/ios/RNNStackPresenter.m +3 -2
- package/lib/src/adapters/NativeEventsReceiver.ts +3 -3
- package/lib/src/adapters/TouchablePreview.tsx +3 -3
- package/lib/src/commands/OptionsProcessor.ts +13 -2
- package/lib/src/interfaces/Options.ts +38 -3
- package/package.json +37 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { View, Text, TouchableOpacity, Image, ImageURISource} from 'react-native';
|
|
3
|
-
import { Navigation, ImageResource} from 'react-native-navigation';
|
|
2
|
+
import { View, Text, TouchableOpacity, Image, ImageURISource } from 'react-native';
|
|
3
|
+
import { Navigation, ImageResource } from 'react-native-navigation';
|
|
4
4
|
import { ComponentProps } from '../ComponentProps';
|
|
5
5
|
import { VISIBLE_SCREEN_TEST_ID } from '../constants';
|
|
6
6
|
import { LayoutStore } from '../Stores/LayoutStore';
|
|
@@ -10,8 +10,7 @@ import { events } from '../Stores/EventsStore';
|
|
|
10
10
|
import _ from 'lodash';
|
|
11
11
|
import { switchTabByIndex } from '../actions/layoutActions';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
function isURISource(src: ImageResource| undefined): src is ImageURISource {
|
|
13
|
+
function isURISource(src: ImageResource | undefined): src is ImageURISource {
|
|
15
14
|
return !!src && typeof src === 'object' && 'uri' in src;
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -36,12 +35,15 @@ export const ComponentScreen = connect(
|
|
|
36
35
|
if (bottomTabsOptions?.visible === false) return null;
|
|
37
36
|
const buttons = bottomTabs!.children!.map((child, i) => {
|
|
38
37
|
const bottomTabOptions = child.resolveOptions().bottomTab;
|
|
39
|
-
const icon =
|
|
38
|
+
const icon =
|
|
39
|
+
(bottomTabs as any).selectedIndex === i
|
|
40
|
+
? bottomTabOptions?.selectedIcon
|
|
41
|
+
: bottomTabOptions?.icon;
|
|
40
42
|
const iconURI = isURISource(icon) ? icon.uri : undefined;
|
|
41
43
|
return (
|
|
42
44
|
<View key={`tab-${i}`}>
|
|
43
45
|
<TouchableOpacity
|
|
44
|
-
style={{padding:10}}
|
|
46
|
+
style={{ padding: 10 }}
|
|
45
47
|
testID={bottomTabOptions?.testID}
|
|
46
48
|
onPress={() => {
|
|
47
49
|
events.invokeBottomTabPressed({
|
|
@@ -51,22 +53,34 @@ export const ComponentScreen = connect(
|
|
|
51
53
|
switchTabByIndex(this.props.layoutNode.getBottomTabs(), i);
|
|
52
54
|
}}
|
|
53
55
|
>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
|
|
57
|
+
<Text>{bottomTabOptions?.badge}</Text>
|
|
58
|
+
{iconURI && (
|
|
59
|
+
<Image
|
|
60
|
+
style={{ width: 18, height: 18, marginBottom: 5 }}
|
|
61
|
+
source={{ uri: iconURI }}
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
<Text style={{ fontSize: 12 }}>{bottomTabOptions?.text || ''}</Text>
|
|
65
|
+
</View>
|
|
59
66
|
</TouchableOpacity>
|
|
60
67
|
</View>
|
|
61
68
|
);
|
|
62
69
|
});
|
|
63
70
|
|
|
64
71
|
return (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
<View
|
|
73
|
+
testID={bottomTabsOptions?.testID}
|
|
74
|
+
style={{
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
width: '100%',
|
|
78
|
+
backgroundColor: '#F0F2F5',
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
68
81
|
{buttons}
|
|
69
|
-
|
|
82
|
+
</View>
|
|
83
|
+
);
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
render() {
|
|
@@ -19,8 +19,8 @@ export const LayoutComponent = class extends Component<ComponentProps> {
|
|
|
19
19
|
return <View />;
|
|
20
20
|
}
|
|
21
21
|
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
22
|
-
const err =
|
|
23
|
-
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}
|
|
22
|
+
const err = new Error(
|
|
23
|
+
`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}: ${error}\n${errorInfo?.componentStack}`
|
|
24
24
|
);
|
|
25
25
|
(err as any).cause = error;
|
|
26
26
|
throw err;
|
package/lib/Mock/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApplicationMock = void 0;
|
|
4
|
-
exports.mockNativeComponents = mockNativeComponents;
|
|
3
|
+
exports.mockNativeComponents = exports.ApplicationMock = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
exports.ApplicationMock = require('./Application').Application;
|
|
7
6
|
tslib_1.__exportStar(require("./constants"), exports);
|
|
@@ -12,3 +11,4 @@ function mockNativeComponents() {
|
|
|
12
11
|
const { Navigation } = require('react-native-navigation');
|
|
13
12
|
Navigation.mockNativeComponents(new NativeCommandsSender(), new NativeEventsReceiver(), new AppRegistryService());
|
|
14
13
|
}
|
|
14
|
+
exports.mockNativeComponents = mockNativeComponents;
|
|
@@ -20,6 +20,7 @@ def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
|
|
|
20
20
|
def kotlinVersion = safeExtGet("RNNKotlinVersion", DEFAULT_KOTLIN_VERSION)
|
|
21
21
|
def kotlinStdlib = safeExtGet('RNNKotlinStdlib',DEFAULT_KOTLIN_STDLIB )
|
|
22
22
|
def kotlinCoroutinesCore = safeExtGet('RNNKotlinCoroutinesCore', '1.5.2')
|
|
23
|
+
|
|
23
24
|
android {
|
|
24
25
|
namespace 'com.reactnativenavigation'
|
|
25
26
|
compileSdkVersion safeExtGetFallbackLowerBound('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package com.reactnativenavigation
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.VisibleForTesting
|
|
4
|
+
|
|
5
|
+
enum class RNNToggles {
|
|
6
|
+
TOP_BAR_COLOR_ANIMATION__PUSH,
|
|
7
|
+
TOP_BAR_COLOR_ANIMATION__TABS,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
private val ToggleDefaults = mapOf(
|
|
11
|
+
RNNToggles.TOP_BAR_COLOR_ANIMATION__PUSH to false,
|
|
12
|
+
RNNToggles.TOP_BAR_COLOR_ANIMATION__TABS to false,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
object RNNFeatureToggles {
|
|
16
|
+
private var init = false
|
|
17
|
+
private var toggles = mutableMapOf<RNNToggles, Boolean>()
|
|
18
|
+
|
|
19
|
+
@JvmStatic
|
|
20
|
+
fun init() {
|
|
21
|
+
assertNotInitialized()
|
|
22
|
+
|
|
23
|
+
init = true
|
|
24
|
+
toggles = ToggleDefaults.toMutableMap()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@JvmStatic
|
|
28
|
+
fun init(overrides: Map<RNNToggles, Boolean>) {
|
|
29
|
+
init()
|
|
30
|
+
this.toggles.putAll(overrides)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@JvmStatic
|
|
34
|
+
fun init(vararg overrides: Pair<RNNToggles, Boolean>) {
|
|
35
|
+
init(mapOf(*overrides))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@JvmStatic
|
|
39
|
+
fun isEnabled(toggleName: RNNToggles): Boolean {
|
|
40
|
+
assertInitialized()
|
|
41
|
+
return toggles.getOrElse(toggleName) { false }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@VisibleForTesting
|
|
45
|
+
@JvmStatic
|
|
46
|
+
fun clear() {
|
|
47
|
+
init = false
|
|
48
|
+
toggles.clear()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private fun assertNotInitialized() {
|
|
52
|
+
if (init) {
|
|
53
|
+
throw IllegalStateException("FeatureToggles already initialized")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private fun assertInitialized() {
|
|
58
|
+
if (!init) {
|
|
59
|
+
throw IllegalStateException("FeatureToggles not initialized")
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -3,7 +3,6 @@ package com.reactnativenavigation;
|
|
|
3
3
|
import android.annotation.TargetApi;
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.content.res.Configuration;
|
|
6
|
-
import android.graphics.Color;
|
|
7
6
|
import android.os.Build;
|
|
8
7
|
import android.os.Bundle;
|
|
9
8
|
import android.view.KeyEvent;
|
|
@@ -12,8 +11,8 @@ import android.view.View;
|
|
|
12
11
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
|
13
12
|
import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
14
13
|
import com.facebook.react.modules.core.PermissionListener;
|
|
15
|
-
import com.reactnativenavigation.options.Options;
|
|
16
14
|
import com.reactnativenavigation.viewcontrollers.overlay.OverlayManager;
|
|
15
|
+
import com.reactnativenavigation.viewcontrollers.statusbar.StatusBarPresenter;
|
|
17
16
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.RootPresenter;
|
|
18
17
|
import com.reactnativenavigation.react.JsDevReloadHandler;
|
|
19
18
|
import com.reactnativenavigation.react.ReactGateway;
|
|
@@ -51,6 +50,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
|
|
|
51
50
|
navigator.bindViews();
|
|
52
51
|
getReactGateway().onActivityCreated(this);
|
|
53
52
|
setBackPressedCallback();
|
|
53
|
+
StatusBarPresenter.Companion.init(this);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@Override
|
|
@@ -4,10 +4,13 @@ import android.app.Application;
|
|
|
4
4
|
|
|
5
5
|
import com.facebook.react.ReactApplication;
|
|
6
6
|
import com.facebook.react.ReactNativeHost;
|
|
7
|
+
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
|
|
7
8
|
import com.facebook.soloader.SoLoader;
|
|
8
9
|
import com.reactnativenavigation.react.ReactGateway;
|
|
9
10
|
import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
|
|
10
11
|
|
|
12
|
+
import java.util.Collections;
|
|
13
|
+
import java.io.IOException;
|
|
11
14
|
import java.util.HashMap;
|
|
12
15
|
import java.util.Map;
|
|
13
16
|
|
|
@@ -15,15 +18,28 @@ import androidx.annotation.NonNull;
|
|
|
15
18
|
|
|
16
19
|
public abstract class NavigationApplication extends Application implements ReactApplication {
|
|
17
20
|
|
|
18
|
-
private ReactGateway reactGateway;
|
|
19
21
|
public static NavigationApplication instance;
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
private final Map<String, ExternalComponentCreator> externalComponents = new HashMap<>();
|
|
24
|
+
private ReactGateway reactGateway;
|
|
25
|
+
|
|
26
|
+
public NavigationApplication() {
|
|
27
|
+
this(Collections.emptyMap());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public NavigationApplication(Map<RNNToggles, Boolean> featureToggleOverrides) {
|
|
31
|
+
instance = this;
|
|
32
|
+
RNNFeatureToggles.init(featureToggleOverrides);
|
|
33
|
+
}
|
|
21
34
|
|
|
22
35
|
@Override
|
|
23
36
|
public void onCreate() {
|
|
24
37
|
super.onCreate();
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
try {
|
|
39
|
+
SoLoader.init(this, OpenSourceMergedSoMapping.INSTANCE);
|
|
40
|
+
} catch (IOException e) {
|
|
41
|
+
throw new RuntimeException(e);
|
|
42
|
+
}
|
|
27
43
|
reactGateway = createReactGateway();
|
|
28
44
|
}
|
|
29
45
|
|
package/lib/android/app/src/main/java/com/reactnativenavigation/options/ValueAnimationOptions.kt
CHANGED
|
@@ -50,9 +50,9 @@ class ValueAnimationOptions {
|
|
|
50
50
|
to += this.to[animationValueAccessor!!(view)]
|
|
51
51
|
}
|
|
52
52
|
val animator = ObjectAnimator.ofFloat(view,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
animProp,
|
|
54
|
+
from,
|
|
55
|
+
to
|
|
56
56
|
)
|
|
57
57
|
animator.interpolator = interpolator
|
|
58
58
|
if (duration.hasValue()) animator.duration = duration.get().toLong()
|
|
@@ -5,6 +5,8 @@ import android.content.Context;
|
|
|
5
5
|
import android.os.Bundle;
|
|
6
6
|
import android.view.MotionEvent;
|
|
7
7
|
|
|
8
|
+
import androidx.annotation.RestrictTo;
|
|
9
|
+
|
|
8
10
|
import com.facebook.react.ReactInstanceManager;
|
|
9
11
|
import com.facebook.react.ReactRootView;
|
|
10
12
|
import com.facebook.react.bridge.ReactContext;
|
|
@@ -12,14 +14,12 @@ import com.facebook.react.config.ReactFeatureFlags;
|
|
|
12
14
|
import com.facebook.react.uimanager.JSTouchDispatcher;
|
|
13
15
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
14
16
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
15
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
16
17
|
import com.reactnativenavigation.react.events.ComponentType;
|
|
17
18
|
import com.reactnativenavigation.react.events.EventEmitter;
|
|
18
19
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView;
|
|
20
|
+
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
19
21
|
import com.reactnativenavigation.views.component.Renderable;
|
|
20
22
|
|
|
21
|
-
import androidx.annotation.RestrictTo;
|
|
22
|
-
|
|
23
23
|
@SuppressLint("ViewConstructor")
|
|
24
24
|
public class ReactView extends ReactRootView implements IReactView, Renderable {
|
|
25
25
|
|
package/lib/android/app/src/main/java/com/reactnativenavigation/react/modal/ModalHostLayout.kt
CHANGED
|
@@ -34,7 +34,7 @@ open class ModalHostLayout(reactContext: ThemedReactContext) : ViewGroup(reactCo
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@TargetApi(23)
|
|
37
|
-
override fun dispatchProvideStructure(structure: ViewStructure
|
|
37
|
+
override fun dispatchProvideStructure(structure: ViewStructure) {
|
|
38
38
|
mHostView.dispatchProvideStructure(structure)
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.reactnativenavigation.utils;
|
|
2
2
|
|
|
3
|
+
import android.graphics.Color;
|
|
4
|
+
|
|
3
5
|
public class ColorUtils {
|
|
4
6
|
public static double[] colorToLAB(int color) {
|
|
5
7
|
final double[] result = new double[3];
|
|
@@ -10,4 +12,13 @@ public class ColorUtils {
|
|
|
10
12
|
public static int labToColor(double[] lab) {
|
|
11
13
|
return androidx.core.graphics.ColorUtils.LABToColor(lab[0], lab[1], lab[2]);
|
|
12
14
|
}
|
|
15
|
+
|
|
16
|
+
public static boolean isColorLight(int color) {
|
|
17
|
+
double darkness = 1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255;
|
|
18
|
+
return darkness < 0.5;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static int setAlpha(int color, int alpha) {
|
|
22
|
+
return (color & 0x00FFFFFF) | (alpha << 24);
|
|
23
|
+
}
|
|
13
24
|
}
|
package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java
CHANGED
|
@@ -18,6 +18,7 @@ import android.graphics.Typeface;
|
|
|
18
18
|
import android.text.TextUtils;
|
|
19
19
|
import androidx.annotation.Nullable;
|
|
20
20
|
import com.facebook.react.bridge.ReadableArray;
|
|
21
|
+
import com.facebook.react.common.ReactConstants;
|
|
21
22
|
import com.facebook.react.views.text.ReactFontManager;
|
|
22
23
|
import com.facebook.react.views.text.ReactTextShadowNode;
|
|
23
24
|
import java.util.ArrayList;
|
|
@@ -96,12 +97,12 @@ public class ReactTypefaceUtils {
|
|
|
96
97
|
|
|
97
98
|
int want = 0;
|
|
98
99
|
if ((weight == Typeface.BOLD)
|
|
99
|
-
|| ((oldStyle & Typeface.BOLD) != 0 && weight ==
|
|
100
|
+
|| ((oldStyle & Typeface.BOLD) != 0 && weight == ReactConstants.UNSET)) {
|
|
100
101
|
want |= Typeface.BOLD;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
if ((style == Typeface.ITALIC)
|
|
104
|
-
|| ((oldStyle & Typeface.ITALIC) != 0 && style ==
|
|
105
|
+
|| ((oldStyle & Typeface.ITALIC) != 0 && style == ReactConstants.UNSET)) {
|
|
105
106
|
want |= Typeface.ITALIC;
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
package com.reactnativenavigation.utils
|
|
2
2
|
|
|
3
|
-
import com.facebook.react.
|
|
3
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
4
|
+
import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable
|
|
4
5
|
import com.facebook.react.views.view.ReactViewGroup
|
|
5
6
|
|
|
7
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
6
8
|
val ReactViewGroup.borderRadius: Float
|
|
7
|
-
get() = (background as?
|
|
9
|
+
get() = (background as? CSSBackgroundDrawable)?.fullBorderWidth ?: 0f
|
package/lib/android/app/src/main/java/com/reactnativenavigation/utils/StubAnimationListener.kt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.reactnativenavigation.utils
|
|
2
|
+
|
|
3
|
+
import android.animation.Animator
|
|
4
|
+
|
|
5
|
+
open class StubAnimationListener: Animator.AnimatorListener {
|
|
6
|
+
override fun onAnimationStart(animation: Animator) {}
|
|
7
|
+
override fun onAnimationEnd(animation: Animator) {}
|
|
8
|
+
override fun onAnimationCancel(animation: Animator) {}
|
|
9
|
+
override fun onAnimationRepeat(animation: Animator) {}
|
|
10
|
+
|
|
11
|
+
companion object {
|
|
12
|
+
@JvmStatic
|
|
13
|
+
fun onAnimatorEnd(onEnd: (animation: Animator) -> Unit) = object: StubAnimationListener() {
|
|
14
|
+
override fun onAnimationEnd(animation: Animator) {
|
|
15
|
+
onEnd(animation)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -3,7 +3,6 @@ package com.reactnativenavigation.utils
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.graphics.Color
|
|
5
5
|
import android.graphics.Rect
|
|
6
|
-
import android.os.Build
|
|
7
6
|
import android.view.View
|
|
8
7
|
import android.view.Window
|
|
9
8
|
import androidx.annotation.ColorInt
|
|
@@ -16,7 +15,6 @@ import kotlin.math.ceil
|
|
|
16
15
|
|
|
17
16
|
object SystemUiUtils {
|
|
18
17
|
private const val STATUS_BAR_HEIGHT_M = 24
|
|
19
|
-
private const val STATUS_BAR_HEIGHT_L = 25
|
|
20
18
|
internal const val STATUS_BAR_HEIGHT_TRANSLUCENCY = 0.65f
|
|
21
19
|
private var statusBarHeight = -1
|
|
22
20
|
var navigationBarDefaultColor = -1
|
|
@@ -38,7 +36,7 @@ object SystemUiUtils {
|
|
|
38
36
|
val contentViewTop = contentView.top
|
|
39
37
|
abs(contentViewTop - statusBarHeight)
|
|
40
38
|
}
|
|
41
|
-
} ?:
|
|
39
|
+
} ?: STATUS_BAR_HEIGHT_M
|
|
42
40
|
statusBarHeight
|
|
43
41
|
}
|
|
44
42
|
return res
|
|
@@ -77,8 +75,6 @@ object SystemUiUtils {
|
|
|
77
75
|
|
|
78
76
|
@JvmStatic
|
|
79
77
|
fun setStatusBarColorScheme(window: Window?, view: View, isDark: Boolean) {
|
|
80
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return
|
|
81
|
-
|
|
82
78
|
window?.let {
|
|
83
79
|
WindowInsetsControllerCompat(window, view).isAppearanceLightStatusBars = isDark
|
|
84
80
|
// Workaround: on devices with api 30 status bar icons flickers or get hidden when removing view
|
|
@@ -121,17 +117,22 @@ object SystemUiUtils {
|
|
|
121
117
|
@ColorInt color: Int,
|
|
122
118
|
translucent: Boolean
|
|
123
119
|
) {
|
|
124
|
-
val
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
window?.statusBarColor =
|
|
120
|
+
val colorAlpha = Color.alpha(color)
|
|
121
|
+
val alpha = if (translucent && colorAlpha == 255) STATUS_BAR_HEIGHT_TRANSLUCENCY else colorAlpha/255.0f
|
|
122
|
+
val red: Int = Color.red(color)
|
|
123
|
+
val green: Int = Color.green(color)
|
|
124
|
+
val blue: Int = Color.blue(color)
|
|
125
|
+
val opaqueColor = Color.argb(ceil(alpha * 255).toInt(), red, green, blue)
|
|
126
|
+
setStatusBarColor(window, opaqueColor)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
fun setStatusBarColor(window: Window?, color: Int) {
|
|
130
|
+
window?.statusBarColor = color
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@JvmStatic
|
|
134
|
+
fun getStatusBarColor(window: Window?): Int? {
|
|
135
|
+
return window?.statusBarColor
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
@JvmStatic
|
|
@@ -5,8 +5,6 @@ import android.view.View;
|
|
|
5
5
|
import android.view.ViewGroup;
|
|
6
6
|
import android.view.ViewParent;
|
|
7
7
|
|
|
8
|
-
import com.facebook.react.views.view.ReactViewBackgroundDrawable;
|
|
9
|
-
|
|
10
8
|
import java.util.ArrayList;
|
|
11
9
|
import java.util.List;
|
|
12
10
|
|
|
@@ -14,6 +12,9 @@ import androidx.annotation.Nullable;
|
|
|
14
12
|
|
|
15
13
|
import static com.reactnativenavigation.utils.ObjectUtils.perform;
|
|
16
14
|
|
|
15
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI;
|
|
16
|
+
import com.facebook.react.uimanager.drawable.CSSBackgroundDrawable;
|
|
17
|
+
|
|
17
18
|
public class ViewUtils {
|
|
18
19
|
@Nullable
|
|
19
20
|
public static <T extends View> T findChildByClass(ViewGroup root, Class<T> clazz) {
|
|
@@ -107,9 +108,10 @@ public class ViewUtils {
|
|
|
107
108
|
return ((ViewGroup) parent).indexOfChild(view);
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
@UnstableReactNativeAPI
|
|
110
112
|
public static int getBackgroundColor(View view) {
|
|
111
|
-
if (view.getBackground() instanceof
|
|
112
|
-
return ((
|
|
113
|
+
if (view.getBackground() instanceof CSSBackgroundDrawable) {
|
|
114
|
+
return ((CSSBackgroundDrawable) view.getBackground()).getColor();
|
|
113
115
|
}
|
|
114
116
|
throw new RuntimeException(view.getBackground().getClass().getSimpleName() + " is not ReactViewBackgroundDrawable");
|
|
115
117
|
}
|
|
@@ -9,7 +9,6 @@ import android.graphics.drawable.Drawable;
|
|
|
9
9
|
|
|
10
10
|
import androidx.annotation.NonNull;
|
|
11
11
|
|
|
12
|
-
import com.aurelhubert.ahbottomnavigation.AHTextView;
|
|
13
12
|
import com.aurelhubert.ahbottomnavigation.notification.AHNotification;
|
|
14
13
|
import com.reactnativenavigation.options.BottomTabOptions;
|
|
15
14
|
import com.reactnativenavigation.options.DotIndicatorOptions;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
package com.reactnativenavigation.viewcontrollers.bottomtabs
|
|
2
2
|
|
|
3
|
-
import com.reactnativenavigation.views.animations.
|
|
3
|
+
import com.reactnativenavigation.views.animations.BaseViewAppearanceAnimator
|
|
4
4
|
import com.reactnativenavigation.views.bottomtabs.BottomTabs
|
|
5
5
|
|
|
6
|
-
class BottomTabsAnimator(view: BottomTabs? = null) :
|
|
6
|
+
class BottomTabsAnimator(view: BottomTabs? = null) : BaseViewAppearanceAnimator<BottomTabs>(HideDirection.Down, view) {
|
|
7
7
|
override fun onShowAnimationEnd() {
|
|
8
8
|
view.restoreBottomNavigation(false)
|
|
9
9
|
}
|
|
@@ -271,11 +271,11 @@ public class BottomTabsController extends ParentController<BottomTabsLayout> imp
|
|
|
271
271
|
private void selectTab(int newIndex, boolean enableSelectionHistory) {
|
|
272
272
|
saveTabSelection(newIndex, enableSelectionHistory);
|
|
273
273
|
tabsAttacher.onTabSelected(tabs.get(newIndex));
|
|
274
|
-
|
|
274
|
+
getCurrentChild().onDeselected();
|
|
275
|
+
|
|
276
|
+
ViewController<?> previouslyVisible = getCurrentChild();
|
|
275
277
|
bottomTabs.setCurrentItem(newIndex, false);
|
|
276
|
-
|
|
277
|
-
getCurrentChild().onViewWillAppear();
|
|
278
|
-
getCurrentChild().onViewDidAppear();
|
|
278
|
+
getCurrentChild().onSelected(previouslyVisible);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
private void saveTabSelection(int newIndex, boolean enableSelectionHistory) {
|
|
@@ -287,11 +287,6 @@ public class BottomTabsController extends ParentController<BottomTabsLayout> imp
|
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
@NonNull
|
|
291
|
-
private ViewGroup getCurrentView() {
|
|
292
|
-
return tabs.get(bottomTabs.getCurrentItem()).getView();
|
|
293
|
-
}
|
|
294
|
-
|
|
295
290
|
public Animator getPushAnimation(Options appearingOptions) {
|
|
296
291
|
return presenter.getPushAnimation(appearingOptions);
|
|
297
292
|
}
|
|
@@ -2,30 +2,23 @@ package com.reactnativenavigation.viewcontrollers.child;
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.content.res.Configuration;
|
|
5
|
-
import android.os.Build;
|
|
6
|
-
import android.util.Log;
|
|
7
5
|
import android.view.View;
|
|
8
6
|
import android.view.ViewGroup;
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.CallSuper;
|
|
9
|
+
import androidx.core.view.ViewCompat;
|
|
10
|
+
import androidx.core.view.WindowInsetsCompat;
|
|
10
11
|
|
|
11
12
|
import com.reactnativenavigation.options.Options;
|
|
12
|
-
import com.reactnativenavigation.utils.LogKt;
|
|
13
|
-
import com.reactnativenavigation.viewcontrollers.parent.ParentController;
|
|
14
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
15
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.NoOpYellowBoxDelegate;
|
|
16
13
|
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
|
|
14
|
+
import com.reactnativenavigation.viewcontrollers.viewcontroller.NoOpYellowBoxDelegate;
|
|
15
|
+
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
17
16
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
18
17
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.overlay.ViewControllerOverlay;
|
|
19
18
|
import com.reactnativenavigation.views.component.Component;
|
|
20
19
|
|
|
21
|
-
import androidx.annotation.CallSuper;
|
|
22
|
-
import androidx.core.graphics.Insets;
|
|
23
|
-
import androidx.core.view.ViewCompat;
|
|
24
|
-
import androidx.core.view.WindowCompat;
|
|
25
|
-
import androidx.core.view.WindowInsetsCompat;
|
|
26
|
-
|
|
27
20
|
public abstract class ChildController<T extends ViewGroup> extends ViewController<T> {
|
|
28
|
-
|
|
21
|
+
protected final Presenter presenter;
|
|
29
22
|
private final ChildControllersRegistry childRegistry;
|
|
30
23
|
|
|
31
24
|
public ChildControllersRegistry getChildRegistry() {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
package com.reactnativenavigation.viewcontrollers.component;
|
|
2
2
|
|
|
3
|
+
import android.animation.Animator;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
3
8
|
import com.reactnativenavigation.options.Options;
|
|
9
|
+
import com.reactnativenavigation.viewcontrollers.statusbar.StatusBarPresenter;
|
|
4
10
|
import com.reactnativenavigation.views.component.ComponentLayout;
|
|
5
11
|
|
|
6
12
|
public class ComponentPresenter extends ComponentPresenterBase {
|
|
@@ -35,4 +41,16 @@ public class ComponentPresenter extends ComponentPresenterBase {
|
|
|
35
41
|
Options withDefault = options.withDefaultOptions(defaultOptions);
|
|
36
42
|
setBackgroundColor(view, withDefault);
|
|
37
43
|
}
|
|
44
|
+
|
|
45
|
+
@Nullable
|
|
46
|
+
public Animator getStatusBarPushAnimation(@NonNull Options appearingOptions) {
|
|
47
|
+
Options appearingOptionsWithDefault = appearingOptions.copy().withDefaultOptions(defaultOptions);
|
|
48
|
+
return StatusBarPresenter.instance.getStatusBarPushAnimation(appearingOptionsWithDefault);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Nullable
|
|
52
|
+
public Animator getStatusBarPopAnimation(@NonNull Options appearingOptions, @NonNull Options disappearingOptions) {
|
|
53
|
+
Options appearingOptionsWithDefault = appearingOptions.copy().withDefaultOptions(defaultOptions);
|
|
54
|
+
return StatusBarPresenter.instance.getStatusBarPopAnimation(appearingOptionsWithDefault, disappearingOptions);
|
|
55
|
+
}
|
|
38
56
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
package com.reactnativenavigation.viewcontrollers.component;
|
|
2
2
|
|
|
3
|
+
import static com.reactnativenavigation.utils.ObjectUtils.perform;
|
|
4
|
+
|
|
5
|
+
import android.animation.Animator;
|
|
3
6
|
import android.app.Activity;
|
|
4
7
|
import android.content.res.Configuration;
|
|
5
8
|
import android.view.View;
|
|
6
9
|
|
|
7
|
-
import com.reactnativenavigation.utils.LogKt;
|
|
8
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
9
|
-
import com.reactnativenavigation.options.Options;
|
|
10
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
11
|
-
import com.reactnativenavigation.utils.SystemUiUtils;
|
|
12
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ReactViewCreator;
|
|
13
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildController;
|
|
14
|
-
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
15
|
-
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
16
|
-
import com.reactnativenavigation.views.component.ComponentLayout;
|
|
17
|
-
|
|
18
10
|
import androidx.annotation.NonNull;
|
|
11
|
+
import androidx.annotation.Nullable;
|
|
19
12
|
import androidx.core.graphics.Insets;
|
|
20
13
|
import androidx.core.view.ViewCompat;
|
|
21
14
|
import androidx.core.view.WindowInsetsCompat;
|
|
22
15
|
|
|
23
|
-
import
|
|
16
|
+
import com.reactnativenavigation.options.Options;
|
|
17
|
+
import com.reactnativenavigation.utils.SystemUiUtils;
|
|
18
|
+
import com.reactnativenavigation.viewcontrollers.child.ChildController;
|
|
19
|
+
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
20
|
+
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
21
|
+
import com.reactnativenavigation.viewcontrollers.viewcontroller.ReactViewCreator;
|
|
22
|
+
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
23
|
+
import com.reactnativenavigation.views.component.ComponentLayout;
|
|
24
24
|
|
|
25
25
|
public class ComponentViewController extends ChildController<ComponentLayout> {
|
|
26
26
|
private final String componentName;
|
|
@@ -64,6 +64,18 @@ public class ComponentViewController extends ChildController<ComponentLayout> {
|
|
|
64
64
|
presenter.setDefaultOptions(defaultOptions);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
@Nullable
|
|
68
|
+
@Override
|
|
69
|
+
public Animator getPushAnimations(Options appearingOptions) {
|
|
70
|
+
return this.presenter.getStatusBarPushAnimation(appearingOptions);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Nullable
|
|
74
|
+
@Override
|
|
75
|
+
public Animator getPopAnimations(Options appearingOptions, Options disappearingOptions) {
|
|
76
|
+
return this.presenter.getStatusBarPopAnimation(appearingOptions, disappearingOptions);
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
@Override
|
|
68
80
|
public ScrollEventListener getScrollEventListener() {
|
|
69
81
|
return perform(view, null, ComponentLayout::getScrollEventListener);
|