diff --git a/App/app/App.js b/App/app/App.js index b4f401ee..06f3ae59 100755 --- a/App/app/App.js +++ b/App/app/App.js @@ -1,555 +1,504 @@ -import React, {Component} from 'react'; +import React, { Component } from "react"; import { - Platform, - StyleSheet, - Text, - View, - StatusBar, - Dimensions, - Image, - ActivityIndicator, - Button, - TouchableHighlight, - Keyboard, - ImageBackground, - LinearGradient, - TouchableOpacity, - TextInput, - NetInfo, - Animated + Platform, + StyleSheet, + Text, + View, + StatusBar, + Dimensions, + Image, + ActivityIndicator, + Button, + TouchableHighlight, + Keyboard, + ImageBackground, + LinearGradient, + TouchableOpacity, + TextInput, + NetInfo, + Animated +} from "react-native"; -} from 'react-native'; +import { bindActionCreators } from "redux"; +import { connect } from "react-redux"; -import {bindActionCreators} from 'redux'; -import {connect} from 'react-redux'; +import QRCodeScanner from "react-native-qrcode-scanner"; +import { UtilStyles } from "./assets/styles"; -import QRCodeScanner from 'react-native-qrcode-scanner'; -import {UtilStyles} from './assets/styles' +import * as Actions from "./store/actions"; -import * as Actions from './store/actions'; - -import {RkButton, RkTheme, RkText, RkTextInput} from 'react-native-ui-kitten'; +import { RkButton, RkTheme, RkText, RkTextInput } from "react-native-ui-kitten"; import Modal from "react-native-modal"; -import Router from './Router' +import Router from "./Router"; -import Icon from "react-native-vector-icons/Ionicons" +import Icon from "react-native-vector-icons/Ionicons"; const SCREEN_HEIGHT = Dimensions.get("window").height; const SCREEN_WIDTH = Dimensions.get("window").width; -import Swiper from 'react-native-swiper'; -var TimerMixin = require('react-timer-mixin'); +import Swiper from "react-native-swiper"; +var TimerMixin = require("react-timer-mixin"); function handleConnectivityChange() { console.log("asdasd"); - } - +} + class App extends Component { handleConnectivityChange = isConnected => { this.setState({ isConnected }); - } - _activate=()=>{ - - this.setState({ isModalVisible: !this.state.isModalVisible}); - this.scanner.reactivate(); - - } - _scanQr=()=>{ - this.props.openScannerLogin() - console.log(this.props.UI_loginScannerActive) - } - _tryLogin=()=>{ - - //console.log(this.state.text) - //this.scanner.reactivate(); - this.props.login(this.state.username, this.state.text); - - - - } - - _toggleModal = () => - this.setState({ isModalVisible: !this.state.isModalVisible }); - - constructor(props) { - - super(props); - - this.state = { - - token: {valid: false}, - tokenData: '', - onHold: true, - logged: false, - isModalVisible: false, - state : {text: ''}, - username:'QR code', - failedAttempt: false, - push:4, - UI_loginScannerActive:false, - userDetails:{username:'', password:''}, - isConnected: true - }; - - } - _print=()=>{ - console.log("hello") - this.setState({push:0}) - } - checkValue=(e)=>{ - console.log("check"+e) - } - _handleConnectionChange = (isConnected) => { - this.props.connectionState(true); - }; - - - componentDidMount() { - this.props.hold(); - NetInfo.isConnected.addEventListener('connectionChange', this.handleConnectivityChange); - - this.setState({isModalVisible: false}) - //verifica se o utilizador tem token guardado - this.props.checkUser(this.props.userDetails); - this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow); - this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide); - - - } - componentWillUnmount() { - NetInfo.isConnected.removeEventListener('connectionChange', this.handleConnectivityChange); - } - - _keyboardDidShow () { - //alert('Keyboard Shown'); - // this.setState({push:0}) - - } - - _keyboardDidHide () { - - //this.setState({push:4}) - - } - onSuccess = (e) => { - - // this.setState({ isModalVisible: !this.state.isModalVisible }); - // this.props.login(e.data, 'f8908cc0'); - this.props.closeLoginQRScan(); - this.setState({username:e.data}) - - console.log("QR code lido"); + }; + _activate = () => { + this.setState({ isModalVisible: !this.state.isModalVisible }); + this.scanner.reactivate(); + }; + _scanQr = () => { + this.props.openScannerLogin(); + console.log(this.props.UI_loginScannerActive); + }; + _tryLogin = () => { + //console.log(this.state.text) + //this.scanner.reactivate(); + this.props.login(this.state.username, this.state.text); + }; + _toggleModal = () => + this.setState({ isModalVisible: !this.state.isModalVisible }); + constructor(props) { + super(props); + this.state = { + token: { valid: false }, + tokenData: "", + onHold: true, + logged: false, + isModalVisible: false, + state: { text: "" }, + username: "QR code", + failedAttempt: false, + push: 4, + UI_loginScannerActive: false, + userDetails: { username: "", password: "" }, + isConnected: true, + modalOpen: false }; + } + _print = () => { + console.log("hello"); + this.setState({ push: 0 }); + }; + checkValue = e => { + console.log("check" + e); + }; + _handleConnectionChange = isConnected => { + this.props.connectionState(true); + }; - render() { - if (!this.state.isConnected) { - return ( - - cenas da vida - - ); - } - if (!this.props.logged && this.props.onHold) { + componentDidMount() { + //this.props.hold(); + NetInfo.isConnected.addEventListener( + "connectionChange", + this.handleConnectivityChange + ); + this.setState({ isModalVisible: false }); + //verifica se o utilizador tem token guardado + this.props.checkUser(this.props.userDetails); + this.keyboardDidShowListener = Keyboard.addListener( + "keyboardDidShow", + this._keyboardDidShow + ); + this.keyboardDidHideListener = Keyboard.addListener( + "keyboardDidHide", + this._keyboardDidHide + ); + } + componentWillUnmount() { + NetInfo.isConnected.removeEventListener( + "connectionChange", + this.handleConnectivityChange + ); + } - return ( - - - - - ) + _keyboardDidShow() { + //alert('Keyboard Shown'); + // this.setState({push:0}) + } - } - else - { + _keyboardDidHide() { + //this.setState({push:4}) + } + onSuccess = e => { + // this.setState({ isModalVisible: !this.state.isModalVisible }); + // this.props.login(e.data, 'f8908cc0'); + this.props.closeLoginQRScan(); + this.setState({ username: e.data }); - // console.log('token... '+ this.props.logged) + console.log("QR code lido"); + }; - //se existir token - - if (this.props.logged ) { - - return ( - - - ) - } - return ( - - - - - - - - - - - - - - - - - - - - - - - - {this.setState({searchString})}} - maxLength={15} - underlineColorAndroid="transparent" - /> - - - - - - Scan QR - - - - - - - this.setState({text})} - clearButtonMode='always' - value={this.state.text} - clearTextOnFocus={true} - onSubmitEditing={Keyboard.dismiss} - placeholder='Password' /> - - Entrar - - - - - - - - - - - - - - - - - - - - - - - Não sabes a password? - - - - Recuperar Password - - - - - - - - - - ); - - } + render() { + if (!this.state.isConnected) { + return ( + + cenas da vida + + ); } + if (!this.props.logged && this.props.onHold) { + return ( + + + + ); + } else { + // console.log('token... '+ this.props.logged) + + //se existir token + + if (this.props.logged) { + return ; + } + return ( + + + + + + + + + + + + + + { + this.setState({ searchString }); + }} + maxLength={15} + underlineColorAndroid="transparent" + /> + + + + Scan QR + + + + + this.setState({ text })} + clearButtonMode="always" + value={this.state.text} + clearTextOnFocus={true} + onSubmitEditing={Keyboard.dismiss} + placeholder="Password" + /> + + + Entrar + + + + + + + + + + + + + + + + + Não sabes a password? + + + + Recuperar Password + + + + + + + ); + } + } } +RkTheme.setType("RkButton", "dark", { + container: { + paddingTop: 10, + backgroundColor: "gray", -RkTheme.setType('RkButton', 'dark', { - container: { - paddingTop: 10, - backgroundColor: 'gray', - - borderRadius: 90, - } + borderRadius: 90 + } }); - const rectDimensions = SCREEN_WIDTH * 0.85; // this is equivalent to 255 from a 393 device width -const overlayColor = 'rgba(0,0,0,0.30)'; +const overlayColor = "rgba(0,0,0,0.30)"; const styles = { - cameraContainer:{ - // height: Dimensions.get('window').height , - }, - passwordInput:{ - borderRadius: 90, - - borderColor:'#bfbdbd', - borderWidth: 1, - marginTop:20, - marginBottom:20, - width:SCREEN_WIDTH*0.8, - - backgroundColor: 'white', + cameraContainer: { + // height: Dimensions.get('window').height , + }, + passwordInput: { + borderRadius: 90, - borderRadius: 90, - height: SCREEN_HEIGHT*0.08, - borderColor:'#bfbdbd', - borderWidth: 1, - paddingLeft:SCREEN_WIDTH*0.05, - - }, - scanQRText:{ + borderColor: "#bfbdbd", + borderWidth: 1, + marginTop: 20, + marginBottom: 20, + width: SCREEN_WIDTH * 0.8, - paddingTop:50 - // paddingTop:20, - + backgroundColor: "white", - }, - scanQR:{ - - //flexDirection: 'row', - paddingTop:5, - backgroundColor:10, - - width:80, - paddingLeft:10, - backgroundColor:'#f24b4b', - borderBottomRightRadius:90, - borderTopRightRadius:90, - height:'100%', - - }, - inputSection: { - - flexDirection: 'row', - backgroundColor: '#fff', - - backgroundColor: 'white', + borderRadius: 90, + height: SCREEN_HEIGHT * 0.08, + borderColor: "#bfbdbd", + borderWidth: 1, + paddingLeft: SCREEN_WIDTH * 0.05 + }, + scanQRText: { + paddingTop: 50 + // paddingTop:20, + }, + scanQR: { + //flexDirection: 'row', + paddingTop: 5, + backgroundColor: 10, - borderRadius: 90, - height: SCREEN_HEIGHT*0.08, - borderColor:'#bfbdbd', - borderWidth: 1, - + width: 80, + paddingLeft: 10, + backgroundColor: "#f24b4b", + borderBottomRightRadius: 90, + borderTopRightRadius: 90, + height: "100%" + }, + inputSection: { + flexDirection: "row", + backgroundColor: "#fff", - }, - searchIcon: { - paddingLeft:10 - }, + backgroundColor: "white", - input: { - - - - flex: 1, - paddingRight: 10, - - - paddingLeft: 0, - paddingLeft:SCREEN_WIDTH*0.05, - color: '#424242', - - }, - textRow:{ - marginBottom:40 - }, - loginContainer:{ - width: '100%', - height: '30%', - justifyContent: 'center', - alignItems: 'center' - }, - loginBtn:{ - marginTop:10, - marginBottom:20, - marginLeft: '25%', - - }, - - button: { - borderWidth:1, - borderColor:'rgba(0,0,0,0.2)', - alignItems:'center', - justifyContent:'center', - width:60, - height:60, - backgroundColor:'#fff', - borderRadius:100, - marginRight: 10, - marginLeft:10 - }, - footer: {}, + borderRadius: 90, + height: SCREEN_HEIGHT * 0.08, + borderColor: "#bfbdbd", + borderWidth: 1 + }, + searchIcon: { + paddingLeft: 10 + }, - buttons: { - flexDirection: 'row', - marginBottom: 24, - marginHorizontal: 24, - marginTop:24, - justifyContent: 'space-around', - - - }, + input: { + flex: 1, + paddingRight: 10, - logoContainer:{ + paddingLeft: 0, + paddingLeft: SCREEN_WIDTH * 0.05, + color: "#424242" + }, + textRow: { + marginBottom: 40 + }, + loginContainer: { + width: "100%", + height: "30%", + justifyContent: "center", + alignItems: "center" + }, + loginBtn: { + marginTop: 10, + marginBottom: 20, + marginLeft: "25%" + }, - width:'100%', - - justifyContent: 'center', - alignItems: 'center', - marginTop:200 + button: { + borderWidth: 1, + borderColor: "rgba(0,0,0,0.2)", + alignItems: "center", + justifyContent: "center", + width: 60, + height: 60, + backgroundColor: "#fff", + borderRadius: 100, + marginRight: 10, + marginLeft: 10 + }, + footer: {}, - }, + buttons: { + flexDirection: "row", + marginBottom: 24, + marginHorizontal: 24, + marginTop: 24, + justifyContent: "space-around" + }, - logo2:{ - - // flex: 1, - // resizeMode: 'contain', - width: 200, height: 200, + logoContainer: { + width: "100%", - }, - wrapper: { - }, - slide1: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: 'white', - }, - slide2: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: 'white', - }, - slide3: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - color:'black', - backgroundColor: 'white', - }, - text: { - color: '#fff', - fontSize: 30, - fontWeight: 'bold', - }, - recover: { - paddingTop: 10, - color: "red", - paddingBottom: 10 - }, - manual: {}, + justifyContent: "center", + alignItems: "center", + marginTop: 200 + }, - logo: { + logo2: { + // flex: 1, + // resizeMode: 'contain', + width: 200, + height: 200 + }, + wrapper: {}, + slide1: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "white" + }, + slide2: { + flex: 1, + justifyContent: "center", + alignItems: "center", + backgroundColor: "white" + }, + slide3: { + flex: 1, + justifyContent: "center", + alignItems: "center", + color: "black", + backgroundColor: "white" + }, + text: { + color: "#fff", + fontSize: 30, + fontWeight: "bold" + }, + recover: { + paddingTop: 10, + color: "red", + paddingBottom: 10 + }, + manual: {}, - height: SCREEN_HEIGHT * 0.35, - width: SCREEN_WIDTH, - backgroundColor: overlayColor, - }, - rectangleContainer: { + logo: { + height: SCREEN_HEIGHT * 0.35, + width: SCREEN_WIDTH, + backgroundColor: overlayColor + }, + rectangleContainer: { + flex: 1, + alignItems: "center", + justifyContent: "center", + backgroundColor: "transparent" + }, - flex: 1, - alignItems: "center", - justifyContent: "center", - backgroundColor: "transparent", + rectangle: { + height: rectDimensions, + width: rectDimensions, + alignItems: "center", + justifyContent: "center", + backgroundColor: "transparent" + }, - }, + topOverlay: { + flex: 1, + backgroundColor: overlayColor, + justifyContent: "center", + alignItems: "center" + }, - rectangle: { + bottomOverlay: { + flex: 1, + height: SCREEN_HEIGHT, + width: SCREEN_WIDTH, + backgroundColor: overlayColor, + paddingBottom: SCREEN_WIDTH * 0.2 + }, - height: rectDimensions, - width: rectDimensions, - alignItems: "center", - justifyContent: "center", - backgroundColor: "transparent" - }, - - topOverlay: { - flex: 1, - backgroundColor: overlayColor, - justifyContent: "center", - alignItems: "center" - }, - - bottomOverlay: { - flex: 1, - height: SCREEN_HEIGHT, - width: SCREEN_WIDTH, - backgroundColor: overlayColor, - paddingBottom: SCREEN_WIDTH * 0.2 - }, - - leftAndRightOverlay: { - height: rectDimensions, - width: SCREEN_WIDTH, - backgroundColor: overlayColor - }, + leftAndRightOverlay: { + height: rectDimensions, + width: SCREEN_WIDTH, + backgroundColor: overlayColor + } }; -RkTheme.setType('RkTextInput', 'frame', { - input: { - backgroundColor: 'white', - marginLeft: 0, - marginHorizontal: 0, - borderRadius: 5 - }, - color: 'gray', - backgroundColor: 'gray', - borderRadius: 10, - container: { - paddingHorizontal: 20 - } - }); - +RkTheme.setType("RkTextInput", "frame", { + input: { + backgroundColor: "white", + marginLeft: 0, + marginHorizontal: 0, + borderRadius: 5 + }, + color: "gray", + backgroundColor: "gray", + borderRadius: 10, + container: { + paddingHorizontal: 20 + } +}); + mapStateToProps = (state, props) => { - - return { - token: state.apiReducer.token, - loggedIn: state.apiReducer.loggedIn, - onHold: state.apiReducer.onHold, - logged: state.apiReducer.logged, - failedAttempt:state.apiReducer.failedAttempt, - UI_loginScannerActive: state.uiReducer.UI_loginScannerActive, - userDetails: state.apiReducer.userDetails, - } + return { + token: state.apiReducer.token, + loggedIn: state.apiReducer.loggedIn, + onHold: state.apiReducer.onHold, + logged: state.apiReducer.logged, + failedAttempt: state.apiReducer.failedAttempt, + UI_loginScannerActive: state.uiReducer.UI_loginScannerActive, + userDetails: state.apiReducer.userDetails, + modalOpen: state.apiReducer.modalOpen, + modalInfo: state.apiReducer.modalInfo, + type: state.apiReducer.type + }; }; -mapDispatchToProps = (dispatch) => { - - return bindActionCreators(Actions, dispatch); +mapDispatchToProps = dispatch => { + return bindActionCreators(Actions, dispatch); }; - -export default connect(mapStateToProps, mapDispatchToProps)(App); \ No newline at end of file +export default connect( + mapStateToProps, + mapDispatchToProps +)(App); diff --git a/App/app/screens/Eventos.js b/App/app/screens/Eventos.js index 9c10e7a8..043d39c4 100644 --- a/App/app/screens/Eventos.js +++ b/App/app/screens/Eventos.js @@ -1,61 +1,47 @@ -import * as React from 'react'; -import { - View, - StyleSheet, - Dimensions, - Text, - Button -} from 'react-native'; -import { TabView, TabBar, SceneMap } from 'react-native-tab-view'; - +import * as React from "react"; +import { View, StyleSheet, Dimensions, Text, Button } from "react-native"; +import { TabView, TabBar, SceneMap } from "react-native-tab-view"; const FirstRoute = () => ( - + ); const SecondRoute = () => ( - + ); - const ThirdRoute = () => ( - + ); const FourthRoute = () => ( - + ); - - - - -export default class Eventos extends React.Component { - +export default class Eventos extends React.Component { state = { - index: 0, - routes: [ - { key: 'first', title: 'Festarola' }, - { key: 'second', title: 'Febrada' }, - { key: 'third', title: 'Rally' }, - { key: 'fourth', title: 'Peddy' }, + index: 0, + routes: [ + { key: "first", title: "Festarola" }, + { key: "second", title: "Febrada" }, + { key: "third", title: "Rally" }, + { key: "fourth", title: "Peddy" } + ] + }; - ], -}; - -render() { - return ( - -