Skip to content

Commit b36a44c

Browse files
committed
added new examples
1 parent 9f94e84 commit b36a44c

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed
104 KB
Loading

example/src/App.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import { SafeAreaView } from 'react-native';
1111
import InstagramExploreExample from './InstagramExploreExample';
1212
import PinterestExample from './PinterestHomeExample';
1313
import GridBoardExamplePage from './GridBoardExample';
14+
import TileGrid from './TileGrid';
1415

1516
type ScreenName =
1617
| 'Landing'
17-
| 'FlexGrid'
1818
| 'InstagramExplore'
1919
| 'Pinterest'
20+
| 'TileGrid'
2021
| 'GridBoardExample';
2122

2223
interface LandingProps {
@@ -26,6 +27,13 @@ interface LandingProps {
2627
const Landing = ({ onNavigate }: LandingProps) => {
2728
return (
2829
<View style={styles.container}>
30+
<TouchableOpacity
31+
onPress={() => onNavigate('TileGrid')}
32+
style={styles.button}
33+
>
34+
<Text style={styles.text}>TileGrid Example </Text>
35+
</TouchableOpacity>
36+
2937
<TouchableOpacity
3038
onPress={() => onNavigate('InstagramExplore')}
3139
style={styles.button}
@@ -78,6 +86,7 @@ const App = () => {
7886
return (
7987
<SafeAreaView style={styles.safeAreaContainer}>
8088
{currentScreen === 'Landing' && <Landing onNavigate={navigate} />}
89+
{currentScreen === 'TileGrid' && <TileGrid />}
8190
{currentScreen === 'InstagramExplore' && <InstagramExploreExample />}
8291
{currentScreen === 'Pinterest' && <PinterestExample />}
8392
{currentScreen === 'GridBoardExample' && <GridBoardExamplePage />}

example/src/TileGrid.tsx

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* eslint-disable react-native/no-inline-styles */
2+
3+
import React from 'react';
4+
import { Text, TouchableOpacity, View } from 'react-native';
5+
import { ResponsiveGrid } from 'react-native-flexible-grid';
6+
7+
export default function TileGrid() {
8+
const data = [
9+
{
10+
widthRatio: 1,
11+
heightRatio: 1,
12+
},
13+
{
14+
widthRatio: 1,
15+
heightRatio: 1,
16+
},
17+
{
18+
widthRatio: 1,
19+
heightRatio: 2,
20+
},
21+
{
22+
widthRatio: 1,
23+
heightRatio: 3,
24+
},
25+
{
26+
widthRatio: 2,
27+
heightRatio: 1,
28+
},
29+
{
30+
widthRatio: 3,
31+
heightRatio: 1,
32+
},
33+
];
34+
35+
return (
36+
<View
37+
style={{
38+
flex: 1,
39+
}}
40+
>
41+
<ResponsiveGrid
42+
maxItemsPerColumn={4}
43+
data={data}
44+
renderItem={(item, _) => (
45+
<TouchableOpacity
46+
style={{
47+
backgroundColor: 'white',
48+
justifyContent: 'center',
49+
alignItems: 'center',
50+
width: '100%',
51+
height: '100%',
52+
padding: 2,
53+
}}
54+
onPress={() => {
55+
console.log(item.text, 'pressed');
56+
}}
57+
>
58+
<View
59+
style={{
60+
width: '100%',
61+
height: '100%',
62+
backgroundColor: '#FFA502',
63+
justifyContent: 'center',
64+
alignItems: 'center',
65+
borderRadius: 5,
66+
}}
67+
>
68+
<Text
69+
style={{
70+
color: 'white',
71+
fontSize: 20,
72+
}}
73+
>
74+
{item.text}
75+
</Text>
76+
</View>
77+
</TouchableOpacity>
78+
)}
79+
/>
80+
</View>
81+
);
82+
}

0 commit comments

Comments
 (0)