Skip to content

Commit

Permalink
day four - finish pages
Browse files Browse the repository at this point in the history
  • Loading branch information
christyanbrayan committed Mar 30, 2020
1 parent 1418e20 commit 002d70f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
Binary file modified backend/src/database/db.sqlite
Binary file not shown.
5 changes: 4 additions & 1 deletion mobile/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import React from 'react';
import 'intl'
import 'intl/locale-data/jsonp/pt-BR'

import React from 'react'

import Routes from './src/routes'

Expand Down
5 changes: 5 additions & 0 deletions mobile/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"expo": "~36.0.0",
"expo-constants": "~8.0.0",
"expo-mail-composer": "~8.0.0",
"intl": "^1.2.5",
"react": "~16.9.0",
"react-dom": "~16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
Expand Down
19 changes: 11 additions & 8 deletions mobile/src/pages/Detail/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Feather } from '@expo/vector-icons'
import { useNavigation } from '@react-navigation/native'
import { useNavigation, useRoute } from '@react-navigation/native'
import { View, Text, Image, TouchableOpacity, Linking } from 'react-native'
import * as MailComposer from 'expo-mail-composer'

Expand All @@ -10,22 +10,25 @@ import styles from './styles'

export default function Detail() {
const navigation = useNavigation()
const message = 'Olá APAD, estou entrando em contato pois gostaria de ajudar no caso "Cadelinha atropelada" com o valor de R$ 120,00'
const route = useRoute()

const incident = route.params.incident
const message = `Olá ${incident.name}, estou entrando em contato pois gostaria de ajudar no caso "${incident.title}" com o valor de "${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(incident.value)}" `

function navigateBack() {
navigation.goBack()
}

function sendMail() {
MailComposer.composeAsync({
subject: 'Herói do caso: Cadelinha atropelada',
recipients: ['diego@rocketseat.com.br'],
subject: `Herói do caso: ${incident.title}`,
recipients: [incident.email],
body: message,
})
}

function sendWhatsApp() {
Linking.openURL(`whatsapp://send?phone=556100000000&text=${message}`)
Linking.openURL(`whatsapp://send?phone=${incident.whatsapp}&text=${message}`)
}

return (
Expand All @@ -40,13 +43,13 @@ export default function Detail() {
<View style={styles.incident}>

<Text style={[styles.incidentProperty, { marginTop: 0 }]}> ONG: </Text>
<Text style={styles.incidentValue}> APAD </Text>
<Text style={styles.incidentValue}> {incident.name} de {incident.city}/{incident.uf} </Text>

<Text style={styles.incidentProperty}> CASO: </Text>
<Text style={styles.incidentValue}> Cadelinha atropelada </Text>
<Text style={styles.incidentValue}> {incident.title} </Text>

<Text style={styles.incidentProperty}> VALOR: </Text>
<Text style={styles.incidentValue}> 120,00 </Text>
<Text style={styles.incidentValue}> {Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(incident.value)} </Text>

</View>

Expand Down
15 changes: 9 additions & 6 deletions mobile/src/pages/Incidents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ import styles from './styles'

export default function Incidents() {
const [incidents, setIncidents] = useState([])
const [total, setTotal] = useState(0)

const navigation = useNavigation()

function navigateToDetail() {
navigation.navigate('Detail')
function navigateToDetail(incident) {
navigation.navigate('Detail', { incident })
}

async function loadIncidents() {
const response = await api.get('incidents')

setIncidents(response.data)
setTotal(response.headers['x-total-count'])
}

useEffect(() => {
Expand All @@ -32,7 +35,7 @@ export default function Incidents() {
<View style={styles.header}>
<Image source={logoImg} />
<Text style={styles.headerText}>
Total de <Text style={styles.headerTextBold}>0 casos</Text>.
Total de <Text style={styles.headerTextBold}>{total} casos</Text>.
</Text>
</View>
<Text style={styles.title}> Bem-vindo! </Text>
Expand All @@ -47,11 +50,11 @@ export default function Incidents() {
<Text style={styles.incidentValue}> {incident.title} </Text>

<Text style={styles.incidentProperty}> VALOR: </Text>
<Text style={styles.incidentValue}> {incident.value} </Text>
<Text style={styles.incidentValue}> {Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(incident.value)} </Text>

<TouchableOpacity style={styles.detailsButton} onPress={() => navigateToDetail()}>
<TouchableOpacity style={styles.detailsButton} onPress={() => navigateToDetail(incident)}>
<Text style={styles.detailsButtonText}> Ver mais detalhes </Text>
<Feather name="arrow-right" size={16} />
<Feather name="arrow-right" size={16} color='#e02041' />
</TouchableOpacity>
</View>
)} />
Expand Down

0 comments on commit 002d70f

Please sign in to comment.