uilib-native 5.0.0-snapshot.7212 → 5.0.0-snapshot.7216
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/components/SafeArea/SafeAreaInsetsManager.js +1 -4
- package/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
- package/components/SafeArea/SafeAreaSpacerView.js +11 -8
- package/components/SafeArea/index.d.ts +10 -0
- package/components/SafeArea/index.js +11 -0
- package/components/index.d.ts +1 -1
- package/components/index.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import _isEqual from "lodash/isEqual";
|
|
|
2
2
|
import _remove from "lodash/remove";
|
|
3
3
|
import _forEach from "lodash/forEach";
|
|
4
4
|
/* eslint no-underscore-dangle: 0 */
|
|
5
|
-
import { NativeModules, DeviceEventEmitter
|
|
5
|
+
import { NativeModules, DeviceEventEmitter } from 'react-native';
|
|
6
6
|
let SafeAreaInsetsCache = null;
|
|
7
7
|
class SafeAreaInsetsManager {
|
|
8
8
|
_defaultInsets = {
|
|
@@ -45,9 +45,6 @@ class SafeAreaInsetsManager {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
setupEventListener() {
|
|
48
|
-
if (Platform.OS !== 'ios') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
48
|
try {
|
|
52
49
|
// Use DeviceEventEmitter instead of NativeEventEmitter to avoid getConstants
|
|
53
50
|
DeviceEventEmitter.addListener('SafeAreaInsetsDidChangeEvent', data => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ViewStyle } from 'react-native';
|
|
2
|
+
import { ViewStyle, StyleProp } from 'react-native';
|
|
3
3
|
export type SafeAreaSpacerViewProps = {
|
|
4
|
-
style?: ViewStyle
|
|
4
|
+
style?: StyleProp<ViewStyle>;
|
|
5
5
|
};
|
|
6
6
|
declare const SafeAreaSpacerView: {
|
|
7
7
|
({ style }: SafeAreaSpacerViewProps): React.JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useCallback, useEffect } from 'react';
|
|
1
|
+
import React, { useState, useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import { View, Dimensions } from 'react-native';
|
|
3
3
|
import SafeAreaInsetsManager from "./SafeAreaInsetsManager";
|
|
4
4
|
const SafeAreaSpacerView = ({
|
|
@@ -10,6 +10,7 @@ const SafeAreaSpacerView = ({
|
|
|
10
10
|
bottom: 0,
|
|
11
11
|
right: 0
|
|
12
12
|
});
|
|
13
|
+
const [componentHeight, setComponentHeight] = useState(0);
|
|
13
14
|
const [spacerHeight, setSpacerHeight] = useState(0);
|
|
14
15
|
useEffect(() => {
|
|
15
16
|
const getSafeAreaInsets = async () => {
|
|
@@ -43,22 +44,24 @@ const SafeAreaSpacerView = ({
|
|
|
43
44
|
const {
|
|
44
45
|
y
|
|
45
46
|
} = event.nativeEvent.layout;
|
|
47
|
+
setComponentHeight(y);
|
|
48
|
+
}, []);
|
|
49
|
+
useEffect(() => {
|
|
46
50
|
const screenHeight = Dimensions.get('window').height;
|
|
47
51
|
let height = 0;
|
|
48
52
|
// Check if positioned within safe area bounds
|
|
49
|
-
if (
|
|
53
|
+
if (componentHeight < safeAreaInsets.top) {
|
|
50
54
|
height = safeAreaInsets.top;
|
|
51
|
-
} else if (
|
|
55
|
+
} else if (componentHeight > screenHeight - safeAreaInsets.bottom) {
|
|
52
56
|
height = safeAreaInsets.bottom;
|
|
53
57
|
}
|
|
54
58
|
if (height !== spacerHeight) {
|
|
55
59
|
setSpacerHeight(height);
|
|
56
60
|
}
|
|
57
|
-
}, [safeAreaInsets, spacerHeight]);
|
|
58
|
-
const spacerStyle = {
|
|
59
|
-
height: spacerHeight
|
|
60
|
-
|
|
61
|
-
};
|
|
61
|
+
}, [componentHeight, safeAreaInsets, spacerHeight]);
|
|
62
|
+
const spacerStyle = useMemo(() => [{
|
|
63
|
+
height: spacerHeight
|
|
64
|
+
}, style], [spacerHeight, style]);
|
|
62
65
|
return <View style={spacerStyle} onLayout={handleLayout} />;
|
|
63
66
|
};
|
|
64
67
|
SafeAreaSpacerView.displayName = 'SafeAreaSpacerView';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewStyle, StyleProp } from 'react-native';
|
|
3
|
+
export type SafeAreaSpacerViewProps = {
|
|
4
|
+
style?: StyleProp<ViewStyle>;
|
|
5
|
+
};
|
|
6
|
+
declare const SafeAreaSpacerView: {
|
|
7
|
+
({ style }: SafeAreaSpacerViewProps): React.JSX.Element;
|
|
8
|
+
displayName: string;
|
|
9
|
+
};
|
|
10
|
+
export default SafeAreaSpacerView;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Platform } from 'react-native';
|
|
3
|
+
import SafeAreaSpacerViewIos from "./SafeAreaSpacerView";
|
|
4
|
+
const isIOS = Platform.OS === 'ios';
|
|
5
|
+
const SafeAreaSpacerView = ({
|
|
6
|
+
style
|
|
7
|
+
}) => {
|
|
8
|
+
return isIOS ? <SafeAreaSpacerViewIos style={style} /> : <View style={style} />;
|
|
9
|
+
};
|
|
10
|
+
SafeAreaSpacerView.displayName = 'SafeAreaSpacerView';
|
|
11
|
+
export default SafeAreaSpacerView;
|
package/components/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DynamicFonts, { FontExtension } from './DynamicFonts';
|
|
2
2
|
import HighlighterOverlayView from './HighlighterOverlayView';
|
|
3
|
-
import SafeAreaSpacerView from './SafeArea
|
|
3
|
+
import SafeAreaSpacerView from './SafeArea';
|
|
4
4
|
import SafeAreaInsetsManager from './SafeArea/SafeAreaInsetsManager';
|
|
5
5
|
import Keyboard, { KeyboardTrackingViewProps, KeyboardAccessoryViewProps } from './Keyboard';
|
|
6
6
|
export { DynamicFonts, FontExtension, HighlighterOverlayView, SafeAreaSpacerView, SafeAreaInsetsManager, Keyboard, KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
|
package/components/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import DynamicFonts, { FontExtension } from "./DynamicFonts";
|
|
2
2
|
import HighlighterOverlayView from "./HighlighterOverlayView";
|
|
3
|
-
import SafeAreaSpacerView from "./SafeArea
|
|
3
|
+
import SafeAreaSpacerView from "./SafeArea";
|
|
4
4
|
import SafeAreaInsetsManager from "./SafeArea/SafeAreaInsetsManager";
|
|
5
5
|
import Keyboard, { KeyboardTrackingViewProps, KeyboardAccessoryViewProps } from "./Keyboard";
|
|
6
6
|
export { DynamicFonts, FontExtension, HighlighterOverlayView, SafeAreaSpacerView, SafeAreaInsetsManager, Keyboard, KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
|
package/package.json
CHANGED