Skip to content
Permalink
Browse files

fix(error): on runtime

  • Loading branch information...
xcarpentier committed Dec 18, 2017
1 parent 28cb467 commit 5b67203570a2bcadf9475eec3c14149c4e404eac
Showing with 55 additions and 32 deletions.
  1. +1 βˆ’0 src/Colors.js
  2. +3 βˆ’1 src/Composer.js
  3. +8 βˆ’4 src/Constants.js
  4. +14 βˆ’9 src/Day.js
  5. +13 βˆ’3 src/GiftedChat.js
  6. +1 βˆ’1 src/MessageText.js
  7. +15 βˆ’14 src/Time.js
@@ -11,4 +11,5 @@ export default {
turquoise: '#1abc9c',
midnightBlue: '#2c3e50',
optionTintColor: '#007AFF',
timeTextColor: '#aaa',
};
@@ -4,9 +4,11 @@ import PropTypes from 'prop-types';
import React from 'react';
import { Platform, StyleSheet, TextInput } from 'react-native';

import { MIN_COMPOSER_HEIGHT, DEFAULT_PLACEHOLDER } from './Constants';
import Constants from './Constants';
import Colors from './Colors';

const { MIN_COMPOSER_HEIGHT, DEFAULT_PLACEHOLDER } = Constants;

export default class Composer extends React.Component {
onContentSizeChange(e) {
const contentSize = e.nativeEvent.contentSize;
@@ -1,10 +1,14 @@
import { Platform } from 'react-native';

const MIN_COMPOSER_HEIGHT = Platform.select({
ios: 33,
android: 41,
});

export default {
MIN_COMPOSER_HEIGHT: Platform.select({
ios: 33,
android: 41,
}),
MIN_COMPOSER_HEIGHT,
MAX_COMPOSER_HEIGHT: 100,
DEFAULT_PLACEHOLDER: 'Type a message...',
DATE_FORMAT: 'll',
TIME_FORMAT: 'LT',
};
@@ -8,17 +8,21 @@ import moment from 'moment';
import Colors from './Colors';

import { isSameDay, isSameUser, warnDeprecated } from './utils';
import Constants from './Constants';

export default function Day() {
const { dateFormat } = this.props;
const { DATE_FORMAT } = Constants;

if (!isSameDay(this.props.currentMessage, this.props.previousMessage)) {
export default function Day(
{ dateFormat, currentMessage, previousMessage, containerStyle, wrapperStyle, textStyle },
context
) {
if (!isSameDay(currentMessage, previousMessage)) {
return (
<View style={[styles.container, this.props.containerStyle]}>
<View style={this.props.wrapperStyle}>
<Text style={[styles.text, this.props.textStyle]}>
{moment(this.props.currentMessage.createdAt)
.locale(this.context.getLocale())
<View style={[styles.container, containerStyle]}>
<View style={wrapperStyle}>
<Text style={[styles.text, textStyle]}>
{moment(currentMessage.createdAt)
.locale(context.getLocale())
.format(dateFormat)
.toUpperCase()}
</Text>
@@ -60,6 +64,7 @@ Day.defaultProps = {
// TODO: remove in next major release
isSameDay: warnDeprecated(isSameDay),
isSameUser: warnDeprecated(isSameUser),
dateFormat: DATE_FORMAT,
};

Day.propTypes = {
@@ -71,5 +76,5 @@ Day.propTypes = {
// TODO: remove in next major release
isSameDay: PropTypes.func,
isSameUser: PropTypes.func,
dateFormat: PropTypes.string.isRequired,
dateFormat: PropTypes.string,
};
@@ -30,7 +30,17 @@ import MessageContainer from './MessageContainer';
import Send from './Send';
import Time from './Time';
import GiftedAvatar from './GiftedAvatar';
import { MIN_COMPOSER_HEIGHT, MAX_COMPOSER_HEIGHT, DEFAULT_PLACEHOLDER } from './Constants';
import Constants from './Constants';

const {
MIN_COMPOSER_HEIGHT,
MAX_COMPOSER_HEIGHT,
DEFAULT_PLACEHOLDER,
TIME_FORMAT,
DATE_FORMAT,
} = Constants;

console.warn(MIN_COMPOSER_HEIGHT, MAX_COMPOSER_HEIGHT);

class GiftedChat extends React.Component {
static append(currentMessages = [], messages, inverted = true) {
@@ -520,8 +530,8 @@ GiftedChat.defaultProps = {
user: {},
onSend: () => {},
locale: null,
timeFormat: 'LT',
dateFormat: 'll',
timeFormat: TIME_FORMAT,
dateFormat: DATE_FORMAT,
isAnimated: Platform.select({
ios: true,
android: false,
@@ -144,7 +144,7 @@ MessageText.defaultProps = {
textStyle: {},
linkStyle: {},
customTextStyle: {},
textProps: '',
textProps: {},
parsePatterns: () => [],
};

@@ -6,18 +6,18 @@ import { StyleSheet, Text, View, ViewPropTypes } from 'react-native';

import moment from 'moment';

export default function Time() {
import Colors from './Colors';
import Constants from './Constants';

const { TIME_FORMAT } = Constants;

export default function Time({ position, containerStyle, currentMessage, timeFormat }, context) {
return (
<View
style={[
styles[this.props.position].container,
this.props.containerStyle[this.props.position],
]}
>
<Text style={[styles[this.props.position].text, this.props.textStyle[this.props.position]]}>
{moment(this.props.currentMessage.createdAt)
.locale(this.context.getLocale())
.format(this.props.timeFormat)}
<View style={[styles[position].container, containerStyle[position]]}>
<Text style={[styles[position].text, textStyle[position]]}>

This comment has been minimized.

Copy link
@pentarex

pentarex Mar 16, 2018

Contributor

is this a mistake or am I missing something? Why the textStyle is not a property anymore?

This comment has been minimized.

Copy link
@xcarpentier

xcarpentier Mar 17, 2018

Author Collaborator

Good catch, can you make a PR?
Sorry πŸ™„

This comment has been minimized.

Copy link
@pentarex

pentarex Mar 17, 2018

Contributor

#797 is the issue #798 is the PR :)

{moment(currentMessage.createdAt)
.locale(context.getLocale())
.format(timeFormat)}
</Text>
</View>
);
@@ -41,7 +41,7 @@ const styles = {
...containerStyle,
},
text: {
color: '#aaa',
color: Colors.timeTextColor,
...textStyle,
},
}),
@@ -50,7 +50,7 @@ const styles = {
...containerStyle,
},
text: {
color: '#fff',
color: Colors.white,
...textStyle,
},
}),
@@ -67,6 +67,7 @@ Time.defaultProps = {
},
containerStyle: {},
textStyle: {},
timeFormat: TIME_FORMAT,
};

Time.propTypes = {
@@ -80,5 +81,5 @@ Time.propTypes = {
left: Text.propTypes.style,
right: Text.propTypes.style,
}),
timeFormat: PropTypes.string.isRequired,
timeFormat: PropTypes.string,
};

0 comments on commit 5b67203

Please sign in to comment.
You can’t perform that action at this time.