Created
July 8, 2017 21:00
-
-
Save MovingGifts/f6e13e59a2f9e73143017e5727635219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import RX from 'reactxp' | |
import { VirtualListView, VirtualListViewItemInfo } from 'reactxp-virtuallistview'; | |
const _headerItemHeight = 20; | |
const _fruitItemHeight = 32; | |
const _headerItemTemplate = 'header'; | |
const _fruitItemTemplate = 'fruit'; | |
export default class FruitListView extends RX.Component { | |
constructor() { | |
super(); | |
this.state = { | |
items: [{ | |
key: 'header1', | |
height: _headerItemHeight, | |
text: 'Domestic Fruits', | |
template: _headerItemTemplate | |
}, { | |
key: 'bannana', | |
height: _fruitItemHeight, | |
text: 'Banana', | |
template: _fruitItemTemplate | |
}, | |
{ | |
key: 'apple', | |
height: _fruitItemHeight, | |
text: 'Apple', | |
template: _fruitItemTemplate | |
}] | |
}; | |
} | |
render() { | |
return ( | |
<VirtualListView | |
itemList={ this.state.items } | |
renderItem={ this._renderItem } | |
animateChanges={ true } | |
skipRenderIfItemUnchanged={ true } | |
/> | |
); | |
} | |
_renderItem(item) { | |
const viewStyle = RX.Styles.createViewStyle({ | |
height: item.height, | |
backgroundColor: item.template === _headerItemTemplate ? '#ddd' : '#fff', | |
alignItems: 'center' | |
}, false); | |
return ( | |
<RX.View style={ viewStyle }> | |
<RX.Text> | |
{ item.text } | |
</RX.Text> | |
</RX.View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment