Commit ccdd2756 by bianca-camargo-machado

merge

2 parents 06a66ed3 e04415e2
......@@ -34,7 +34,7 @@ const AppNavigator = createStackNavigator(
Votar
},
{
initialRouteName: 'Inicio',
initialRouteName: 'Login',
defaultNavigationOptions: {
headerStyle: {
backgroundColor: 'transparent',
......
import React, { Component } from 'react';
import { View, Image, TouchableOpacity,Text, StyleSheet } from 'react-native';
import { View, Image, TouchableOpacity,Text, StyleSheet, KeyboardAvoidingView } from 'react-native';
import { auth } from '../config';
import InputEmail from '../components/InputEmail';
import InputSenha from '../components/InputSenha';
......@@ -30,11 +30,11 @@ export default class Login extends Component {
render(){
return(
<View style={styles.container}>
<KeyboardAvoidingView style={styles.container} behavior="padding" enabled number="2">
<View style={styles.loginContainer}>
<Image resizeMode="contain" style={styles.logo} source={require("../../assets/icon.png")} />
</View>
<View style={{flex: 1}}>
<View style={{flex: 3}}>
<InputEmail
autoCorrect={false}
label=" "
......@@ -59,14 +59,14 @@ export default class Login extends Component {
</Text>
</View>
<View style={{flex: 2, backgroundColor: 'white'}}>
<View style={{flex: 3, backgroundColor: 'white'}}>
<TouchableOpacity style={styles.loginButtonContainer}
onPress={() => {this.setState({ errorMessage: 'Por favor, aguarde.' }), this.handleLogin()}}>
<Text style={styles.loginButtonText}>Entrar</Text>
</TouchableOpacity>
</View>
</View>
</KeyboardAvoidingView>
);
}
......
import React, { Component } from 'react';
import { View, Text, StyleSheet, ScrollView } from 'react-native';
import { View, Text, StyleSheet, ScrollView, KeyboardAvoidingView } from 'react-native';
import { DocumentPicker } from 'expo';
import { app } from '../config';
import BotaoAnterior from '../components/BotaoAnterior';
......@@ -9,29 +9,28 @@ import Progresso from '../components/Progresso';
import InputTexto from '../components/InputTexto';
import BotaoEnvioArquivo from '../components/BotaoEnvioArquivo';
import styles from '../styles/estilos';
import {KeyboardAvoidingView} from 'react-native';
export default class QuestaoContexto extends Component {
constructor(props) {
super(props);
this.state = {
sala: {},
questoes: [],
loading: false,
loaded: false,
url_pdf: null,
url: ''
export default class QuestaoContexto extends Component {
constructor(props) {
super(props);
this.state = {
sala: {},
questoes: [],
loading: false,
loaded: false,
url_pdf: null,
url: ''
}
}
}
componentWillMount() {
const sala = this.props.navigation.getParam('sala', null);
const questoes = this.props.navigation.getParam('questao', null);
const sala = this.props.navigation.getParam('sala', null);
const questoes = this.props.navigation.getParam('questao', null);
if(sala)
this.setState({sala});
if(questoes)
this.setState({questoes});
if (sala)
this.setState({ sala });
if (questoes)
this.setState({ questoes });
}
static navigationOptions = {
title: '',
......@@ -40,27 +39,26 @@ constructor(props) {
handleFile = async () => {
let result = await DocumentPicker.getDocumentAsync({});
if (!result.cancelled) {
this.upload(result.uri, result.name)
.then(() =>
{
if (result.uri)
this.setState({ url_pdf: result.uri, loading: false, loaded: true });
})
.catch((error) => {
alert('Falha no upload, verifique a conexão.\n erro:', error);
});
}
if (!result.cancelled) {
this.upload(result.uri, result.name)
.then(() => {
if (result.uri)
this.setState({ url_pdf: result.uri, loading: false, loaded: true });
})
.catch((error) => {
alert('Falha no upload, verifique a conexão.\n erro:', error);
});
}
}
urlToBlob = (uri) => {
//reference: https://github.com/expo/expo/issues/2402
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onload = function() {
xhr.onload = function () {
resolve(xhr.response); // when BlobModule finishes reading, resolve with the blob
};
xhr.onerror = function() {
xhr.onerror = function () {
reject(new TypeError('Network request failed')); // error occurred, rejecting
};
xhr.responseType = 'blob'; // use BlobModule's UriHandler
......@@ -70,10 +68,10 @@ constructor(props) {
}
upload = async (uri, name) => {
if(uri) {
this.setState({loading: true, loaded: false});
if (uri) {
this.setState({ loading: true, loaded: false });
const blob = await this.urlToBlob(uri);
const ref = app.storage().ref().child('questao/pdfs/'+name);
const ref = app.storage().ref().child('questao/pdfs/' + name);
const snap = await ref.put(blob);
const remoteUri = await snap.ref.getDownloadURL();
......@@ -84,23 +82,23 @@ constructor(props) {
}
handleURL = (value) => {
this.setState({url: value});
this.setState({ url: value });
}
handleSubmit = () => {
const { url_pdf, url, sala } = this.state;
let { questoes } = this.state;
let questaoAtualizada;
if(url_pdf)
questaoAtualizada = Object.assign(questoes[questoes.length-2], {'url_pdf': url_pdf});
if(url)
questaoAtualizada = Object.assign(questoes[questoes.length-2], {'url': url});
if(questaoAtualizada) {
questoes[questoes.length-2] = questaoAtualizada;
let questaoAtualizada;
if (url_pdf)
questaoAtualizada = Object.assign(questoes[questoes.length - 2], { 'url_pdf': url_pdf });
if (url)
questaoAtualizada = Object.assign(questoes[questoes.length - 2], { 'url': url });
if (questaoAtualizada) {
questoes[questoes.length - 2] = questaoAtualizada;
}
this.setState({questoes: questoes});
this.setState({ questoes: questoes });
this.props.navigation.navigate('QuestaoSalva', {
sala: sala,
questoes: questoes
......@@ -110,68 +108,69 @@ constructor(props) {
render() {
const { loading, loaded, url, questoes } = this.state;
return (
<KeyboardAvoidingView style={styles.container} behavior="padding" enabled>
<KeyboardAvoidingView style={styles.containerKeyboard}
behavior="padding" enabled keyboardVerticalOffset={120}>
<ScrollView>
<View style={styles.container}>
<View styles={styles.innerContainer}>
<Text style={[contextStyles.titulo, contextStyles.titulo1]}>Dica:</Text>
<Text style={[contextStyles.titulo, contextStyles.titulo2]}>É importante contextualizar a sua pergunta para que os votantes entendam:</Text>
<View style={contextStyles.container}>
<View>
<Text style={[contextStyles.titulo3, {marginBottom: 15}]}>
Vamos adicionar um arquivo (Exemplo: PDF ou imagem) contextualizando a
<Text style={{color: '#8400C5'}}> questão {questoes.length-1}</Text>?
<View style={styles.container}>
<View styles={styles.innerContainer}>
<Text style={[contextStyles.titulo, contextStyles.titulo1]}>Dica:</Text>
<Text style={[contextStyles.titulo, contextStyles.titulo2]}>É importante contextualizar a sua pergunta para que os votantes entendam:</Text>
<View style={contextStyles.container}>
<View>
<Text style={[contextStyles.titulo3, { marginBottom: 15 }]}>
Vamos adicionar um arquivo (Exemplo: PDF ou imagem) contextualizando a
<Text style={{ color: '#8400C5' }}> questão {questoes.length - 1}</Text>?
</Text>
</View>
</View>
<View>
<BotaoEnvioArquivo
loaded={!!loaded}
loading={!!loading}
onPress={() => this.handleFile()}
texto="Anexar Arquivo"
/>
</View>
<View>
<Text style={[contextStyles.titulo3, contextStyles.titulo4]}>
Vamos adicionar um URL externo contextualizando a
<Text style={{ color: '#8400C5' }}> questão {questoes.length - 1}</Text>?
</Text>
</View>
<View>
<BotaoEnvioArquivo
loaded={!!loaded}
loading={!!loading}
onPress={() => this.handleFile()}
texto="Anexar Arquivo"
<InputTexto
label="URL:"
onChangeText={value => this.handleURL(value)}
placeholder='https://woopsicredi.com/'
value={url}
/>
</View>
</View>
<View>
<Text style={[contextStyles.titulo3, contextStyles.titulo4]}>
Vamos adicionar um URL externo contextualizando a
<Text style={{color: '#8400C5'}}> questão {questoes.length-1}</Text>?
</Text>
</View>
<View style={styles.flowButtonsContainer}>
<InputTexto
label="URL:"
onChangeText={value => this.handleURL(value)}
placeholder='https://woopsicredi.com/'
value={url}
<BotaoAnterior
endereco='Questao'
disabled={loading}
navigation={this.props.navigation}
style={styles.icon}
/>
<Progresso quantidade={4} total={5} />
<BotaoProximo
endereco='QuestaoSalva'
disabled={loading}
navigation={this.props.navigation}
style={styles.icon}
onPress={() => this.handleSubmit()}
/>
</View>
</View>
<View style={styles.flowButtonsContainer}>
<BotaoAnterior
endereco='Questao'
disabled={loading}
navigation={this.props.navigation}
style={styles.icon}
/>
<Progresso quantidade={4} total={5}/>
<BotaoProximo
endereco='QuestaoSalva'
disabled={loading}
navigation={this.props.navigation}
style={styles.icon}
onPress={() => this.handleSubmit()}
/>
</View>
</View>
</View>
</ScrollView>
</ScrollView>
</KeyboardAvoidingView>
);
}
}
......
......@@ -8,6 +8,11 @@ export default StyleSheet.create({
paddingLeft: 15,
paddingRight: 15
},
containerKeyboard: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
},
flowButtonsContainer: {
alignItems: 'center',
flexDirection: 'row',
......@@ -38,7 +43,7 @@ export default StyleSheet.create({
},
loginContainer:{
alignItems: 'center',
flexGrow: 1,
flex: 2,
justifyContent: 'center'
},
logo: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!