@mrmeg/expo-ui 0.7.2 → 0.7.3
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/dist/components/BottomSheet.d.ts +92 -16
- package/dist/components/BottomSheet.js +203 -444
- package/dist/components/Dialog.js +16 -8
- package/dist/components/SegmentedControl.d.ts +52 -0
- package/dist/components/SegmentedControl.js +25 -0
- package/dist/components/Slider.d.ts +23 -3
- package/dist/components/Slider.js +26 -147
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tabs.js +10 -2
- package/dist/components/TextInput.d.ts +1 -1
- package/dist/components/TextInput.js +121 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/package.json +2 -1
- package/dist/components/BottomSheetKeyboard.d.ts +0 -7
- package/dist/components/BottomSheetKeyboard.js +0 -39
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { Animated, Keyboard, Platform } from "react-native";
|
|
3
|
-
// This value drives layout props (a sheet's `bottom`/`height`), which the
|
|
4
|
-
// native animation driver can't touch — so timings here must stay on the JS
|
|
5
|
-
// driver. It also means the value is a positive keyboard height (0 when
|
|
6
|
-
// hidden), letting consumers both lift and shrink the sheet from one source.
|
|
7
|
-
function animateKeyboardOffset(value, toValue, duration = 180) {
|
|
8
|
-
Animated.timing(value, {
|
|
9
|
-
toValue,
|
|
10
|
-
duration,
|
|
11
|
-
useNativeDriver: false,
|
|
12
|
-
}).start();
|
|
13
|
-
}
|
|
14
|
-
export function useBottomSheetKeyboardAnimation() {
|
|
15
|
-
const keyboardHeight = useRef(new Animated.Value(0)).current;
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (Platform.OS === "web") {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const showEvent = Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
|
|
21
|
-
const hideEvent = Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
|
|
22
|
-
const showSubscription = Keyboard.addListener(showEvent, (event) => {
|
|
23
|
-
animateKeyboardOffset(keyboardHeight, event.endCoordinates.height, event.duration || 180);
|
|
24
|
-
});
|
|
25
|
-
const hideSubscription = Keyboard.addListener(hideEvent, (event) => {
|
|
26
|
-
animateKeyboardOffset(keyboardHeight, 0, event.duration || 160);
|
|
27
|
-
});
|
|
28
|
-
return () => {
|
|
29
|
-
showSubscription.remove();
|
|
30
|
-
hideSubscription.remove();
|
|
31
|
-
};
|
|
32
|
-
}, [keyboardHeight]);
|
|
33
|
-
return { height: keyboardHeight };
|
|
34
|
-
}
|
|
35
|
-
export const BottomSheetKeyboardController = {
|
|
36
|
-
dismiss() {
|
|
37
|
-
Keyboard.dismiss();
|
|
38
|
-
},
|
|
39
|
-
};
|