Chats: Don't show group header if none of the filters is selected (#560)

This commit is contained in:
Diego Mello 2018-12-06 10:53:20 -02:00 committed by GitHub
parent a2821af95b
commit 17da7ac09c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 6 deletions

View File

@ -502,7 +502,19 @@ export default class RoomsListView extends LoggedView {
); );
} }
renderSeparator = () => <View style={styles.separator} />; renderSeparator = () => <View style={styles.separator} />
renderSectionHeader = (header) => {
const { showUnread, showFavorites, groupByType } = this.props;
if (!(showUnread || showFavorites || groupByType)) {
return null;
}
return (
<View style={styles.groupTitleContainer}>
<Text style={styles.groupTitle}>{I18n.t(header)}</Text>
</View>
);
}
renderSection = (data, header) => { renderSection = (data, header) => {
const { showUnread, showFavorites, groupByType } = this.props; const { showUnread, showFavorites, groupByType } = this.props;
@ -525,11 +537,7 @@ export default class RoomsListView extends LoggedView {
style={styles.list} style={styles.list}
renderItem={this.renderItem} renderItem={this.renderItem}
ItemSeparatorComponent={this.renderSeparator} ItemSeparatorComponent={this.renderSeparator}
ListHeaderComponent={() => ( ListHeaderComponent={() => this.renderSectionHeader(header)}
<View style={styles.groupTitleContainer}>
<Text style={styles.groupTitle}>{I18n.t(header)}</Text>
</View>
)}
getItemLayout={getItemLayout} getItemLayout={getItemLayout}
enableEmptySections enableEmptySections
removeClippedSubviews removeClippedSubviews