diff --git a/example/src/components/contactList/ContactList.tsx b/example/src/components/contactList/ContactList.tsx index 7ab6f2751..76287b25f 100644 --- a/example/src/components/contactList/ContactList.tsx +++ b/example/src/components/contactList/ContactList.tsx @@ -20,6 +20,7 @@ export interface ContactListProps { count?: number; style?: ViewStyle; onItemPress?: () => void; + onRefresh?: () => void; } const keyExtractor = (item: any, index: number) => `${item.name}.${index}`; @@ -29,6 +30,7 @@ const handleGetCount = (data: any[]) => data.length; const ContactList = ({ type, count = 25, + onRefresh, style, onItemPress, }: ContactListProps) => { @@ -97,6 +99,8 @@ const ContactList = ({ return ( { - title: string; - headerStyle?: ViewStyle; -} - -const ContactListContainerComponent = ({ - count, - type, - title, - headerStyle: _headerStyle, - onItemPress, -}: ContactListContainerProps) => { - const headerStyle = useMemo( - () => [styles.headerContainer, _headerStyle], - [_headerStyle] - ); - return ( - <> - - {title} - - - - ); -}; - -const styles = StyleSheet.create({ - title: { - fontSize: 36, - lineHeight: 46, - fontWeight: '800', - }, - headerContainer: { - padding: 24, - backgroundColor: 'white', - zIndex: 99999, - }, -}); - -const ContactListContainer = memo(ContactListContainerComponent); - -export default ContactListContainer; diff --git a/example/src/components/contactListContainer/index.ts b/example/src/components/contactListContainer/index.ts deleted file mode 100644 index 67c9f0411..000000000 --- a/example/src/components/contactListContainer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ContactListContainer'; diff --git a/example/src/components/handle/Handle.tsx b/example/src/components/customHandle/CustomHandle.tsx similarity index 80% rename from example/src/components/handle/Handle.tsx rename to example/src/components/customHandle/CustomHandle.tsx index e416b78b2..bb16e45fd 100644 --- a/example/src/components/handle/Handle.tsx +++ b/example/src/components/customHandle/CustomHandle.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import { StyleProp, StyleSheet, ViewStyle } from 'react-native'; +import { StyleProp, StyleSheet, Text, ViewStyle } from 'react-native'; import { BottomSheetHandleProps } from '@gorhom/bottom-sheet'; import Animated, { Extrapolate, @@ -10,11 +10,16 @@ import Animated, { import { toRad } from 'react-native-redash'; import { transformOrigin } from '../../utilities/transformOrigin'; -interface HandleProps extends BottomSheetHandleProps { +interface CustomHandleProps extends BottomSheetHandleProps { + title: string; style?: StyleProp; } -const Handle: React.FC = ({ style, animatedIndex }) => { +const CustomHandle: React.FC = ({ + title, + style, + animatedIndex, +}) => { //#region animations const indicatorTransformOriginY = useDerivedValue(() => @@ -23,7 +28,7 @@ const Handle: React.FC = ({ style, animatedIndex }) => { //#endregion //#region styles - const containerStyle = useMemo(() => [styles.header, style], [style]); + const containerStyle = useMemo(() => [styles.container, style], [style]); const containerAnimatedStyle = useAnimatedStyle(() => { const borderTopRadius = interpolate( animatedIndex.value, @@ -100,23 +105,25 @@ const Handle: React.FC = ({ style, animatedIndex }) => { + {title} ); }; -export default Handle; +export default CustomHandle; const styles = StyleSheet.create({ - header: { + container: { alignContent: 'center', alignItems: 'center', - justifyContent: 'center', - backgroundColor: 'white', - paddingVertical: 14, + paddingBottom: 12, + paddingHorizontal: 16, borderBottomWidth: 1, - borderBottomColor: '#fff', + borderBottomColor: 'rgba(0,0,0,0.125)', + zIndex: 99999, }, indicator: { + marginTop: 10, position: 'absolute', width: 10, height: 4, @@ -130,4 +137,11 @@ const styles = StyleSheet.create({ borderTopEndRadius: 2, borderBottomEndRadius: 2, }, + title: { + marginTop: 26, + fontSize: 20, + lineHeight: 20, + textAlign: 'center', + fontWeight: 'bold', + }, }); diff --git a/example/src/components/customHandle/index.ts b/example/src/components/customHandle/index.ts new file mode 100644 index 000000000..c9d91b754 --- /dev/null +++ b/example/src/components/customHandle/index.ts @@ -0,0 +1 @@ +export { default } from './CustomHandle'; diff --git a/example/src/components/handle/index.ts b/example/src/components/handle/index.ts deleted file mode 100644 index 1b3992686..000000000 --- a/example/src/components/handle/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Handle'; diff --git a/example/src/components/headerHandle/HeaderHandle.tsx b/example/src/components/headerHandle/HeaderHandle.tsx new file mode 100644 index 000000000..64770713f --- /dev/null +++ b/example/src/components/headerHandle/HeaderHandle.tsx @@ -0,0 +1,49 @@ +import React, { memo } from 'react'; +import { StyleSheet, Text } from 'react-native'; +import { + BottomSheetHandle, + BottomSheetHandleProps, +} from '@gorhom/bottom-sheet'; + +interface HeaderHandleProps extends BottomSheetHandleProps { + children?: string | React.ReactNode | React.ReactNode[]; +} + +const HeaderHandle = ({ children, ...rest }: HeaderHandleProps) => { + return ( + + {typeof children === 'string' ? ( + {children} + ) : ( + children + )} + + ); +}; + +const styles = StyleSheet.create({ + container: { + paddingBottom: 12, + paddingHorizontal: 16, + borderBottomWidth: 1, + borderBottomColor: 'rgba(0,0,0,0.125)', + zIndex: 99999, + }, + title: { + marginTop: 16, + fontSize: 20, + lineHeight: 20, + textAlign: 'center', + fontWeight: 'bold', + }, + indicator: { + height: 4, + opacity: 0.5, + }, +}); + +export default memo(HeaderHandle); diff --git a/example/src/components/headerHandle/index.ts b/example/src/components/headerHandle/index.ts new file mode 100644 index 000000000..036408a2c --- /dev/null +++ b/example/src/components/headerHandle/index.ts @@ -0,0 +1 @@ +export { default } from './HeaderHandle'; diff --git a/example/src/screens/advanced/BackdropExample.tsx b/example/src/screens/advanced/BackdropExample.tsx index 0eb829481..45039012c 100644 --- a/example/src/screens/advanced/BackdropExample.tsx +++ b/example/src/screens/advanced/BackdropExample.tsx @@ -2,7 +2,8 @@ import React, { useCallback, useMemo, useRef, useState } from 'react'; import { View, StyleSheet } from 'react-native'; import BottomSheet, { BottomSheetBackdrop } from '@gorhom/bottom-sheet'; import Button from '../../components/button'; -import ContactListContainer from '../../components/contactListContainer'; +import ContactList from '../../components/contactList'; +import HeaderHandle from '../../components/headerHandle'; const BackdropExample = () => { // state @@ -45,6 +46,10 @@ const BackdropExample = () => { ), [backdropPressBehavior] ); + const renderHeaderHandle = useCallback( + props => , + [] + ); return (