-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec09520
commit 55877da
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
packages/rn-tester/js/examples/FlatList/FlatList-nested.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import React from "react"; | ||
import { | ||
SafeAreaView, | ||
View, | ||
FlatList, | ||
StyleSheet, | ||
Text, | ||
StatusBar, | ||
} from "react-native"; | ||
|
||
const DATA = [ | ||
{ | ||
id: "bd7acbea-c1b1-46c2-aed5-3ad53abb28ba", | ||
title: "First Item", | ||
}, | ||
{ | ||
id: "3ac68afc-c605-48d3-a4f8-fbd91aa97f63", | ||
title: "Second Item", | ||
}, | ||
{ | ||
id: "58694a0f-3da1-471f-bd96-145571e29d72", | ||
title: "Third Item", | ||
}, | ||
{ | ||
id: "bd7acbea-c1b1-46c2-aed5-3ad53abb8bbb", | ||
title: "Fourth Item", | ||
}, | ||
{ | ||
id: "3ac68afc-c605-48d3-a4f8-fbd91aa97676", | ||
title: "Fifth Item", | ||
}, | ||
{ | ||
id: "58694a0f-3da1-471f-bd96-145571e27234", | ||
title: "Sixth Item", | ||
}, | ||
{ | ||
id: "58694a0f-3da1-471f-bd96-145571e29234", | ||
title: "Seven Item", | ||
}, | ||
{ | ||
id: "58694a0f-3da1-471f-bd96-145571429234", | ||
title: "Eight Item", | ||
}, | ||
{ | ||
id: "58694a0f-3da1-471f-bd96-115571429234", | ||
title: "Nine Item", | ||
}, | ||
{ | ||
id: "58694a0f-3da1-471f-bd96-1155h1429234", | ||
title: "Ten Item", | ||
}, | ||
]; | ||
|
||
const Item = ({ title }) => ( | ||
<View style={styles.item}> | ||
<Text style={styles.title}>{title}</Text> | ||
</View> | ||
); | ||
|
||
const renderItem = ({ item }) => <Item title={item.title} />; | ||
|
||
const renderFlatList = ({ item }) => ( | ||
<View> | ||
<Text>Flatlist {item}</Text> | ||
<FlatList renderItem={renderItem} horizontal data={DATA} /> | ||
</View> | ||
); | ||
|
||
const FlatListNested = () => { | ||
return ( | ||
<SafeAreaView style={styles.container}> | ||
<FlatList | ||
data={[1, 2, 3]} | ||
renderItem={renderFlatList} | ||
keyExtractor={(item) => item.toString()} | ||
/> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
marginTop: StatusBar.currentHeight || 0, | ||
}, | ||
item: { | ||
backgroundColor: "#f9c2ff", | ||
padding: 20, | ||
marginVertical: 8, | ||
marginHorizontal: 16, | ||
}, | ||
title: { | ||
fontSize: 16, | ||
}, | ||
}); | ||
|
||
exports.title = "FlatList Nested"; | ||
exports.testTitle = "Test accessibility announcement in nested flatlist"; | ||
exports.category = "ListView"; | ||
exports.documentationURL = "https://reactnative.dev/docs/flatlist"; | ||
exports.description = "Nested flatlist example"; | ||
exports.examples = [ | ||
{ | ||
title: "FlatList Nested example", | ||
render: function (): React.Element<typeof FlatListNested> { | ||
return <FlatListNested />; | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters