MCPcopy Create free account
hub / github.com/callstack/react-native-paper / CardExample

Function CardExample

example/src/Examples/CardExample.tsx:21–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19type Mode = 'elevated' | 'outlined' | 'contained';
20
21const CardExample = () => {
22 const { colors, isV3 } = useExampleTheme();
23 const [selectedMode, setSelectedMode] = React.useState('elevated' as Mode);
24 const [isSelected, setIsSelected] = React.useState(false);
25 const preferences = React.useContext(PreferencesContext);
26
27 const modes = isV3
28 ? ['elevated', 'outlined', 'contained']
29 : ['elevated', 'outlined'];
30
31 const TextComponent = isV3 ? Text : Paragraph;
32
33 return (
34 <ScreenWrapper contentContainerStyle={styles.content}>
35 <View style={styles.preference}>
36 {(modes as Mode[]).map((mode) => (
37 <Chip
38 key={mode}
39 selected={selectedMode === mode}
40 mode="outlined"
41 onPress={() => setSelectedMode(mode)}
42 style={styles.chip}
43 >
44 {mode}
45 </Chip>
46 ))}
47 </View>
48 <ScrollView
49 style={[styles.container, { backgroundColor: colors?.background }]}
50 contentContainerStyle={styles.content}
51 >
52 <Card style={styles.card} mode={selectedMode}>
53 <Card.Cover
54 source={require('../../assets/images/wrecked-ship.jpg')}
55 />
56 <Card.Title title="Abandoned Ship" />
57 <Card.Content>
58 <TextComponent variant="bodyMedium">
59 The Abandoned Ship is a wrecked ship located on Route 108 in
60 Hoenn, originally being a ship named the S.S. Cactus. The second
61 part of the ship can only be accessed by using Dive and contains
62 the Scanner.
63 </TextComponent>
64 </Card.Content>
65 </Card>
66 {isV3 && (
67 <Card style={styles.card} mode={selectedMode}>
68 <Card.Cover source={require('../../assets/images/bridge.jpg')} />
69 <Card.Title
70 title="Title variant"
71 subtitle="Subtitle variant"
72 titleVariant="headlineMedium"
73 subtitleVariant="bodyLarge"
74 />
75 <Card.Content>
76 <TextComponent variant="bodyMedium">
77 This is a card using title and subtitle with specified variants.
78 </TextComponent>

Callers

nothing calls this directly

Calls 1

useExampleThemeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…