feat: fixes and formatter
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
import { AnimatePresence, Motion } from "@legendapp/motion";
|
||||
import { useKeyboard } from "@react-native-community/hooks";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { Keyboard, StyleSheet } from "react-native";
|
||||
import { AnimatePresence, Motion } from '@legendapp/motion'
|
||||
import { useKeyboard } from '@react-native-community/hooks'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Keyboard, StyleSheet } from 'react-native'
|
||||
|
||||
import BottomSheet from "./BottomSheet";
|
||||
import BottomSheet from './BottomSheet'
|
||||
|
||||
import useLayoutType from "../hooks/useLayoutType";
|
||||
import { Palette } from "../styles";
|
||||
import useLayoutType from '../hooks/useLayoutType'
|
||||
import { Palette } from '../styles'
|
||||
|
||||
export default ({
|
||||
children,
|
||||
bottomSheetRef,
|
||||
snapPoints = ["25%", "50%"],
|
||||
snapPoints = ['25%', '50%'],
|
||||
handleStyle = {},
|
||||
...rest
|
||||
}) => {
|
||||
const [currentSnapPointIndex, setCurrentSnapPointIndex] = useState(0);
|
||||
const [currentSnapPointIndex, setCurrentSnapPointIndex] = useState(0)
|
||||
|
||||
const { keyboardShown = false } = useKeyboard();
|
||||
const { isWeb } = useLayoutType();
|
||||
const { keyboardShown = false } = useKeyboard()
|
||||
const { isWeb } = useLayoutType()
|
||||
|
||||
const handleSheetChanges = useCallback((index) => {
|
||||
setCurrentSnapPointIndex(index);
|
||||
setCurrentSnapPointIndex(index)
|
||||
|
||||
if (index <= 0) {
|
||||
Keyboard.dismiss();
|
||||
Keyboard.dismiss()
|
||||
}
|
||||
}, []);
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (bottomSheetRef.current && !isWeb && currentSnapPointIndex > 0) {
|
||||
if (keyboardShown) {
|
||||
bottomSheetRef.current.expand();
|
||||
bottomSheetRef.current.expand()
|
||||
} else {
|
||||
bottomSheetRef.current.snapToIndex(1);
|
||||
bottomSheetRef.current.snapToIndex(1)
|
||||
}
|
||||
}
|
||||
}, [keyboardShown]);
|
||||
}, [keyboardShown])
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -47,7 +47,7 @@ export default ({
|
||||
onPress={() => bottomSheetRef?.current?.close()}
|
||||
>
|
||||
<Motion.View
|
||||
key={"A"}
|
||||
key={'A'}
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: Palette.black,
|
||||
@@ -57,10 +57,10 @@ export default ({
|
||||
exit={{ opacity: 0 }}
|
||||
transition={{
|
||||
default: {
|
||||
type: "spring",
|
||||
type: 'spring',
|
||||
},
|
||||
opacity: {
|
||||
type: "timing",
|
||||
type: 'timing',
|
||||
},
|
||||
}}
|
||||
></Motion.View>
|
||||
@@ -83,5 +83,5 @@ export default ({
|
||||
{children}
|
||||
</BottomSheet>
|
||||
</>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user