From 114c9727cec7ab6dfcdb5d72733d5f01355f8f39 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Tue, 14 Nov 2017 20:46:56 -0200 Subject: [PATCH] iOS: Use icon in header to create new channel (#80) --- app/views/RoomsListView.js | 29 ++++++++++++++++++++++++++--- app/views/SelectUsersView.js | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/views/RoomsListView.js b/app/views/RoomsListView.js index c9429221a..06228adc1 100644 --- a/app/views/RoomsListView.js +++ b/app/views/RoomsListView.js @@ -3,7 +3,7 @@ import { ListView } from 'realm/react-native'; import React from 'react'; import PropTypes from 'prop-types'; import Icon from 'react-native-vector-icons/Ionicons'; -import { View, StyleSheet, TextInput, SafeAreaView } from 'react-native'; +import { Platform, View, StyleSheet, TextInput, SafeAreaView } from 'react-native'; import { connect } from 'react-redux'; import * as actions from '../actions'; import * as server from '../actions/connect'; @@ -78,6 +78,25 @@ export default class RoomsListView extends React.Component { server: PropTypes.string } + static navigationOptions = ({ navigation }) => { + if (Platform.OS !== 'ios') { + return; + } + + const { params = {} } = navigation.state; + const headerRight = ( + + ); + + return { headerRight }; + }; + constructor(props) { super(props); @@ -94,6 +113,10 @@ export default class RoomsListView extends React.Component { componentWillMount() { this.data.addListener(this.updateState); + this.props.navigation.setParams({ + createChannel: () => this._createChannel() + }); + this.setState({ ...this.state, dataSource: ds.cloneWithRows(this.data) @@ -258,7 +281,7 @@ export default class RoomsListView extends React.Component { style={styles.list} renderRow={this.renderItem} renderHeader={this.renderSearchBar} - contentOffset={{ x: 0, y: 20 }} + contentOffset={{ x: 0, y: 38 }} enableEmptySections keyboardShouldPersistTaps='always' /> @@ -277,7 +300,7 @@ export default class RoomsListView extends React.Component { {this.renderList()} - {this.renderCreateButtons()} + {Platform.OS === 'android' && this.renderCreateButtons()} ) } diff --git a/app/views/SelectUsersView.js b/app/views/SelectUsersView.js index a8bbc7ba0..10d6045c2 100644 --- a/app/views/SelectUsersView.js +++ b/app/views/SelectUsersView.js @@ -248,7 +248,7 @@ export default class RoomsListView extends React.Component { style={styles.list} renderRow={this.renderItem} renderHeader={this.renderHeader} - contentOffset={{ x: 0, y: this.props.users.length > 0 ? 40 : 20 }} + contentOffset={{ x: 0, y: this.props.users.length > 0 ? 38 : 0 }} enableEmptySections keyboardShouldPersistTaps='always' />