@@ -59,6 +59,8 @@ type State = {|
59
59
empty : boolean ,
60
60
useFlatListItemComponent : boolean ,
61
61
fadingEdgeLength : number ,
62
+ onPressDisabled : boolean ,
63
+ textSelectable : boolean ,
62
64
| } ;
63
65
64
66
class FlatListExample extends React . PureComponent < Props , State > {
@@ -74,6 +76,8 @@ class FlatListExample extends React.PureComponent<Props, State> {
74
76
empty : false ,
75
77
useFlatListItemComponent : false ,
76
78
fadingEdgeLength : 0 ,
79
+ onPressDisabled : false ,
80
+ textSelectable : true ,
77
81
} ;
78
82
79
83
_onChangeFilterText = filterText => {
@@ -161,6 +165,16 @@ class FlatListExample extends React.PureComponent<Props, State> {
161
165
this . state . debug ,
162
166
this . _setBooleanValue ( 'debug' ) ,
163
167
) }
168
+ { renderSmallSwitchOption (
169
+ 'onPress Disabled' ,
170
+ this . state . onPressDisabled ,
171
+ this . _setBooleanValue ( 'onPressDisabled' ) ,
172
+ ) }
173
+ { renderSmallSwitchOption (
174
+ 'Text Selectable' ,
175
+ this . state . textSelectable ,
176
+ this . _setBooleanValue ( 'textSelectable' ) ,
177
+ ) }
164
178
{ renderSmallSwitchOption (
165
179
'Use FlatListItemComponent' ,
166
180
this . state . useFlatListItemComponent ,
@@ -236,6 +250,12 @@ class FlatListExample extends React.PureComponent<Props, State> {
236
250
data : state . data . concat ( genItemData ( 100 , state . data . length ) ) ,
237
251
} ) ) ;
238
252
} ;
253
+ _onPressCallback = ( ) => {
254
+ const { onPressDisabled} = this . state ;
255
+ const warning = ( ) => console . log ( 'onPress disabled' ) ;
256
+ const onPressAction = onPressDisabled ? warning : this . _pressItem ;
257
+ return onPressAction ;
258
+ } ;
239
259
_onRefresh = ( ) => Alert . alert ( 'onRefresh: nothing to refresh :P' ) ;
240
260
_renderItemComponent = ( ) => {
241
261
const flatListPropKey = this . state . useFlatListItemComponent
@@ -253,9 +273,10 @@ class FlatListExample extends React.PureComponent<Props, State> {
253
273
item = { item }
254
274
horizontal = { this . state . horizontal }
255
275
fixedHeight = { this . state . fixedHeight }
256
- onPress = { this . _pressItem }
276
+ onPress = { this . _onPressCallback ( ) }
257
277
onShowUnderlay = { separators . highlight }
258
278
onHideUnderlay = { separators . unhighlight }
279
+ textSelectable = { this . state . textSelectable }
259
280
/>
260
281
) ;
261
282
} ,
0 commit comments