Skip to content

Commit

Permalink
Empty room background
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Aug 9, 2018
1 parent 50eb035 commit 89cb4f7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 35 deletions.
3 changes: 0 additions & 3 deletions app/lib/methods/getCustomEmojis.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const getLastMessage = () => {

export default async function() {
try {
if (!this.ddp.status) {
return;
}
const lastMessage = getLastMessage();
let emojis = await this.ddp.call('listEmojiCustom');
emojis = emojis.filter(emoji => !lastMessage || emoji._updatedAt > lastMessage);
Expand Down
Binary file added app/static/images/message_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 35 additions & 28 deletions app/views/RoomView/ListView.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ListView as OldList } from 'realm/react-native';
import React from 'react';
import cloneReferencedElement from 'react-clone-referenced-element';
import { ScrollView, ListView as OldList2 } from 'react-native';
import { ScrollView, ListView as OldList2, ImageBackground } from 'react-native';
import moment from 'moment';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -63,22 +62,24 @@ export class List extends React.Component {
}, 1000);

render() {
return (<ListView
enableEmptySections
style={styles.list}
data={this.data}
keyExtractor={item => item._id}
onEndReachedThreshold={100}
renderFooter={this.props.renderFooter}
renderHeader={() => <Typing />}
onEndReached={() => this.props.onEndReached(this.data[this.data.length - 1])}
dataSource={this.dataSource}
renderRow={(item, previousItem) => this.props.renderRow(item, previousItem)}
initialListSize={1}
pageSize={20}
testID='room-view-messages'
{...scrollPersistTaps}
/>);
return (
<ListView
enableEmptySections
style={styles.list}
data={this.data}
keyExtractor={item => item._id}
onEndReachedThreshold={100}
renderFooter={this.props.renderFooter}
renderHeader={() => <Typing />}
onEndReached={() => this.props.onEndReached(this.data[this.data.length - 1])}
dataSource={this.dataSource}
renderRow={(item, previousItem) => this.props.renderRow(item, previousItem)}
initialListSize={1}
pageSize={20}
testID='room-view-messages'
{...scrollPersistTaps}
/>
);
}
}

Expand Down Expand Up @@ -170,16 +171,22 @@ export class ListView extends OldList2 {
onKeyboardDidHide: undefined
});

return cloneReferencedElement(
<ScrollView {...props} />,
{
ref: this._setScrollComponentRef,
onContentSizeChange: this._onContentSizeChange,
onLayout: this._onLayout
},
header,
bodyComponents,
footer,
const image = data.length === 0 ? require('../../static/images/message_empty.png') : null;
return (
[
<ImageBackground key='listview-background' source={image} style={styles.imageBackground} />,
<ScrollView
key='listview-scroll'
ref={this._setScrollComponentRef}
onContentSizeChange={this._onContentSizeChange}
onLayout={this._onLayout}
{...props}
>
{header}
{bodyComponents}
{footer}
</ScrollView>
]
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/views/RoomView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ export default class RoomView extends LoggedView {
};

renderHeader = () => {
if (this.state.end) {
return <Text style={styles.loadingMore}>{I18n.t('Start_of_conversation')}</Text>;
if (!this.state.end) {
return <Text style={styles.loadingMore}>{I18n.t('Loading_messages_ellipsis')}</Text>;
}
return <Text style={styles.loadingMore}>{I18n.t('Loading_messages_ellipsis')}</Text>;
return null;
}

renderList = () => {
Expand Down
5 changes: 5 additions & 0 deletions app/views/RoomView/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,10 @@ export default StyleSheet.create({
},
loading: {
flex: 1
},
imageBackground: {
width: '100%',
height: '100%',
position: 'absolute'
}
});
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-clone-referenced-element": "^1.0.1",
"react-emojione": "^5.0.0",
"react-native": "^0.56.0",
"react-native-actionsheet": "^2.4.2",
Expand Down

0 comments on commit 89cb4f7

Please sign in to comment.