diff --git a/client/react-native/common/components/Library/Text.js b/client/react-native/common/components/Library/Text.js index 878115c9f7..ddfa9ad47c 100644 --- a/client/react-native/common/components/Library/Text.js +++ b/client/react-native/common/components/Library/Text.js @@ -1,6 +1,9 @@ +import { Text as TextNative, TextInput, StyleSheet } from 'react-native' import React, { Fragment, PureComponent } from 'react' -import { View, Text as TextNative, TextInput, StyleSheet } from 'react-native' +import hash from 'object-hash' + import { Icon, Flex } from '.' +import { colors } from '../../constants' import { tinyText, smallText, @@ -23,8 +26,6 @@ import { marginHorizontal, marginVertical, } from '../../styles' -import { colors } from '../../constants' -import hash from 'object-hash' const reverse = props => Object.keys(props) @@ -52,6 +53,8 @@ const getPadding = ( case 'boolean': padding = find({ inside: props, from: paddings, or: 'small' }) break + case 'number': + break case 'string': padding = paddings[padding] break @@ -206,11 +209,17 @@ const getMargin = ( case 'string': return margins[props.margin] case 'object': - return Object.keys(margins).reduce((a, key) => { - a[`margin${key.charAt(0).toUpperCase()}${key.slice(1)}`] = - props.margin[key] - return a - }, {}) + return Array.isArray(props.margin) + ? props.margin.reduce((a, key) => { + a[`margin${key.charAt(0).toUpperCase()}${key.slice(1)}`] = + margins[key] + return a + }, {}) + : Object.keys(margins).reduce((a, key) => { + a[`margin${key.charAt(0).toUpperCase()}${key.slice(1)}`] = + props.margin[key] + return a + }, {}) default: return null } @@ -352,7 +361,7 @@ export class ForegroundText extends PureComponent { {icon && typeof icon === 'string' ? ( ) : ( - icon && {icon} + icon && {icon} )} {input ? ( {children} diff --git a/client/react-native/common/components/Screens/Chats/Detail.js b/client/react-native/common/components/Screens/Chats/Detail.js index bfb7221911..ed7ed109f7 100644 --- a/client/react-native/common/components/Screens/Chats/Detail.js +++ b/client/react-native/common/components/Screens/Chats/Detail.js @@ -1,5 +1,5 @@ /* eslint-disable */ -import { ActivityIndicator, FlatList } from 'react-native' +import { ActivityIndicator, FlatList, Platform, View } from 'react-native' import React, { Fragment, PureComponent } from 'react' import { QueryReducer } from '../../../relay' @@ -64,6 +64,7 @@ const Message = fragments.Event(props => { class Input extends PureComponent { state = { input: '', + height: 16, } onSubmit = () => { @@ -87,25 +88,59 @@ class Input extends PureComponent { render() { return ( - this.setState({ input }), - placeholder: 'Write a secure message...', - autoFocus: true, - value: this.state.input, - }} - background={colors.grey8} - color={colors.grey5} - onSubmit={this.onSubmit} - /> + + + 20 ? 0 : 8, + bottom: this.state.height > 20 ? 0 : 8, + }} + lineHeight={this.state.height > 20 ? 0 : 16} + background={colors.grey8} + icon="edit-2" + height={this.state.height} + input={{ + onChangeText: input => { + this.setState({ input }) + }, + onContentSizeChange: ({ + nativeEvent: { + contentSize: { height }, + }, + }) => { + this.setState({ + height: height > 80 ? 80 : height, + }) + }, + placeholder: 'Write a secure message...', + autoFocus: true, + value: this.state.input, + }} + multiline + color={colors.grey5} + /> + + + ) } } @@ -134,10 +169,10 @@ const List = fragments.EventList( const { data, loading } = this.props const edges = (data && data.EventList && data.EventList.edges) || [] return ( - + (this.ref = ref)} - style={[{ paddingTop: 54 }, paddingHorizontal]} + style={[paddingHorizontal]} data={edges} inverted refreshing={loading} @@ -151,24 +186,6 @@ const List = fragments.EventList( /> )} /> - - - - - ) } @@ -195,37 +212,50 @@ export default class Detail extends PureComponent { render() { const conversation = this.props.navigation.getParam('conversation') return ( - - + + - {(state, retry) => { - switch (state.type) { - default: - case state.loading: - return - case state.success: - return ( - - ) - case state.error: - return null - } - }} - + ])} + > + {(state, retry) => { + switch (state.type) { + default: + case state.loading: + return + case state.success: + return ( + + ) + case state.error: + return null + } + }} + + + + + ) } diff --git a/client/react-native/common/index.js b/client/react-native/common/index.js index f9373d05de..4137347eab 100644 --- a/client/react-native/common/index.js +++ b/client/react-native/common/index.js @@ -2,7 +2,7 @@ if (!__DEV__) { console.error = console.warn } - +console.warn = () => {} import React from 'react' import ReactDOM from 'react-dom' import { NativeModules, Platform, AppRegistry } from 'react-native'