This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ react-native run-android | |
Starting JS server... | |
Building and installing the app on the device (cd android && gradlew.bat installDebug... | |
:app:preBuild UP-TO-DATE | |
:app:preDebugBuild UP-TO-DATE | |
:app:checkDebugManifest | |
:app:preReleaseBuild UP-TO-DATE | |
:react-native-fbsdk:compileLint | |
:react-native-fbsdk:copyReleaseLint UP-TO-DATE | |
:react-native-fbsdk:preBuild UP-TO-DATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: "com.android.application" | |
import com.android.build.OutputFile | |
apply from: "../../node_modules/react-native/react.gradle" | |
def enableSeparateBuildPerCPUArchitecture = false | |
def enableProguardInReleaseBuilds = false | |
android { | |
compileSdkVersion 23 | |
buildToolsVersion "23.0.1" | |
defaultConfig { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { AppRegistry, Text, View } from 'react-native'; | |
const options = { | |
enableHighAccuracy: true, | |
timeout: 10000, | |
maximumAge: 1000 | |
}; | |
const myPosition = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Componente do mapa -------------------------------- | |
import React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
import MapView from 'react-native-maps'; | |
import { StyleSheet, View, Text, Dimensions } from 'react-native'; | |
import { Spinner } from './common'; | |
import { setLocation } from '../actions'; | |
const { width, height } = Dimensions.get('window'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Instância do Firebase ('database' é o arquivo de configuração pra conectar) | |
const NewsInstance = firebase.initializeApp(database, 'NewsInstance'); | |
const grabData = (dispatch, target) => { | |
return NewsInstance.database().ref(`/company-news/${target}`) | |
.on('value', snap => { | |
console.log('Data: ', JSON.stringify(snap.val())); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const create = (userUID, customerObj) => { | |
return new Promise((resolve, reject) => { | |
const ref = database.ref('user_data').child(userUID).child('customers').push() | |
const key = ref.key; | |
ref.set(customerObj) | |
.then(() => { | |
resolve(key) | |
}) | |
.catch(e => { | |
reject(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getAll = (userUID) => { | |
return new Promise((resolve, reject) => { | |
const ref = database | |
.ref('user_data') | |
.child(userUID) | |
.child('customers') | |
.on('value', snap => { | |
(snap.val() ? resolve(snap.val()) : reject({'message': 'Empty Firebase node'})) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calcProgress() { | |
const percentage = ((100 / this.props.initial) * this.state.elapsed) / 100; | |
const current = this.props.initial - this.state.elapsed; | |
const elapsed = this.state.elapsed + 1000; | |
return this.setState({ percentage, current, elapsed }) | |
} | |
playButton() { | |
let interval = setInterval(this.calcProgress, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const checkOpenTasks = (uid) => (dispatch) => | |
new Promise((resolve, reject) => { | |
AsyncStorage.getItem(uid).then(item => { | |
if (item) { | |
const moments = Object.keys(JSON.parse(item)); | |
const last = Math.max.apply(null, moments); //Último moment mesclado ao objeto | |
const { action, initial, elapsed } = JSON.parse(item)[last] //Ação realizada pelo último moment mesclado | |
const now = moment.utc().valueOf(); //Moment presente | |
const extra = (now - last) - ((now - last) % 1000); //Arredondamento - detalhes no README.md | |
resolve({ action, initial, elapsed, extra }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentWillMount() { | |
this.props.getInitial(this.state.task); | |
this.props.checkOpenTasks(this.state.task) | |
.then((r) => { | |
if (r.action === 'play') { | |
this.setState({ elapsed: r.extra, status: 'running' }); | |
let interval = setInterval(this.calcProgress, 1000); | |
this.setState({ interval }); | |
//O interval só é definido depois pra que calcProgress não sobreescreva os dados do action creator | |
} else { |
OlderNewer