@@ -6,10 +6,12 @@ import {
66 View ,
77 Text ,
88 TextInput ,
9- Switch
9+ Switch ,
10+ Image
1011} from 'react-native' ;
1112
1213import ModalSelector from 'react-native-modal-selector'
14+ import { countryList } from "./assets/CountryList" ;
1315
1416class SampleApp extends Component {
1517
@@ -87,9 +89,50 @@ class SampleApp extends Component {
8789 />
8890 }
8991 />
92+
93+ { /* Default mode: a clickable button will re rendered with FlatList */ }
94+ < ModalSelector
95+ data = { countryList }
96+ listType = "FLATLIST"
97+ keyExtractor = { ( x ) => x . name }
98+ labelExtractor = { ( x ) => x . name }
99+ initValue = "listType with FlatList"
100+ initValueTextStyle = { { color : "black" } }
101+ selectStyle = { { borderColor : "black" } }
102+ selectTextStyle = { { color : "blue" } }
103+ onChange = { option => { this . setState ( { textInputValue : option . name } ) } }
104+ componentExtractor = { ( option ) => < ListItem data = { option } /> }
105+ />
106+
107+ { /* Default mode: a clickable button will re rendered without FlatList */ }
108+ < ModalSelector
109+ data = { countryList }
110+ keyExtractor = { ( x ) => x . name }
111+ labelExtractor = { ( x ) => x . name }
112+ initValue = "listType without FlatList"
113+ initValueTextStyle = { { color : "black" } }
114+ selectStyle = { { borderColor : "black" } }
115+ selectTextStyle = { { color : "blue" } }
116+ onChange = { option => { this . setState ( { textInputValue : option . name } ) } }
117+ componentExtractor = { ( option ) => < ListItem data = { option } /> } />
118+
90119 </ View >
91120 ) ;
92121 }
93122}
94123
124+ const ListItem = ( { data } ) => {
125+ return (
126+ < View key = { data . number } style = { { flexDirection : "row" } } >
127+ < Image
128+ style = { { width : 26 , height : 26 , borderRadius : 13 } }
129+ resizeMode = "cover"
130+ source = { { uri : data . flag } }
131+ />
132+ < Text > { data . number } </ Text >
133+ < Text > { data . name } </ Text >
134+ </ View >
135+ ) ;
136+ } ;
137+
95138export default SampleApp ;
0 commit comments