Skip to content

Commit 453a701

Browse files
author
Simar
committed
alternative to section header (detail in desc)
This basically serves the purpose of the original header prop in ListView. This header does not stick to the screen as the user scrolls down the list. The current sectionHeaderView does stick to the screen.
1 parent 1eb01a4 commit 453a701

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

GiftedListView.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ var GiftedListView = React.createClass({
4040
refreshable: true,
4141
refreshableViewHeight: 50,
4242
refreshableDistance: 40,
43+
headerView: null,
4344
sectionHeaderView: null,
4445
withSections: false,
4546
onFetch(page, callback, options) { callback([]); },
@@ -63,6 +64,7 @@ var GiftedListView = React.createClass({
6364
refreshable: React.PropTypes.bool,
6465
refreshableViewHeight: React.PropTypes.number,
6566
refreshableDistance: React.PropTypes.number,
67+
headerView: React.PropTypes.func,
6668
sectionHeaderView: React.PropTypes.func,
6769
withSections: React.PropTypes.bool,
6870
onFetch: React.PropTypes.func,
@@ -126,14 +128,23 @@ var GiftedListView = React.createClass({
126128
</TouchableHighlight>
127129
);
128130
},
131+
headerView() {
132+
if(this.state.paginationStatus==='firstLoad' || !this.props.headerView){
133+
return(<View />);
134+
}
135+
return this.props.headerView();
136+
},
129137
refreshableFetchingView() {
130138
if (this.props.refreshableFetchingView) {
131139
return this.props.refreshableFetchingView();
132140
}
133141

134142
return (
135-
<View style={[this.defaultStyles.refreshableView, this.props.customStyles.refreshableView]}>
136-
<GiftedSpinner />
143+
<View>
144+
<View style={[this.defaultStyles.refreshableView, this.props.customStyles.refreshableView]}>
145+
<GiftedSpinner />
146+
</View>
147+
{this.headerView()}
137148
</View>
138149
);
139150
},
@@ -143,10 +154,13 @@ var GiftedListView = React.createClass({
143154
}
144155

145156
return (
146-
<View style={[this.defaultStyles.refreshableView, this.props.customStyles.refreshableView]}>
147-
<Text style={[this.defaultStyles.actionsLabel, this.props.customStyles.actionsLabel]}>
148-
149-
</Text>
157+
<View>
158+
<View style={[this.defaultStyles.refreshableView, this.props.customStyles.refreshableView]}>
159+
<Text style={[this.defaultStyles.actionsLabel, this.props.customStyles.actionsLabel]}>
160+
161+
</Text>
162+
</View>
163+
{this.headerView()}
150164
</View>
151165
);
152166
},
@@ -157,10 +171,13 @@ var GiftedListView = React.createClass({
157171

158172
if (Platform.OS !== 'android') {
159173
return (
160-
<View style={[this.defaultStyles.refreshableView, this.props.customStyles.refreshableView]}>
161-
<Text style={[this.defaultStyles.actionsLabel, this.props.customStyles.actionsLabel]}>
162-
163-
</Text>
174+
<View>
175+
<View style={[this.defaultStyles.refreshableView, this.props.customStyles.refreshableView]}>
176+
<Text style={[this.defaultStyles.actionsLabel, this.props.customStyles.actionsLabel]}>
177+
178+
</Text>
179+
</View>
180+
{this.headerView()}
164181
</View>
165182
);
166183
} else {

0 commit comments

Comments
 (0)