Init support to iPhone X

This commit is contained in:
Rodrigo Nascimento 2017-11-13 10:49:19 -02:00
parent 994a087ba4
commit 50c50a790a
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
15 changed files with 1548 additions and 1299 deletions

View File

@ -31,9 +31,9 @@ export default class Banner extends React.PureComponent {
offline: PropTypes.bool offline: PropTypes.bool
} }
componentWillMount() { componentWillMount() {
this.state = { this.setState({
slow: false slow: false
}; });
this.timer = setTimeout(() => this.setState({ slow: true }), 5000); this.timer = setTimeout(() => this.setState({ slow: true }), 5000);
} }
componentWillUnmount() { componentWillUnmount() {

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { View, TextInput, StyleSheet } from 'react-native'; import { View, TextInput, StyleSheet, SafeAreaView } from 'react-native';
import Icon from 'react-native-vector-icons/MaterialIcons'; import Icon from 'react-native-vector-icons/MaterialIcons';
import ImagePicker from 'react-native-image-picker'; import ImagePicker from 'react-native-image-picker';
import RocketChat from '../lib/rocketchat'; import RocketChat from '../lib/rocketchat';
@ -10,7 +10,9 @@ const styles = StyleSheet.create({
paddingTop: 1, paddingTop: 1,
borderTopWidth: 1, borderTopWidth: 1,
borderTopColor: '#ccc', borderTopColor: '#ccc',
backgroundColor: '#fff', backgroundColor: '#fff'
},
safeAreaView: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center' alignItems: 'center'
}, },
@ -77,6 +79,7 @@ export default class MessageBox extends React.PureComponent {
render() { render() {
return ( return (
<View style={styles.textBox}> <View style={styles.textBox}>
<SafeAreaView style={styles.safeAreaView}>
<Icon style={styles.fileButton} name='add-circle-outline' onPress={this.addFile} /> <Icon style={styles.fileButton} name='add-circle-outline' onPress={this.addFile} />
<TextInput <TextInput
ref={component => this.component = component} ref={component => this.component = component}
@ -86,8 +89,9 @@ export default class MessageBox extends React.PureComponent {
blurOnSubmit={false} blurOnSubmit={false}
placeholder='New message' placeholder='New message'
underlineColorAndroid='transparent' underlineColorAndroid='transparent'
defaultValue={''} defaultValue=''
/> />
</SafeAreaView>
</View> </View>
); );
} }

View File

@ -53,7 +53,7 @@ export default class Sidebar extends Component {
componentWillMount() { componentWillMount() {
realm.addListener('change', this.updateState); realm.addListener('change', this.updateState);
this.state = this.getState(); this.setState(this.getState());
} }
componentWillUnmount() { componentWillUnmount() {

View File

@ -45,14 +45,16 @@ export default class Loading extends Component {
toValue: 0.8, toValue: 0.8,
duration: 1000, duration: 1000,
useNativeDriver: true useNativeDriver: true
}), }
),
Animated.timing( Animated.timing(
this.scale, this.scale,
{ {
toValue: 1, toValue: 1,
duration: 1000, duration: 1000,
useNativeDriver: true useNativeDriver: true
}) }
)
]).start(() => { ]).start(() => {
this.animate(); this.animate();
}); });

View File

@ -76,7 +76,7 @@ export default class RoomItem extends React.PureComponent {
unread: PropTypes.number, unread: PropTypes.number,
baseUrl: PropTypes.string, baseUrl: PropTypes.string,
onPress: PropTypes.func, onPress: PropTypes.func,
dateFormat: PropTypes.string.isRequired dateFormat: PropTypes.string
} }
get icon() { get icon() {
@ -126,6 +126,7 @@ export default class RoomItem extends React.PureComponent {
render() { render() {
const { unread, name, _updatedAt } = this.props; const { unread, name, _updatedAt } = this.props;
if (_updatedAt) {
return ( return (
<TouchableOpacity onPress={this.props.onPress} style={styles.container}> <TouchableOpacity onPress={this.props.onPress} style={styles.container}>
{this.icon} {this.icon}
@ -137,4 +138,15 @@ export default class RoomItem extends React.PureComponent {
</TouchableOpacity> </TouchableOpacity>
); );
} }
return (
<TouchableOpacity onPress={this.props.onPress} style={styles.container}>
{this.icon}
<View style={styles.roomNameView}>
<Text style={styles.roomName} ellipsizeMode='tail' numberOfLines={1}>{ name }</Text>
</View>
{this.renderNumber(unread)}
</TouchableOpacity>
);
}
} }

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { TextInput, View, Text, Switch, TouchableOpacity } from 'react-native'; import { TextInput, View, Text, Switch, TouchableOpacity, SafeAreaView } from 'react-native';
import { createChannelRequest } from '../actions/createChannel'; import { createChannelRequest } from '../actions/createChannel';
import styles from './Styles'; import styles from './Styles';
import KeyboardView from '../presentation/KeyboardView'; import KeyboardView from '../presentation/KeyboardView';
@ -94,7 +94,7 @@ export default class CreateChannelView extends React.Component {
style={[styles.defaultViewBackground, { flex: 1 }]} style={[styles.defaultViewBackground, { flex: 1 }]}
contentContainerStyle={styles.defaultView} contentContainerStyle={styles.defaultView}
> >
<View style={styles.formContainer}> <SafeAreaView style={styles.formContainer}>
<Text style={styles.label_white}>Channel Name</Text> <Text style={styles.label_white}>Channel Name</Text>
<TextInput <TextInput
value={this.state.channelName} value={this.state.channelName}
@ -139,7 +139,7 @@ export default class CreateChannelView extends React.Component {
{this.props.result.isFetching ? 'LOADING' : 'CREATE'}! {this.props.result.isFetching ? 'LOADING' : 'CREATE'}!
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
</View> </SafeAreaView>
</KeyboardView> </KeyboardView>
); );
} }

View File

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Text, TextInput, View, TouchableOpacity, Alert } from 'react-native'; import { Text, TextInput, View, TouchableOpacity, Alert, SafeAreaView } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import * as loginActions from '../actions/login'; import * as loginActions from '../actions/login';
@ -72,6 +72,7 @@ class ForgotPasswordView extends React.Component {
contentContainerStyle={styles.container} contentContainerStyle={styles.container}
keyboardVerticalOffset={128} keyboardVerticalOffset={128}
> >
<SafeAreaView>
<View style={styles.loginView}> <View style={styles.loginView}>
<View style={styles.formContainer}> <View style={styles.formContainer}>
<TextInput <TextInput
@ -96,8 +97,9 @@ class ForgotPasswordView extends React.Component {
{this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>} {this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>}
</View> </View>
<Spinner visible={this.props.login.isFetching} textContent={'Loading...'} textStyle={{ color: '#FFF' }} /> <Spinner visible={this.props.login.isFetching} textContent="Loading..." textStyle={{ color: '#FFF' }} />
</View> </View>
</SafeAreaView>
</KeyboardView> </KeyboardView>
); );
} }

View File

@ -3,7 +3,7 @@ import React from 'react';
import Icon from 'react-native-vector-icons/Ionicons'; import Icon from 'react-native-vector-icons/Ionicons';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Zeroconf from 'react-native-zeroconf'; import Zeroconf from 'react-native-zeroconf';
import { View, Text, SectionList, StyleSheet } from 'react-native'; import { View, Text, SectionList, StyleSheet, SafeAreaView } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { setServer } from '../actions/server'; import { setServer } from '../actions/server';
import realm from '../lib/realm'; import realm from '../lib/realm';
@ -93,7 +93,7 @@ export default class ListServerView extends React.Component {
zeroconf.scan('http', 'tcp', 'local.'); zeroconf.scan('http', 'tcp', 'local.');
this.state = this.getState(); this.setState(this.getState());
} }
componentDidUpdate() { componentDidUpdate() {
@ -184,6 +184,7 @@ export default class ListServerView extends React.Component {
return ( return (
<View style={styles.view}> <View style={styles.view}>
<Banner /> <Banner />
<SafeAreaView style={styles.view}>
<SectionList <SectionList
style={styles.list} style={styles.list}
sections={this.state.sections} sections={this.state.sections}
@ -192,6 +193,7 @@ export default class ListServerView extends React.Component {
keyExtractor={item => item.id} keyExtractor={item => item.id}
ItemSeparatorComponent={this.renderSeparator} ItemSeparatorComponent={this.renderSeparator}
/> />
</SafeAreaView>
</View> </View>
); );
} }

View File

@ -3,7 +3,7 @@ import React from 'react';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Keyboard, Text, TextInput, View, TouchableOpacity } from 'react-native'; import { Keyboard, Text, TextInput, View, TouchableOpacity, SafeAreaView } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
// import * as actions from '../actions'; // import * as actions from '../actions';
@ -78,6 +78,7 @@ class LoginView extends React.Component {
contentContainerStyle={styles.container} contentContainerStyle={styles.container}
keyboardVerticalOffset={128} keyboardVerticalOffset={128}
> >
<SafeAreaView>
<View style={styles.loginView}> <View style={styles.loginView}>
<View style={styles.formContainer}> <View style={styles.formContainer}>
<TextInput <TextInput
@ -120,8 +121,9 @@ class LoginView extends React.Component {
{this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>} {this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>}
</View> </View>
<Spinner visible={this.props.login.isFetching} textContent={'Loading...'} textStyle={{ color: '#FFF' }} /> <Spinner visible={this.props.login.isFetching} textContent='Loading...' textStyle={{ color: '#FFF' }} />
</View> </View>
</SafeAreaView>
</KeyboardView> </KeyboardView>
); );
} }

View File

@ -3,7 +3,7 @@ import React from 'react';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Keyboard, Text, TextInput, View, TouchableOpacity } from 'react-native'; import { Keyboard, Text, TextInput, View, TouchableOpacity, SafeAreaView } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import * as loginActions from '../actions/login'; import * as loginActions from '../actions/login';
@ -37,7 +37,9 @@ class RegisterView extends React.Component {
} }
_valid() { _valid() {
const { name, email, password, confirmPassword } = this.state; const {
name, email, password, confirmPassword
} = this.state;
return name.trim() && email.trim() && return name.trim() && email.trim() &&
password && confirmPassword && password === confirmPassword; password && confirmPassword && password === confirmPassword;
} }
@ -45,12 +47,16 @@ class RegisterView extends React.Component {
return this.props.login.failure && /Email/.test(this.props.login.error.reason); return this.props.login.failure && /Email/.test(this.props.login.error.reason);
} }
submit = () => { submit = () => {
const { name, email, password, code } = this.state; const {
name, email, password, code
} = this.state;
if (!this._valid()) { if (!this._valid()) {
return; return;
} }
this.props.registerSubmit({ name, email, pass: password, code }); this.props.registerSubmit({
name, email, pass: password, code
});
Keyboard.dismiss(); Keyboard.dismiss();
} }
usernameSubmit = () => { usernameSubmit = () => {
@ -125,7 +131,8 @@ class RegisterView extends React.Component {
: { color: placeholderTextColor } : { color: placeholderTextColor }
]} ]}
onPress={this.submit} onPress={this.submit}
>REGISTER</Text> >REGISTER
</Text>
</TouchableOpacity> </TouchableOpacity>
{this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>} {this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>}
@ -155,7 +162,8 @@ class RegisterView extends React.Component {
<Text <Text
style={styles.button} style={styles.button}
onPress={this.usernameSubmit} onPress={this.usernameSubmit}
>REGISTER</Text> >REGISTER
</Text>
</TouchableOpacity> </TouchableOpacity>
{this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>} {this.props.login.failure && <Text style={styles.error}>{this.props.login.error.reason}</Text>}
@ -166,11 +174,13 @@ class RegisterView extends React.Component {
render() { render() {
return ( return (
<KeyboardView contentContainerStyle={styles.container}> <KeyboardView contentContainerStyle={styles.container}>
<SafeAreaView>
<View style={styles.loginView}> <View style={styles.loginView}>
{this._renderRegister()} {this._renderRegister()}
{this._renderUsername()} {this._renderUsername()}
<Spinner visible={this.props.login.isFetching} textContent={'Loading...'} textStyle={{ color: '#FFF' }} /> <Spinner visible={this.props.login.isFetching} textContent='Loading...' textStyle={{ color: '#FFF' }} />
</View> </View>
</SafeAreaView>
</KeyboardView> </KeyboardView>
); );
} }

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Text, View, StyleSheet, Button, InteractionManager } from 'react-native'; import { Text, View, StyleSheet, Button, InteractionManager, SafeAreaView } from 'react-native';
import { ListView } from 'realm/react-native'; import { ListView } from 'realm/react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
@ -19,6 +19,9 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
backgroundColor: '#fff' backgroundColor: '#fff'
}, },
safeAreaView: {
flex: 1
},
list: { list: {
flex: 1, flex: 1,
transform: [{ scaleY: -1 }] transform: [{ scaleY: -1 }]
@ -195,6 +198,7 @@ export default class RoomView extends React.Component {
return ( return (
<KeyboardView contentContainerStyle={styles.container} keyboardVerticalOffset={64}> <KeyboardView contentContainerStyle={styles.container} keyboardVerticalOffset={64}>
{this.renderBanner()} {this.renderBanner()}
<SafeAreaView style={styles.safeAreaView}>
<ListView <ListView
enableEmptySections enableEmptySections
style={styles.list} style={styles.list}
@ -205,6 +209,7 @@ export default class RoomView extends React.Component {
renderRow={item => this.renderItem({ item })} renderRow={item => this.renderItem({ item })}
initialListSize={10} initialListSize={10}
/> />
</SafeAreaView>
{this.renderFooter()} {this.renderFooter()}
</KeyboardView> </KeyboardView>
); );

View File

@ -3,7 +3,7 @@ import { ListView } from 'realm/react-native';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Icon from 'react-native-vector-icons/Ionicons'; import Icon from 'react-native-vector-icons/Ionicons';
import { View, StyleSheet, TextInput } from 'react-native'; import { View, StyleSheet, TextInput, SafeAreaView } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as actions from '../actions'; import * as actions from '../actions';
import * as server from '../actions/connect'; import * as server from '../actions/connect';
@ -51,6 +51,9 @@ const styles = StyleSheet.create({
padding: 5, padding: 5,
paddingLeft: 10, paddingLeft: 10,
color: '#aaa' color: '#aaa'
},
safeAreaView: {
backgroundColor: '#fff'
} }
}); });
@ -90,10 +93,10 @@ export default class RoomsListView extends React.Component {
componentWillMount() { componentWillMount() {
this.data.addListener(this.updateState); this.data.addListener(this.updateState);
this.state = { this.setState({
...this.state, ...this.state,
dataSource: ds.cloneWithRows(this.data) dataSource: ds.cloneWithRows(this.data)
}; });
} }
componentWillReceiveProps(props) { componentWillReceiveProps(props) {
@ -243,7 +246,7 @@ export default class RoomsListView extends React.Component {
key={item._id} key={item._id}
type={item.t} type={item.t}
baseUrl={this.props.Site_Url} baseUrl={this.props.Site_Url}
dateFormat={'MM-DD-YYYY HH:mm:ss'} dateFormat='MM-DD-YYYY HH:mm:ss'
onPress={() => this._onPressItem(item._id, item)} onPress={() => this._onPressItem(item._id, item)}
/> />
) )
@ -271,7 +274,9 @@ export default class RoomsListView extends React.Component {
render = () => ( render = () => (
<View style={styles.container}> <View style={styles.container}>
<Banner /> <Banner />
<SafeAreaView style={styles.safeAreaView}>
{this.renderList()} {this.renderList()}
{this.renderCreateButtons()} {this.renderCreateButtons()}
</SafeAreaView>
</View>) </View>)
} }

View File

@ -3,7 +3,7 @@ import { ListView } from 'realm/react-native';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Icon from 'react-native-vector-icons/Ionicons'; import Icon from 'react-native-vector-icons/Ionicons';
import { View, StyleSheet, TextInput, Text, TouchableOpacity } from 'react-native'; import { View, StyleSheet, TextInput, Text, TouchableOpacity, SafeAreaView } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as actions from '../actions'; import * as actions from '../actions';
import * as server from '../actions/connect'; import * as server from '../actions/connect';
@ -20,6 +20,9 @@ const styles = StyleSheet.create({
alignItems: 'stretch', alignItems: 'stretch',
justifyContent: 'center' justifyContent: 'center'
}, },
safeAreaView: {
backgroundColor: '#FFFFFF'
},
list: { list: {
width: '100%', width: '100%',
backgroundColor: '#FFFFFF' backgroundColor: '#FFFFFF'
@ -264,8 +267,10 @@ export default class RoomsListView extends React.Component {
render = () => ( render = () => (
<View style={styles.container}> <View style={styles.container}>
<Banner /> <Banner />
<SafeAreaView style={styles.safeAreaView}>
{this.renderList()} {this.renderList()}
{this.renderCreateButton()} {this.renderCreateButton()}
</SafeAreaView>
</View> </View>
); );
} }

2512
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,9 +18,9 @@
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"moment": "^2.19.2", "moment": "^2.19.2",
"prop-types": "^15.6.0", "prop-types": "^15.6.0",
"react": "16.0.0-alpha.12", "react": "16.1.0",
"react-emojione": "^3.1.10", "react-emojione": "^3.1.10",
"react-native": "0.46.1", "react-native": "0.50.3",
"react-native-action-button": "^2.8.1", "react-native-action-button": "^2.8.1",
"react-native-animatable": "^1.2.4", "react-native-animatable": "^1.2.4",
"react-native-card-view": "0.0.3", "react-native-card-view": "0.0.3",
@ -28,13 +28,13 @@
"react-native-fetch-blob": "^0.10.8", "react-native-fetch-blob": "^0.10.8",
"react-native-image-picker": "^0.26.7", "react-native-image-picker": "^0.26.7",
"react-native-img-cache": "^1.5.0", "react-native-img-cache": "^1.5.0",
"react-native-keyboard-aware-scroll-view": "^0.3.0", "react-native-keyboard-aware-scroll-view": "^0.4.1",
"react-native-loading-spinner-overlay": "^0.5.2", "react-native-loading-spinner-overlay": "^0.5.2",
"react-native-meteor": "^1.2.0", "react-native-meteor": "^1.2.0",
"react-native-modal": "^3.1.0", "react-native-modal": "^4.1.1",
"react-native-optimized-flatlist": "^1.0.3", "react-native-optimized-flatlist": "^1.0.3",
"react-native-svg": "^5.4.1", "react-native-svg": "^6.0.0",
"react-native-svg-image": "^1.1.4", "react-native-svg-image": "^2.0.1",
"react-native-vector-icons": "^4.4.2", "react-native-vector-icons": "^4.4.2",
"react-native-zeroconf": "^0.8.3", "react-native-zeroconf": "^0.8.3",
"react-navigation": "^1.0.0-beta.19", "react-navigation": "^1.0.0-beta.19",
@ -43,7 +43,7 @@
"redux": "^3.7.2", "redux": "^3.7.2",
"redux-immutable-state-invariant": "^2.1.0", "redux-immutable-state-invariant": "^2.1.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
"redux-saga": "^0.15.6", "redux-saga": "^0.16.0",
"regenerator-runtime": "^0.11.0", "regenerator-runtime": "^0.11.0",
"remote-redux-devtools": "^0.5.12", "remote-redux-devtools": "^0.5.12",
"strip-ansi": "^4.0.0" "strip-ansi": "^4.0.0"
@ -51,20 +51,20 @@
"devDependencies": { "devDependencies": {
"@storybook/addon-storyshots": "^3.2.15", "@storybook/addon-storyshots": "^3.2.15",
"@storybook/react-native": "^3.2.15", "@storybook/react-native": "^3.2.15",
"babel-eslint": "^7.2.3", "babel-eslint": "^8.0.2",
"babel-jest": "20.0.3", "babel-jest": "21.2.0",
"babel-preset-react-native": "2.1.0", "babel-preset-react-native": "4.0.0",
"codecov": "^2.3.0", "codecov": "^3.0.0",
"eslint": "^4.11.0", "eslint": "^4.11.0",
"eslint-config-airbnb": "^15.1.0", "eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.8.0", "eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0", "eslint-plugin-react": "^7.4.0",
"eslint-plugin-react-native": "^3.1.0", "eslint-plugin-react-native": "^3.1.0",
"jest": "20.0.4", "jest": "21.2.1",
"jest-cli": "^20.0.4", "jest-cli": "^21.2.1",
"react-dom": "16.0.0-alpha.12", "react-dom": "16.1.0",
"react-test-renderer": "16.0.0-alpha.12" "react-test-renderer": "16.1.0"
}, },
"jest": { "jest": {
"preset": "react-native", "preset": "react-native",