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

Commit

Permalink
Merge branch 'dev' into neto#pushNotificationsEnable/Disable
Browse files Browse the repository at this point in the history
  • Loading branch information
netochaves authored Jun 1, 2019
2 parents a7ced9c + a10d287 commit 4ca9a57
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 42 deletions.
4 changes: 2 additions & 2 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ return (exports.sendPushNotification = functions.firestore
.catch(error => console.log(error))

const { contactName, contactPhoto } = data
if (source === "2") {
if (source === "1") {
const payload = {
data: {
conversaId
},
notification: {
title: contactName,
body: contentTranslated,
body: content,
sound: "default",
android_channel_id: "main-channel",
collapseKey: "unichat",
Expand Down
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
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import React from "react"

import "~/config/ReactotronConfig"
import firebase from "react-native-firebase"

import Routes from "~/routes"
import { createRootNavigator } from "~/routes"

const App = () => <Routes />
const App = () => {
let isAuth
firebase.auth().onAuthStateChanged(user => {
isAuth = user != null
})
const Routes = createRootNavigator(isAuth)
return <Routes />
}

export default App
90 changes: 56 additions & 34 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from "react"
import {
createAppContainer,
createStackNavigator,
createMaterialTopTabNavigator
createMaterialTopTabNavigator,
createSwitchNavigator
} from "react-navigation"
import PerfilSettings from "~/Screens/PerfilSettings/perfilsettings"
import PreviewImage from "~/Screens/PreviewImage/previewImg"
Expand All @@ -14,17 +15,8 @@ import Conversas from "~/Screens/Conversas/conversas"
import Settings from "~/Screens/Config/config"
import EditPerfil from "~/Screens/EditPerfil/editperfil"
import Languages from "~/Screens/Languages/languages"
import { Icon } from "react-native-elements"
import firebase from "react-native-firebase"

let rota = "AuthScreen"
firebase.auth().onAuthStateChanged(user => {
if (user) {
rota = "Conversas"
} else {
rota = "AuthScreen"
}
})
import { Icon } from "react-native-elements"

const tabBarNavigator = createMaterialTopTabNavigator(
{
Expand Down Expand Up @@ -84,69 +76,99 @@ const tabBarNavigator = createMaterialTopTabNavigator(
}
}
)
const appStackNavigator = createStackNavigator(

const HomeStackNavigator = createStackNavigator(
{
AuthScreen: {
screen: Auth,
SettingsScreen: {
screen: tabBarNavigator,
navigationOptions: {
header: null
}
},
PerfilSettings: {
screen: PerfilSettings,
EditPerfilScreen: {
screen: EditPerfil,
navigationOptions: {
header: null
}
},
PreviewImage: {
screen: PreviewImage,
LanguagesScreen: {
screen: Languages,
navigationOptions: {
title: "Tela de Idiomas",
headerTitleStyle: {
fontWeight: "normal"
}
}
},
VerificationScreen: {
screen: Verification,
Contacts: {
screen: tabBarNavigator,
navigationOptions: {
header: null
}
},
Conversas: {
screen: tabBarNavigator,

ChatScreen: {
screen: Chat,
navigationOptions: {
header: null
}
},
ContactsScreen: {
Conversas: {
screen: tabBarNavigator,
navigationOptions: {
header: null
}
},
ChatScreen: {
screen: Chat,
}
},
{
initialRouteName: "Conversas"
},
{ header: null }
)

const authStackNavigator = createStackNavigator(
{
AuthScreen: {
screen: Auth,
navigationOptions: {
header: null
}
},
SettingsScreen: {
screen: tabBarNavigator,
PerfilSettings: {
screen: PerfilSettings,
navigationOptions: {
header: null
}
},
EditPerfilScreen: {
screen: EditPerfil,
PreviewImage: {
screen: PreviewImage
},
VerificationScreen: {
screen: Verification,
navigationOptions: {
header: null
}
},
LanguagesScreen: {
screen: Languages,
Conversas: {
screen: tabBarNavigator,
navigationOptions: {
header: null
}
}
},
{
initialRouteName: rota
initialRouteName: "AuthScreen"
},
{ header: null }
)
export default createAppContainer(appStackNavigator)
export const createRootNavigator = (isAuth = false) => {
return createAppContainer(
createSwitchNavigator(
{
Home: HomeStackNavigator,
Auth: authStackNavigator
},
{ initialRouteName: isAuth ? "Home" : "Auth" }
)
)
}

0 comments on commit 4ca9a57

Please sign in to comment.