Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Max#componente para grupo #172

Merged
merged 7 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Components/Chat/chatContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Chat = props => {
renderItem={({ item }) => {
return (
<Message
nomeRemetente={null}
chave={item.key}
destUserUid={destUserUid}
content={
Expand Down
24 changes: 20 additions & 4 deletions src/Components/mensagem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { PureComponent } from "react"
import { Svg, Path } from "react-native-svg"
import { View, Text, StyleSheet, TouchableOpacity, Alert } from "react-native"
import { moderateScale } from "react-native-size-matters"
import getColor from "~/functions/getColor"
import firebase from "react-native-firebase"

const cor = getColor()
const styles = StyleSheet.create({
// Estilo para a mensagem do remetente
remet: {
Expand Down Expand Up @@ -32,6 +34,7 @@ const styles = StyleSheet.create({
right: 5
},
textRemet: {
fontFamily: "Open Sans",
fontSize: 14,
color: "white"
},
Expand Down Expand Up @@ -64,13 +67,20 @@ const styles = StyleSheet.create({
marginBottom: 5,
padding: 10
},
nomeRemetente: {
fontFamily: "Open Sans",
fontSize: 12,
fontWeight: "bold",
color: cor
},
arrowDest: {
elevation: 5,
position: "absolute",
bottom: 0,
left: 5
},
textDest: {
fontFamily: "Open Sans",
fontSize: 14,
color: "black"
},
Expand All @@ -93,7 +103,8 @@ export default class Mensagem extends PureComponent {
content: "",
date: "",
source: "",
original: ""
original: "",
nomeRemetente: null
}
const userUid = firebase.auth().currentUser.uid
const { destUserUid } = this.props
Expand All @@ -107,9 +118,9 @@ export default class Mensagem extends PureComponent {
}

componentDidMount() {
const { chave, content, date, source, original } = this.props
const { chave, content, date, source, original, nomeRemetente } = this.props

this.setState({ chave, content, date, source, original })
this.setState({ chave, content, date, source, original, nomeRemetente })
}

alterarIdioma = chave => {
Expand Down Expand Up @@ -171,7 +182,7 @@ export default class Mensagem extends PureComponent {
}

render() {
const { content, date, source } = this.state
const { content, date, source, nomeRemetente } = this.state
let message
// Remetente
if (source === "1") {
Expand Down Expand Up @@ -225,6 +236,11 @@ export default class Mensagem extends PureComponent {
</Svg>
</View>
<View style={styles.boxDest}>
{nomeRemetente && (
<View>
<Text style={styles.nomeRemetente}>{nomeRemetente}</Text>
</View>
)}
<Text style={styles.textDest}>{content}</Text>
</View>
</TouchableOpacity>
Expand Down
17 changes: 17 additions & 0 deletions src/functions/getColor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable no-plusplus */
const getColor = () => {
const hexadecimais = "0123456789ABCDEF"
let cor = "#"
while (1) {
for (let i = 0; i < 6; i++) {
cor += hexadecimais[Math.floor(Math.random() * 16)]
}
if (cor === "#FFFFFF") {
cor = "#"
} else {
return cor
}
}
}

export default getColor