File tree Expand file tree Collapse file tree 3 files changed +92
-1
lines changed Expand file tree Collapse file tree 3 files changed +92
-1
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,13 @@ import { SafeAreaView } from 'react-native';
1111import InstagramExploreExample from './InstagramExploreExample' ;
1212import PinterestExample from './PinterestHomeExample' ;
1313import GridBoardExamplePage from './GridBoardExample' ;
14+ import TileGrid from './TileGrid' ;
1415
1516type ScreenName =
1617 | 'Landing'
17- | 'FlexGrid'
1818 | 'InstagramExplore'
1919 | 'Pinterest'
20+ | 'TileGrid'
2021 | 'GridBoardExample' ;
2122
2223interface LandingProps {
@@ -26,6 +27,13 @@ interface LandingProps {
2627const 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 /> }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments