Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 659d257

Browse files
authored
Merge pull request #700 from erkarl/sticky-list-headers
Make list headers sticky
2 parents 498f765 + 6f26669 commit 659d257

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

src/component/list.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class List extends Component {
5050
ref={component => (this.list = component)}
5151
dataSource={this.dataSource}
5252
renderHeader={this.props.renderHeader}
53+
stickyHeaderIndices={[0]}
5354
renderRow={this.props.renderItem}
5455
enableEmptySections={true}
5556
/>

src/view/channel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const ChannelList = ({ store, channel }) => {
108108
<ListContent>
109109
<List
110110
data={channels}
111-
renderHeader={() => <ChannelListHeader />}
111+
renderHeader={ChannelListHeader}
112112
renderItem={item => (
113113
<ChannelListItem
114114
ch={item}
@@ -259,10 +259,13 @@ const hStyles = StyleSheet.create({
259259
color: color.greyListHeader,
260260
fontSize: font.sizeXS,
261261
},
262+
header: {
263+
backgroundColor: color.blackDark,
264+
},
262265
});
263266

264267
const ChannelListHeader = () => (
265-
<ListHeader>
268+
<ListHeader style={hStyles.header}>
266269
<Text style={[iStyles.m, hStyles.txt]}>STATUS</Text>
267270
<Text style={[iStyles.m, hStyles.txt]}>CAPACITY</Text>
268271
<Text style={[iStyles.l, hStyles.txt]}>FUNDING TRANSACTION ID</Text>

src/view/notification.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const NotificationView = ({ store, nav }) => {
2626
<ListContent>
2727
<List
2828
data={notifications}
29-
renderHeader={() => <NotificationListHeader />}
29+
renderHeader={NotificationListHeader}
3030
renderItem={item => <NotificationListItem item={item} />}
3131
/>
3232
</ListContent>
@@ -96,10 +96,13 @@ const hStyles = StyleSheet.create({
9696
color: color.greyListHeader,
9797
fontSize: font.sizeXS,
9898
},
99+
header: {
100+
backgroundColor: color.blackDark,
101+
},
99102
});
100103

101104
const NotificationListHeader = () => (
102-
<ListHeader>
105+
<ListHeader style={hStyles.header}>
103106
<Text style={[iStyles.s, hStyles.txt]}>TYPE</Text>
104107
<Text style={[iStyles.m, hStyles.txt]}>TIME</Text>
105108
<Text style={[iStyles.l, hStyles.txt]}>DESCRIPTION</Text>

src/view/transaction.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const TransactionView = ({ store, nav, transaction }) => {
2828
<ListContent>
2929
<List
3030
data={transactions}
31-
renderHeader={() => <TransactionListHeader />}
31+
renderHeader={TransactionListHeader}
3232
renderItem={item => (
3333
<TransactionListItem
3434
tx={item}
@@ -123,10 +123,13 @@ const hStyles = StyleSheet.create({
123123
color: color.greyListHeader,
124124
fontSize: font.sizeXS,
125125
},
126+
header: {
127+
backgroundColor: color.blackDark,
128+
},
126129
});
127130

128131
const TransactionListHeader = () => (
129-
<ListHeader style={iStyles.item}>
132+
<ListHeader style={[iStyles.item, hStyles.header]}>
130133
<View style={iStyles.i} />
131134
<Text style={[iStyles.m, hStyles.txt]}>STATUS</Text>
132135
<Text style={[iStyles.m, hStyles.txt]}>DATE</Text>

stories/component/list-story.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ storiesOf('List', module).add('List Content', () => (
1616
<List
1717
data={[...Array(1000)].map((x, i) => ({ id: String(i), data: 'foo' }))}
1818
renderHeader={() => (
19-
<ListHeader>
19+
<ListHeader style={{ backgroundColor: color.white }}>
2020
<Text style={{ flex: 1, color: color.greyText }}>ID</Text>
2121
<Text style={{ flex: 1, color: color.greyText }}>Data</Text>
2222
</ListHeader>

0 commit comments

Comments
 (0)