uilib-native 4.5.2 → 4.5.3-snapshot.7095
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/android/build.gradle +5 -5
- package/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
- package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
- package/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.d.ts +4 -1
- package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +32 -9
- package/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.d.ts +3 -0
- package/components/Keyboard/KeyboardInput/KeyboardAccessoryView.d.ts +10 -0
- package/components/Keyboard/KeyboardInput/KeyboardAccessoryView.js +30 -4
- package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +19 -4
- package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +80 -6
- package/components/Keyboard/KeyboardTracking/KeyboardTrackingView/index.d.ts +2 -2
- package/components/Keyboard/index.d.ts +1 -1
- package/package.json +1 -1
- package/react-native.config.js +1 -3
- package/scripts/releaseNative.js +19 -5
- package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
- package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
- package/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
package/android/build.gradle
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
project.ext {
|
|
4
|
-
buildToolsVersion = rootProject.ext.has("buildToolsVersion") ? rootProject.ext.buildToolsVersion : '
|
|
5
|
-
minSdkVersion = rootProject.ext.has("minSdkVersion") ? rootProject.ext.minSdkVersion :
|
|
6
|
-
compileSdkVersion = rootProject.ext.has("compileSdkVersion") ? rootProject.ext.compileSdkVersion :
|
|
7
|
-
targetSdkVersion = rootProject.ext.has("targetSdkVersion") ? rootProject.ext.targetSdkVersion :
|
|
8
|
-
supportLibVersion = rootProject.ext.has("supportLibVersion") ? rootProject.ext.supportLibVersion : '
|
|
4
|
+
buildToolsVersion = rootProject.ext.has("buildToolsVersion") ? rootProject.ext.buildToolsVersion : '35.0.0'
|
|
5
|
+
minSdkVersion = rootProject.ext.has("minSdkVersion") ? rootProject.ext.minSdkVersion : 24
|
|
6
|
+
compileSdkVersion = rootProject.ext.has("compileSdkVersion") ? rootProject.ext.compileSdkVersion : 35
|
|
7
|
+
targetSdkVersion = rootProject.ext.has("targetSdkVersion") ? rootProject.ext.targetSdkVersion : 34
|
|
8
|
+
supportLibVersion = rootProject.ext.has("supportLibVersion") ? rootProject.ext.supportLibVersion : '28.0.0'
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
android {
|
|
@@ -6,7 +6,6 @@ import com.facebook.react.ReactPackage;
|
|
|
6
6
|
import com.wix.reactnativeuilib.dynamicfont.DynamicFontPackage;
|
|
7
7
|
import com.wix.reactnativeuilib.highlighterview.HighlighterViewPackage;
|
|
8
8
|
import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage;
|
|
9
|
-
import com.wix.reactnativeuilib.textinput.TextInputDelKeyHandlerPackage;
|
|
10
9
|
|
|
11
10
|
import java.util.Arrays;
|
|
12
11
|
import java.util.List;
|
|
@@ -23,7 +22,6 @@ public class UiLibPackageList {
|
|
|
23
22
|
return Arrays.asList(
|
|
24
23
|
new DynamicFontPackage(),
|
|
25
24
|
new HighlighterViewPackage(),
|
|
26
|
-
new TextInputDelKeyHandlerPackage(),
|
|
27
25
|
new KeyboardInputPackage(application)
|
|
28
26
|
);
|
|
29
27
|
}
|
package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java
CHANGED
|
@@ -8,12 +8,15 @@ import android.util.SizeF;
|
|
|
8
8
|
import android.view.View;
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.bridge.ReadableMap;
|
|
11
|
+
import com.facebook.react.bridge.UIManager;
|
|
11
12
|
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
12
13
|
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
13
14
|
import com.facebook.react.uimanager.SimpleViewManager;
|
|
14
15
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
16
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
15
17
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
16
18
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
19
|
+
import com.facebook.react.uimanager.common.UIManagerType;
|
|
17
20
|
|
|
18
21
|
import javax.annotation.Nullable;
|
|
19
22
|
|
|
@@ -75,33 +78,38 @@ class HighlighterViewManager extends SimpleViewManager<HighlighterView> {
|
|
|
75
78
|
|
|
76
79
|
@ReactProp(name = "highlightViewTag")
|
|
77
80
|
public void setHighlightViewTag(final HighlighterView view, Integer highlightViewTag) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
81
|
+
if (highlightViewTag != null) {
|
|
82
|
+
try {
|
|
83
|
+
UIManager uiManager = UIManagerHelper.getUIManagerForReactTag(context, highlightViewTag);
|
|
84
|
+
if (uiManager != null) {
|
|
85
|
+
final View resolvedView = uiManager.resolveView(highlightViewTag);
|
|
86
|
+
if (resolvedView != null) {
|
|
87
|
+
if (resolvedView.getWidth() == 0 || resolvedView.getHeight() == 0) {
|
|
88
|
+
resolvedView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
|
89
|
+
@Override
|
|
90
|
+
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
|
91
|
+
float width = right - left;
|
|
92
|
+
float height = bottom - top;
|
|
93
|
+
if (width > 0 && height > 0) {
|
|
94
|
+
setViewBasedHighlightFrame(view, resolvedView);
|
|
95
|
+
resolvedView.removeOnLayoutChangeListener(this);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
setViewBasedHighlightFrame(view, resolvedView);
|
|
96
101
|
}
|
|
97
|
-
}
|
|
102
|
+
} else {
|
|
103
|
+
Log.e("HighlighterView", "was not able to resolve highlightViewTag: " + highlightViewTag.toString());
|
|
104
|
+
}
|
|
98
105
|
} else {
|
|
99
|
-
|
|
106
|
+
Log.e("HighlighterView", "was not able to resolve get uiManager for highlightViewTag: " + highlightViewTag.toString());
|
|
100
107
|
}
|
|
108
|
+
} catch (IllegalViewOperationException e) {
|
|
109
|
+
Log.e("HighlighterView", "invalid highlightViewTag: " + highlightViewTag.toString() + " " + e.toString());
|
|
101
110
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
Log.e("HighlighterView", "invalid highlightViewTag: " + highlightViewTag.toString() + " " + e.toString());
|
|
111
|
+
} else {
|
|
112
|
+
Log.e("HighlighterView", "highlightViewTag is null");
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
|
package/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java
CHANGED
|
@@ -9,7 +9,7 @@ public class RuntimeUtils {
|
|
|
9
9
|
private static final Runnable sUIUpdateClosure = new Runnable() {
|
|
10
10
|
@Override
|
|
11
11
|
public void run() {
|
|
12
|
-
ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
|
|
12
|
+
// ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete();
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ import CustomKeyboardViewBase, { CustomKeyboardViewBaseProps } from '../CustomKe
|
|
|
3
3
|
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewBaseProps> {
|
|
4
4
|
static displayName: string;
|
|
5
5
|
componentDidUpdate(prevProps: CustomKeyboardViewBaseProps): Promise<void>;
|
|
6
|
-
|
|
6
|
+
getStyle: () => {
|
|
7
|
+
height: number | undefined;
|
|
8
|
+
};
|
|
9
|
+
render(): React.JSX.Element | null;
|
|
7
10
|
}
|
|
@@ -1,28 +1,51 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import TextInputKeyboardManager from "../TextInputKeyboardManager/TextInputKeyboardManager.android";
|
|
2
|
+
import { Keyboard, View } from 'react-native';
|
|
4
3
|
import KeyboardRegistry from "../KeyboardRegistry";
|
|
5
4
|
import CustomKeyboardViewBase from "../CustomKeyboardViewBase";
|
|
6
|
-
const CustomKeyboardViewNativeAndroid = requireNativeComponent('CustomKeyboardViewNativeTemp');
|
|
7
5
|
export default class CustomKeyboardView extends CustomKeyboardViewBase {
|
|
8
6
|
static displayName = 'IGNORE';
|
|
9
7
|
async componentDidUpdate(prevProps) {
|
|
10
8
|
const {
|
|
11
|
-
component
|
|
9
|
+
component,
|
|
10
|
+
inputRef,
|
|
11
|
+
shouldFocus,
|
|
12
|
+
onKeyboardDismiss
|
|
12
13
|
} = this.props;
|
|
13
|
-
if (prevProps.component !== component
|
|
14
|
-
|
|
14
|
+
if (prevProps.component !== component) {
|
|
15
|
+
if (!component) {
|
|
16
|
+
if (shouldFocus) {
|
|
17
|
+
if (inputRef?.current) {
|
|
18
|
+
inputRef.current.focus?.();
|
|
19
|
+
} else {
|
|
20
|
+
inputRef?.focus?.();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
Keyboard.dismiss();
|
|
25
|
+
}
|
|
26
|
+
onKeyboardDismiss?.();
|
|
15
27
|
}
|
|
16
28
|
super.componentDidUpdate(prevProps);
|
|
17
29
|
}
|
|
30
|
+
getStyle = () => {
|
|
31
|
+
const {
|
|
32
|
+
keyboardHeight
|
|
33
|
+
} = this.props;
|
|
34
|
+
return {
|
|
35
|
+
height: keyboardHeight
|
|
36
|
+
};
|
|
37
|
+
};
|
|
18
38
|
render() {
|
|
19
39
|
const {
|
|
20
40
|
component,
|
|
21
41
|
initialProps
|
|
22
42
|
} = this.props;
|
|
23
43
|
const KeyboardComponent = component && KeyboardRegistry.getKeyboard(component);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
if (!KeyboardComponent) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return <View style={this.getStyle()}>
|
|
48
|
+
<KeyboardComponent {...initialProps} />
|
|
49
|
+
</View>;
|
|
27
50
|
}
|
|
28
51
|
}
|
|
@@ -3,6 +3,9 @@ import { EventSubscription } from 'react-native';
|
|
|
3
3
|
export type CustomKeyboardViewBaseProps = {
|
|
4
4
|
inputRef?: any;
|
|
5
5
|
initialProps?: any;
|
|
6
|
+
keyboardHeight?: number;
|
|
7
|
+
onKeyboardDismiss?: () => void;
|
|
8
|
+
shouldFocus?: boolean;
|
|
6
9
|
component?: string;
|
|
7
10
|
onItemSelected?: (component?: string, args?: any) => void;
|
|
8
11
|
onRequestShowKeyboard?: (keyboardId: string) => void;
|
|
@@ -58,9 +58,16 @@ declare class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps
|
|
|
58
58
|
allowHitsOutsideBounds: boolean;
|
|
59
59
|
scrollBehavior: any;
|
|
60
60
|
};
|
|
61
|
+
static currentId: number;
|
|
61
62
|
customInputControllerEventsSubscriber: any;
|
|
62
63
|
trackingViewRef: any;
|
|
64
|
+
subscription: any;
|
|
65
|
+
id: number;
|
|
63
66
|
constructor(props: KeyboardAccessoryViewProps);
|
|
67
|
+
state: {
|
|
68
|
+
keyboardHeight: number;
|
|
69
|
+
shouldFocus: boolean;
|
|
70
|
+
};
|
|
64
71
|
componentWillUnmount(): void;
|
|
65
72
|
onContainerComponentHeightChanged(event: LayoutChangeEvent): void;
|
|
66
73
|
onAndroidBackPressed(): boolean;
|
|
@@ -69,6 +76,9 @@ declare class KeyboardAccessoryView extends Component<KeyboardAccessoryViewProps
|
|
|
69
76
|
registerAndroidBackHandler(): void;
|
|
70
77
|
processInitialProps(): any;
|
|
71
78
|
scrollToStart(): void;
|
|
79
|
+
onKeyboardHeightChange: (keyboardHeight: number) => void;
|
|
80
|
+
onDismiss: () => void;
|
|
81
|
+
onKeyboardDismiss: () => void;
|
|
72
82
|
render(): React.JSX.Element;
|
|
73
83
|
}
|
|
74
84
|
export default KeyboardAccessoryView;
|
|
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|
|
2
2
|
import { StyleSheet, Platform, NativeModules, NativeEventEmitter, DeviceEventEmitter, processColor, BackHandler } from 'react-native';
|
|
3
3
|
import KeyboardTrackingView from "../KeyboardTracking/KeyboardTrackingView";
|
|
4
4
|
import CustomKeyboardView from "./CustomKeyboardView";
|
|
5
|
-
import KeyboardUtils from "./utils/KeyboardUtils";
|
|
5
|
+
import KeyboardUtils, { KeyboardHeightListener } from "./utils/KeyboardUtils";
|
|
6
6
|
const IsIOS = Platform.OS === 'ios';
|
|
7
7
|
const IsAndroid = Platform.OS === 'android';
|
|
8
8
|
/**
|
|
@@ -20,9 +20,11 @@ class KeyboardAccessoryView extends Component {
|
|
|
20
20
|
allowHitsOutsideBounds: false,
|
|
21
21
|
scrollBehavior: KeyboardTrackingView.scrollBehaviors.FIXED_OFFSET
|
|
22
22
|
};
|
|
23
|
+
static currentId = 0;
|
|
23
24
|
|
|
24
25
|
// TODO: fix
|
|
25
26
|
|
|
27
|
+
id = ++KeyboardAccessoryView.currentId;
|
|
26
28
|
constructor(props) {
|
|
27
29
|
super(props);
|
|
28
30
|
this.onContainerComponentHeightChanged = this.onContainerComponentHeightChanged.bind(this);
|
|
@@ -33,12 +35,16 @@ class KeyboardAccessoryView extends Component {
|
|
|
33
35
|
this.registerForKeyboardResignedEvent();
|
|
34
36
|
this.registerAndroidBackHandler();
|
|
35
37
|
}
|
|
38
|
+
state = {
|
|
39
|
+
keyboardHeight: 0,
|
|
40
|
+
shouldFocus: true
|
|
41
|
+
};
|
|
36
42
|
componentWillUnmount() {
|
|
37
43
|
if (this.customInputControllerEventsSubscriber) {
|
|
38
44
|
this.customInputControllerEventsSubscriber.remove();
|
|
39
45
|
}
|
|
40
46
|
if (IsAndroid) {
|
|
41
|
-
|
|
47
|
+
this.subscription.remove();
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
onContainerComponentHeightChanged(event) {
|
|
@@ -87,7 +93,7 @@ class KeyboardAccessoryView extends Component {
|
|
|
87
93
|
}
|
|
88
94
|
registerAndroidBackHandler() {
|
|
89
95
|
if (IsAndroid) {
|
|
90
|
-
BackHandler.addEventListener('hardwareBackPress', this.onAndroidBackPressed);
|
|
96
|
+
this.subscription = BackHandler.addEventListener('hardwareBackPress', this.onAndroidBackPressed);
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
processInitialProps() {
|
|
@@ -106,7 +112,26 @@ class KeyboardAccessoryView extends Component {
|
|
|
106
112
|
this.trackingViewRef.scrollToStart();
|
|
107
113
|
}
|
|
108
114
|
}
|
|
115
|
+
onKeyboardHeightChange = keyboardHeight => {
|
|
116
|
+
this.setState({
|
|
117
|
+
keyboardHeight
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
onDismiss = () => {
|
|
121
|
+
this.setState({
|
|
122
|
+
shouldFocus: false
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
onKeyboardDismiss = () => {
|
|
126
|
+
this.setState({
|
|
127
|
+
shouldFocus: true
|
|
128
|
+
});
|
|
129
|
+
};
|
|
109
130
|
render() {
|
|
131
|
+
const {
|
|
132
|
+
keyboardHeight,
|
|
133
|
+
shouldFocus
|
|
134
|
+
} = this.state;
|
|
110
135
|
const {
|
|
111
136
|
renderContent,
|
|
112
137
|
kbInputRef,
|
|
@@ -117,8 +142,9 @@ class KeyboardAccessoryView extends Component {
|
|
|
117
142
|
...others
|
|
118
143
|
} = this.props;
|
|
119
144
|
return <KeyboardTrackingView {...others} scrollBehavior={scrollBehavior} ref={r => this.trackingViewRef = r} style={styles.trackingToolbarContainer} onLayout={this.onContainerComponentHeightChanged}>
|
|
145
|
+
<KeyboardHeightListener id={`${this.id}`} onDismiss={this.onDismiss} onKeyboardHeightChange={this.onKeyboardHeightChange} />
|
|
120
146
|
<>{renderContent?.()}</>
|
|
121
|
-
<CustomKeyboardView inputRef={kbInputRef} component={kbComponent} initialProps={this.processInitialProps()} onItemSelected={onItemSelected} onRequestShowKeyboard={onRequestShowKeyboard} useSafeArea={others.useSafeArea} />
|
|
147
|
+
<CustomKeyboardView keyboardHeight={keyboardHeight} shouldFocus={shouldFocus} onKeyboardDismiss={this.onKeyboardDismiss} inputRef={kbInputRef} component={kbComponent} initialProps={this.processInitialProps()} onItemSelected={onItemSelected} onRequestShowKeyboard={onRequestShowKeyboard} useSafeArea={others.useSafeArea} />
|
|
122
148
|
</KeyboardTrackingView>;
|
|
123
149
|
}
|
|
124
150
|
}
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description: util for managing the keyboard.
|
|
3
|
-
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardInput/KeyboardInputViewScreen.js
|
|
4
|
-
*/
|
|
5
1
|
export default class KeyboardUtils {
|
|
6
2
|
static displayName: string;
|
|
3
|
+
private static listeners;
|
|
4
|
+
private static addListener;
|
|
5
|
+
private static removeListener;
|
|
7
6
|
/**
|
|
8
7
|
* Used to dismiss (close) the keyboard.
|
|
9
8
|
*/
|
|
10
9
|
static dismiss: () => void;
|
|
11
10
|
}
|
|
11
|
+
interface KeyboardHeightProps {
|
|
12
|
+
id: string;
|
|
13
|
+
onDismiss: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const useKeyboardHeight: ({ id, onDismiss }: KeyboardHeightProps) => {
|
|
16
|
+
keyboardHeight: number;
|
|
17
|
+
isKeyboardVisible: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface KeyboardHeightListenerProps {
|
|
20
|
+
id: string;
|
|
21
|
+
onDismiss: () => void;
|
|
22
|
+
onKeyboardHeightChange?: (height: number) => void;
|
|
23
|
+
onKeyboardVisibilityChange?: (isKeyboardVisible: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
declare const KeyboardHeightListener: ({ id, onDismiss, onKeyboardHeightChange, onKeyboardVisibilityChange }: KeyboardHeightListenerProps) => null;
|
|
26
|
+
export { useKeyboardHeight, KeyboardHeightListener };
|
|
@@ -1,17 +1,91 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Keyboard, Platform } from 'react-native';
|
|
2
3
|
import TextInputKeyboardManager from "../TextInputKeyboardManager";
|
|
4
|
+
const IS_IOS = Platform.OS === 'ios';
|
|
5
|
+
const DEFAULT_KEYBOARD_HEIGHT = IS_IOS ? 216 : 312; // TODO: verify this value for iOS
|
|
3
6
|
|
|
4
|
-
/**
|
|
5
|
-
* @description: util for managing the keyboard.
|
|
6
|
-
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/keyboardInput/KeyboardInputViewScreen.js
|
|
7
|
-
*/
|
|
8
7
|
export default class KeyboardUtils {
|
|
9
8
|
static displayName = 'KeyboardUtils';
|
|
9
|
+
static listeners = {};
|
|
10
|
+
static addListener = (id, onDismiss) => {
|
|
11
|
+
if (id && onDismiss && !KeyboardUtils.listeners[id]) {
|
|
12
|
+
KeyboardUtils.listeners[id] = onDismiss;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
static removeListener = id => {
|
|
16
|
+
if (id && KeyboardUtils.listeners[id]) {
|
|
17
|
+
delete KeyboardUtils.listeners[id];
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* Used to dismiss (close) the keyboard.
|
|
12
23
|
*/
|
|
13
24
|
static dismiss = () => {
|
|
14
25
|
Keyboard.dismiss();
|
|
15
26
|
TextInputKeyboardManager.dismissKeyboard();
|
|
27
|
+
Object.keys(KeyboardUtils.listeners).forEach(key => {
|
|
28
|
+
KeyboardUtils.listeners[key]();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const useKeyboardHeight = ({
|
|
33
|
+
id,
|
|
34
|
+
onDismiss
|
|
35
|
+
}) => {
|
|
36
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
37
|
+
const [keyboardHeight, setKeyboardHeight] = useState(DEFAULT_KEYBOARD_HEIGHT);
|
|
38
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
39
|
+
const keyboardDidShow = useCallback(e => {
|
|
40
|
+
if (!isInitialized) {
|
|
41
|
+
setIsInitialized(true);
|
|
42
|
+
setKeyboardHeight(e.endCoordinates.height);
|
|
43
|
+
}
|
|
44
|
+
setIsVisible(true);
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, []);
|
|
47
|
+
const keyboardDidHide = useCallback(() => {
|
|
48
|
+
setIsVisible(false);
|
|
49
|
+
}, []);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', keyboardDidShow);
|
|
52
|
+
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', keyboardDidHide);
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
KeyboardUtils.addListener(id, onDismiss);
|
|
55
|
+
return () => {
|
|
56
|
+
keyboardDidShowListener.remove();
|
|
57
|
+
keyboardDidHideListener.remove();
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
KeyboardUtils.removeListener(id);
|
|
60
|
+
};
|
|
61
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
|
+
}, []);
|
|
63
|
+
return {
|
|
64
|
+
keyboardHeight,
|
|
65
|
+
isKeyboardVisible: isVisible
|
|
16
66
|
};
|
|
17
|
-
}
|
|
67
|
+
};
|
|
68
|
+
const KeyboardHeightListener = ({
|
|
69
|
+
id,
|
|
70
|
+
onDismiss,
|
|
71
|
+
onKeyboardHeightChange,
|
|
72
|
+
onKeyboardVisibilityChange
|
|
73
|
+
}) => {
|
|
74
|
+
const {
|
|
75
|
+
keyboardHeight,
|
|
76
|
+
isKeyboardVisible
|
|
77
|
+
} = useKeyboardHeight({
|
|
78
|
+
id,
|
|
79
|
+
onDismiss
|
|
80
|
+
});
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
onKeyboardHeightChange?.(keyboardHeight);
|
|
83
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
+
}, [keyboardHeight]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
onKeyboardVisibilityChange?.(isKeyboardVisible);
|
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
}, [isKeyboardVisible]);
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
export { useKeyboardHeight, KeyboardHeightListener };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ViewStyle, ViewProps } from 'react-native';
|
|
2
|
+
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
3
|
declare const SCROLL_BEHAVIORS: {
|
|
4
4
|
NONE: any;
|
|
5
5
|
SCROLL_TO_BOTTOM_INVERTED_ONLY: any;
|
|
@@ -72,7 +72,7 @@ export type KeyboardTrackingViewProps = ViewProps & {
|
|
|
72
72
|
*/
|
|
73
73
|
usesBottomTabs?: boolean;
|
|
74
74
|
ref?: any;
|
|
75
|
-
style?: ViewStyle
|
|
75
|
+
style?: StyleProp<ViewStyle>;
|
|
76
76
|
children?: React.ReactChild | React.ReactChild[];
|
|
77
77
|
};
|
|
78
78
|
declare const _default: React.ForwardRefExoticComponent<Omit<KeyboardTrackingViewProps, "ref"> & React.RefAttributes<unknown>> & {
|
|
@@ -26,7 +26,7 @@ declare const _default: {
|
|
|
26
26
|
useSafeArea?: boolean | undefined;
|
|
27
27
|
usesBottomTabs?: boolean | undefined;
|
|
28
28
|
ref?: any;
|
|
29
|
-
style?: import("react-native/types").ViewStyle
|
|
29
|
+
style?: import("react-native/types").StyleProp<import("react-native/types").ViewStyle>;
|
|
30
30
|
children?: import("react").ReactChild | import("react").ReactChild[] | undefined;
|
|
31
31
|
} & {
|
|
32
32
|
offset?: number | undefined;
|
package/package.json
CHANGED
package/react-native.config.js
CHANGED
|
@@ -10,11 +10,9 @@ module.exports = {
|
|
|
10
10
|
sourceDir: './android/',
|
|
11
11
|
packageImportPath: `import com.wix.reactnativeuilib.dynamicfont.DynamicFontPackage;
|
|
12
12
|
import com.wix.reactnativeuilib.highlighterview.HighlighterViewPackage;
|
|
13
|
-
import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage
|
|
14
|
-
import com.wix.reactnativeuilib.textinput.TextInputDelKeyHandlerPackage;`,
|
|
13
|
+
import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage;`,
|
|
15
14
|
packageInstance: `new DynamicFontPackage(),
|
|
16
15
|
new HighlighterViewPackage(),
|
|
17
|
-
new TextInputDelKeyHandlerPackage(),
|
|
18
16
|
new KeyboardInputPackage(getApplication())`
|
|
19
17
|
}
|
|
20
18
|
}
|
package/scripts/releaseNative.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
const exec = require('shell-utils').exec;
|
|
2
2
|
const p = require('path');
|
|
3
3
|
|
|
4
|
+
// Export buildkite variables for Release build
|
|
5
|
+
// We cast toString() because function returns 'object'
|
|
6
|
+
const IS_SNAPSHOT = process.env.BUILDKITE_MESSAGE?.match(/^snapshot$/i);
|
|
7
|
+
const VERSION_TAG = IS_SNAPSHOT ? 'snapshot' : 'latest';
|
|
8
|
+
|
|
4
9
|
function run() {
|
|
5
10
|
if (!validateEnv()) {
|
|
6
11
|
return;
|
|
7
12
|
}
|
|
8
13
|
|
|
14
|
+
const packageJsonVersion = require('../package.json').version;
|
|
9
15
|
const currentPublished = findCurrentPublishedVersion();
|
|
10
|
-
const
|
|
11
|
-
|
|
16
|
+
const newVersion = IS_SNAPSHOT
|
|
17
|
+
? `${packageJsonVersion}-snapshot.${process.env.BUILDKITE_BUILD_NUMBER}`
|
|
18
|
+
: packageJsonVersion;
|
|
19
|
+
|
|
20
|
+
console.log('Debug releaseNative', 'packageJsonVersion=', packageJsonVersion, 'currentPublished=', currentPublished, 'newVersion=', newVersion);
|
|
12
21
|
|
|
13
|
-
if (currentPublished !==
|
|
22
|
+
if (currentPublished !== packageJsonVersion) {
|
|
14
23
|
createNpmRc();
|
|
15
24
|
versionTagAndPublish(currentPublished, newVersion);
|
|
16
25
|
}
|
|
@@ -49,8 +58,13 @@ function tryPublishAndTag(version) {
|
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
function tagAndPublish(newVersion) {
|
|
52
|
-
console.log(`
|
|
53
|
-
exec.execSync(`npm
|
|
61
|
+
console.log(`trying to publish ${newVersion}...`);
|
|
62
|
+
exec.execSync(`npm --no-git-tag-version version ${newVersion}`);
|
|
63
|
+
exec.execSync(`npm publish --tag ${VERSION_TAG}`);
|
|
64
|
+
if (!IS_SNAPSHOT) {
|
|
65
|
+
exec.execSync(`git tag -a ${newVersion} -m "${newVersion}"`);
|
|
66
|
+
}
|
|
67
|
+
exec.execSyncSilent(`git push deploy ${newVersion} || true`);
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
run();
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.highlighterview;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import androidx.annotation.Nullable;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
7
|
-
import com.facebook.react.uimanager.UIBlock;
|
|
8
|
-
import com.facebook.react.uimanager.UIManagerModule;
|
|
9
|
-
import com.facebook.react.uimanager.UIViewOperationQueue;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* ¯\_(ツ)_/¯
|
|
13
|
-
*/
|
|
14
|
-
public class ReactHacks {
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* {@link NativeViewHierarchyManager} is used to resolve a native view by RN tag ({@link NativeViewHierarchyManager#resolveView}). The only way of obtaining it is by
|
|
18
|
-
* posting {@link UIBlock} which can take a noticeable amount of time to execute.
|
|
19
|
-
*/
|
|
20
|
-
@Nullable
|
|
21
|
-
public static NativeViewHierarchyManager getNativeViewHierarchyManager(UIManagerModule uiManager) {
|
|
22
|
-
try {
|
|
23
|
-
UIViewOperationQueue mOperationsQueue = (UIViewOperationQueue) ReflectionUtils.getDeclaredField(uiManager.getUIImplementation(), "mOperationsQueue");
|
|
24
|
-
return (NativeViewHierarchyManager) ReflectionUtils.getDeclaredField(mOperationsQueue, "mNativeViewHierarchyManager");
|
|
25
|
-
} catch (Exception e) {
|
|
26
|
-
e.printStackTrace();
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.highlighterview;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import androidx.annotation.Nullable;
|
|
5
|
-
|
|
6
|
-
import java.lang.reflect.Field;
|
|
7
|
-
|
|
8
|
-
class ReflectionUtils {
|
|
9
|
-
|
|
10
|
-
@Nullable
|
|
11
|
-
static Object getDeclaredField(Object obj, String fieldName) {
|
|
12
|
-
try {
|
|
13
|
-
Field f = getField(obj.getClass(), fieldName);
|
|
14
|
-
if (f == null) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
f.setAccessible(true);
|
|
18
|
-
return f.get(obj);
|
|
19
|
-
} catch (Exception e) {
|
|
20
|
-
e.printStackTrace();
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private static Field getField(Class clazz, String name) {
|
|
26
|
-
try {
|
|
27
|
-
return clazz.getDeclaredField(name);
|
|
28
|
-
} catch (NoSuchFieldException nsfe) {
|
|
29
|
-
return getField(clazz.getSuperclass(), name);
|
|
30
|
-
} catch (Exception e) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.textinput;
|
|
2
|
-
|
|
3
|
-
import android.text.Editable;
|
|
4
|
-
import android.text.InputType;
|
|
5
|
-
import android.text.method.KeyListener;
|
|
6
|
-
import android.view.KeyEvent;
|
|
7
|
-
import android.view.View;
|
|
8
|
-
|
|
9
|
-
class DefaultKeyListener implements KeyListener {
|
|
10
|
-
@Override
|
|
11
|
-
public int getInputType() {
|
|
12
|
-
return InputType.TYPE_NULL;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@Override
|
|
16
|
-
public boolean onKeyDown(View view, Editable text, int keyCode, KeyEvent event) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@Override
|
|
21
|
-
public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
public boolean onKeyOther(View view, Editable text, KeyEvent event) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Override
|
|
31
|
-
public void clearMetaKeyState(View view, Editable content, int states) {
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.textinput;
|
|
2
|
-
|
|
3
|
-
import android.text.Editable;
|
|
4
|
-
import android.text.method.KeyListener;
|
|
5
|
-
import android.view.KeyEvent;
|
|
6
|
-
import android.view.View;
|
|
7
|
-
|
|
8
|
-
import com.facebook.react.bridge.Arguments;
|
|
9
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
11
|
-
|
|
12
|
-
public class KeyListenerProxy implements KeyListener {
|
|
13
|
-
|
|
14
|
-
final private ReactApplicationContext mContext;
|
|
15
|
-
final private KeyListener mKeyListener;
|
|
16
|
-
|
|
17
|
-
KeyListenerProxy(ReactApplicationContext context, KeyListener keyListener) {
|
|
18
|
-
mContext = context;
|
|
19
|
-
mKeyListener = keyListener == null ? new DefaultKeyListener() : keyListener;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Override
|
|
23
|
-
public int getInputType() {
|
|
24
|
-
return mKeyListener.getInputType();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@Override
|
|
28
|
-
public boolean onKeyDown(View view, Editable text, int keyCode, KeyEvent event) {
|
|
29
|
-
return mKeyListener.onKeyDown(view, text, keyCode, event);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Override
|
|
33
|
-
public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
|
|
34
|
-
if (keyCode == KeyEvent.KEYCODE_DEL) {
|
|
35
|
-
emitBackspacePressEvent();
|
|
36
|
-
}
|
|
37
|
-
return mKeyListener.onKeyUp(view, text, keyCode, event);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@Override
|
|
41
|
-
public boolean onKeyOther(View view, Editable text, KeyEvent event) {
|
|
42
|
-
return mKeyListener.onKeyOther(view, text, event);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Override
|
|
46
|
-
public void clearMetaKeyState(View view, Editable content, int states) {
|
|
47
|
-
mKeyListener.clearMetaKeyState(view, content, states);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private void emitBackspacePressEvent() {
|
|
51
|
-
mContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onBackspacePress", Arguments.createMap());
|
|
52
|
-
}
|
|
53
|
-
}
|
package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.textinput;
|
|
2
|
-
|
|
3
|
-
import android.util.Log;
|
|
4
|
-
import android.view.View;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
-
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
10
|
-
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
11
|
-
import com.facebook.react.uimanager.UIBlock;
|
|
12
|
-
import com.facebook.react.uimanager.UIManagerModule;
|
|
13
|
-
import com.facebook.react.views.textinput.ReactEditText;
|
|
14
|
-
|
|
15
|
-
public class TextInputDelKeyHandlerModule extends ReactContextBaseJavaModule {
|
|
16
|
-
|
|
17
|
-
private final static String REACT_CLASS = "TextInputDelKeyHandler";
|
|
18
|
-
|
|
19
|
-
TextInputDelKeyHandlerModule(ReactApplicationContext reactContext) {
|
|
20
|
-
super(reactContext);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@Override
|
|
24
|
-
public String getName() {
|
|
25
|
-
return REACT_CLASS;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@ReactMethod
|
|
29
|
-
public void register(final Integer textInputTag) {
|
|
30
|
-
final ReactApplicationContext reactContext = this.getReactApplicationContext();
|
|
31
|
-
final UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
|
|
32
|
-
|
|
33
|
-
uiManager.addUIBlock(new UIBlock() {
|
|
34
|
-
public void execute(NativeViewHierarchyManager viewHierarchyManager) {
|
|
35
|
-
Log.d("ReactNativeJS","registering tag = " + textInputTag);
|
|
36
|
-
final View view;
|
|
37
|
-
try {
|
|
38
|
-
view = viewHierarchyManager.resolveView(textInputTag);
|
|
39
|
-
} catch (IllegalViewOperationException e) {
|
|
40
|
-
Log.d("ReactNativeJS","no view for tag = " + textInputTag);
|
|
41
|
-
e.printStackTrace();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
final ReactEditText editText = ViewUtils.getEditTextInView(view);
|
|
45
|
-
|
|
46
|
-
if (editText != null) {
|
|
47
|
-
Log.d("ReactNativeJS","has editText for tag = " + textInputTag);
|
|
48
|
-
final KeyListenerProxy keyListenerProxy = new KeyListenerProxy(reactContext, editText.getKeyListener());
|
|
49
|
-
editText.setKeyListener(keyListenerProxy);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.textinput;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage;
|
|
4
|
-
import com.facebook.react.bridge.JavaScriptModule;
|
|
5
|
-
import com.facebook.react.bridge.NativeModule;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
8
|
-
|
|
9
|
-
import java.util.Arrays;
|
|
10
|
-
import java.util.Collections;
|
|
11
|
-
import java.util.List;
|
|
12
|
-
|
|
13
|
-
public class TextInputDelKeyHandlerPackage implements ReactPackage {
|
|
14
|
-
@Override
|
|
15
|
-
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
16
|
-
return Arrays.<NativeModule>asList(new TextInputDelKeyHandlerModule(reactContext));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// @Override
|
|
20
|
-
// public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
21
|
-
// return Collections.emptyList();
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
|
-
@Override
|
|
25
|
-
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
26
|
-
return Collections.emptyList();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
package com.wix.reactnativeuilib.textinput;
|
|
2
|
-
|
|
3
|
-
import android.view.View;
|
|
4
|
-
import android.view.ViewGroup;
|
|
5
|
-
|
|
6
|
-
import androidx.annotation.Nullable;
|
|
7
|
-
|
|
8
|
-
import com.facebook.react.views.textinput.ReactEditText;
|
|
9
|
-
|
|
10
|
-
class ViewUtils {
|
|
11
|
-
|
|
12
|
-
@Nullable
|
|
13
|
-
static ReactEditText getEditTextInView(View view) {
|
|
14
|
-
if (view == null) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (view instanceof ReactEditText) {
|
|
19
|
-
return (ReactEditText) view;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (view instanceof ViewGroup) {
|
|
23
|
-
final ViewGroup viewGroup = (ViewGroup) view;
|
|
24
|
-
|
|
25
|
-
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
|
26
|
-
final View child = viewGroup.getChildAt(i);
|
|
27
|
-
final View childView = getEditTextInView(child);
|
|
28
|
-
|
|
29
|
-
if (childView != null) {
|
|
30
|
-
return (ReactEditText) childView;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|