Skip to content

Commit eb7f975

Browse files
committed
chore: update scrollview & flatlist examples
1 parent 36f0542 commit eb7f975

3 files changed

Lines changed: 33 additions & 27 deletions

File tree

example/shared/src/components/Footer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Platform, StyleSheet, Text, View, type PressableProps, Pressable } from 'react-native';
22
import { useSafeAreaInsets } from 'react-native-safe-area-context';
33

4-
import { DARK_GRAY, FOOTER_HEIGHT } from '../utils';
4+
import { DARK_GRAY, FOOTER_HEIGHT, SPACING } from '../utils';
55

66
const isIPad = Platform.OS === 'ios' && Platform.isPad;
77

@@ -28,10 +28,10 @@ const styles = StyleSheet.create({
2828
},
2929
container: {
3030
height: FOOTER_HEIGHT,
31-
alignItems: 'center',
32-
justifyContent: 'center',
31+
padding: SPACING,
3332
},
3433
text: {
34+
textAlign: 'center',
3535
color: '#fff',
3636
},
3737
});

example/shared/src/components/sheets/ScrollViewSheet.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { TrueSheet, type TrueSheetProps } from '@lodev09/react-native-true-sheet
1313
import { BORDER_RADIUS, DARK, FOOTER_HEIGHT, GAP, LIGHT_GRAY, SPACING, times } from '../../utils';
1414
import { Footer } from '../Footer';
1515
import { Header } from '../Header';
16+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
17+
import { Input } from '../Input';
1618

1719
interface ScrollViewSheetProps extends TrueSheetProps {}
1820

@@ -40,6 +42,7 @@ const HeavyItem = ({ index }: { index: number }) => {
4042
};
4143

4244
export const ScrollViewSheet = forwardRef<TrueSheet, ScrollViewSheetProps>((props, ref) => {
45+
const insets = useSafeAreaInsets();
4346
return (
4447
<TrueSheet
4548
ref={ref}
@@ -48,13 +51,24 @@ export const ScrollViewSheet = forwardRef<TrueSheet, ScrollViewSheetProps>((prop
4851
scrollable
4952
backgroundColor={Platform.select({ android: DARK })}
5053
header={<Header />}
51-
footer={<Footer />}
54+
footer={
55+
<Footer>
56+
<Input />
57+
</Footer>
58+
}
5259
onDidDismiss={() => console.log('Sheet ScrollView dismissed!')}
5360
onDidPresent={() => console.log(`Sheet ScrollView presented!`)}
5461
{...props}
5562
>
56-
<ScrollView nestedScrollEnabled contentContainerStyle={styles.content} indicatorStyle="black">
57-
{times(500, (i) => (
63+
<ScrollView
64+
nestedScrollEnabled
65+
contentContainerStyle={[
66+
styles.content,
67+
{ paddingBottom: FOOTER_HEIGHT + SPACING + insets.bottom },
68+
]}
69+
indicatorStyle="black"
70+
>
71+
{times(20, (i) => (
5872
<HeavyItem key={i} index={i} />
5973
))}
6074
</ScrollView>

example/shared/src/screens/ModalScreen.tsx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { useRef, useState, useEffect } from 'react';
22
import { Modal, StyleSheet, Text, View } from 'react-native';
33
import { TrueSheet, TrueSheetProvider } from '@lodev09/react-native-true-sheet';
44

5-
import { BLUE, DARK, DARK_BLUE, DARK_GRAY, GAP, LIGHT_GRAY, SPACING } from '../utils';
6-
import { Button, DemoContent, Input, Spacer } from '../components';
7-
import { PromptSheet, FlatListSheet } from '../components/sheets';
5+
import { BLUE, DARK_GRAY, GAP, LIGHT_GRAY, SPACING } from '../utils';
6+
import { Button, Input, Spacer } from '../components';
7+
import { PromptSheet, FlatListSheet, ScrollViewSheet } from '../components/sheets';
88

99
export interface ModalScreenProps {
1010
onNavigateToTest?: () => void;
@@ -16,12 +16,13 @@ export const ModalScreen = ({ onNavigateToTest, onDismiss }: ModalScreenProps) =
1616
const flatlistSheet = useRef<TrueSheet>(null);
1717

1818
const [modalVisible, setModalVisible] = useState(false);
19-
const modalSimpleSheet = useRef<TrueSheet>(null);
19+
const modalPromptSheet = useRef<TrueSheet>(null);
2020
const modalFlatlistSheet = useRef<TrueSheet>(null);
21+
const modalScrollViewSheet = useRef<TrueSheet>(null);
2122

2223
useEffect(() => {
2324
if (modalVisible) {
24-
modalSimpleSheet.current?.present();
25+
modalPromptSheet.current?.present();
2526
}
2627
}, [modalVisible]);
2728

@@ -58,23 +59,18 @@ export const ModalScreen = ({ onNavigateToTest, onDismiss }: ModalScreenProps) =
5859
This is a React Native Modal. You can present TrueSheets from here!
5960
</Text>
6061
</View>
61-
<Button text="Simple Sheet" onPress={() => modalSimpleSheet.current?.present()} />
62+
<Button text="Prompt Sheet" onPress={() => modalPromptSheet.current?.present()} />
63+
<Button
64+
text="ScrollView Sheet"
65+
onPress={() => modalScrollViewSheet.current?.present()}
66+
/>
6267
<Button text="FlatList Sheet" onPress={() => modalFlatlistSheet.current?.present()} />
6368
<Spacer />
6469
<Button text="Close Modal" onPress={() => setModalVisible(false)} />
6570

66-
<TrueSheet
67-
ref={modalSimpleSheet}
68-
detents={['auto']}
69-
// initialDetentIndex={0}
70-
dimmed={false}
71-
style={styles.simpleSheet}
72-
backgroundColor={DARK}
73-
>
74-
<DemoContent color={DARK_BLUE} text="Simple Sheet" />
75-
<Button text="Dismiss" onPress={() => modalSimpleSheet.current?.dismiss()} />
76-
</TrueSheet>
71+
<PromptSheet ref={modalPromptSheet} />
7772
<FlatListSheet ref={modalFlatlistSheet} />
73+
<ScrollViewSheet ref={modalScrollViewSheet} />
7874
</View>
7975
</TrueSheetProvider>
8076
</Modal>
@@ -98,10 +94,6 @@ const styles = StyleSheet.create({
9894
padding: SPACING,
9995
gap: GAP,
10096
},
101-
simpleSheet: {
102-
padding: SPACING,
103-
gap: GAP,
104-
},
10597
heading: {
10698
marginBottom: SPACING * 2,
10799
},

0 commit comments

Comments
 (0)