1- import React , { Component } from 'react'
1+ import React , { Component , Fragment } from 'react' ;
22import PropTypes from 'prop-types'
33import { View , TouchableOpacity , Text , Image } from 'react-native'
44import Icon from 'react-native-vector-icons/MaterialIcons'
@@ -32,6 +32,9 @@ class RowSubItem extends Component {
3232 if ( this . props . mergedStyles !== nextProps . mergedStyles ) {
3333 return true
3434 }
35+ if ( this . props . customSubItemContentRenderer !== nextProps . customSubItemContentRenderer ) {
36+ return true
37+ }
3538 return false
3639 }
3740
@@ -77,24 +80,72 @@ class RowSubItem extends Component {
7780 ) : null
7881 }
7982
80- render ( ) {
83+ _renderDefaultContent = ( ) => {
8184 const {
8285 mergedStyles,
8386 mergedColors,
8487 subItem,
88+ selectChildren,
89+ selectedIconOnLeft,
90+ iconKey,
8591 uniqueKey,
92+ displayKey,
93+ itemNumberOfLines,
8694 subItemFontFamily,
95+ highlightedChildren,
96+ } = this . props ;
97+
98+ const itemSelected = this . _itemSelected ( ) ;
99+ const highlightChild = ! selectChildren && highlightedChildren . includes ( subItem [ uniqueKey ] )
100+
101+ return (
102+ < Fragment >
103+ { selectedIconOnLeft && this . _renderSelectedIcon ( ) }
104+
105+ { iconKey && subItem [ iconKey ] && (
106+ < ItemIcon
107+ iconKey = { iconKey }
108+ icon = { subItem [ iconKey ] }
109+ style = { mergedStyles . itemIconStyle }
110+ />
111+ ) }
112+ < Text
113+ numberOfLines = { itemNumberOfLines }
114+ style = { [
115+ {
116+ flex : 1 ,
117+ color : subItem . disabled ? mergedColors . disabled : mergedColors . subText ,
118+ } ,
119+ subItemFontFamily ,
120+ mergedStyles . subItemText ,
121+ ( itemSelected || highlightChild ) && mergedStyles . selectedSubItemText ,
122+ ] }
123+ >
124+ { subItem [ displayKey ] }
125+ </ Text >
126+ { ! selectedIconOnLeft && this . _renderSelectedIcon ( ) }
127+ </ Fragment >
128+ )
129+ }
130+
131+ render ( ) {
132+ const {
133+ mergedStyles,
134+ mergedColors,
135+ subItem,
136+ uniqueKey,
87137 selectChildren,
88- selectedIconOnLeft,
89138 highlightedChildren,
90- itemNumberOfLines ,
91- displayKey ,
92- iconKey ,
139+
140+ // OL_CHANGE
141+ customSubItemContentRenderer : CustomSubItemContentRenderer
93142 } = this . props
94143
95144 const highlightChild = ! selectChildren && highlightedChildren . includes ( subItem [ uniqueKey ] )
96145 const itemSelected = this . _itemSelected ( )
97146
147+ const shouldUseCostumeRender = CustomSubItemContentRenderer ? true : false ;
148+
98149 return (
99150 < View
100151 key = { subItem [ uniqueKey ] }
@@ -120,30 +171,9 @@ class RowSubItem extends Component {
120171 ( itemSelected || highlightChild ) && mergedStyles . selectedSubItem ,
121172 ] }
122173 >
123- { selectedIconOnLeft && this . _renderSelectedIcon ( ) }
174+ { ! shouldUseCostumeRender && this . _renderDefaultContent ( ) }
124175
125- { iconKey && subItem [ iconKey ] && (
126- < ItemIcon
127- iconKey = { iconKey }
128- icon = { subItem [ iconKey ] }
129- style = { mergedStyles . itemIconStyle }
130- />
131- ) }
132- < Text
133- numberOfLines = { itemNumberOfLines }
134- style = { [
135- {
136- flex : 1 ,
137- color : subItem . disabled ? mergedColors . disabled : mergedColors . subText ,
138- } ,
139- subItemFontFamily ,
140- mergedStyles . subItemText ,
141- ( itemSelected || highlightChild ) && mergedStyles . selectedSubItemText ,
142- ] }
143- >
144- { subItem [ displayKey ] }
145- </ Text >
146- { ! selectedIconOnLeft && this . _renderSelectedIcon ( ) }
176+ { shouldUseCostumeRender && < CustomSubItemContentRenderer subItem = { subItem } isItemSelected = { this . _itemSelected } /> }
147177 </ TouchableOpacity >
148178 </ View >
149179 )
0 commit comments