-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
124 lines (111 loc) · 2.87 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import React from 'react';
import {styles,colors} from './Styles';
import LoginScreen from './views/LoginScreen';
import ListOrdersScreen from './views/ListOrdersScreen';
import ListFreeOrdersScreen from './views/ListFreeOrdersScreen';
import OrderDetailsScreen from './views/OrderDetailsScreen';
import FreeOrderDetailsScreen from './views/FreeOrderDetailsScreen';
import MapScreen from './views/MapScreen';
import {Location} from 'expo';
import {View, Text, Platform, StatusBar} from 'react-native';
import Tabs from 'react-native-tabs';
import {StackNavigator, TabNavigator} from 'react-navigation';
import API from './helpers/net';
//////// NAVI STUFF //////////////////
const OrderNavi = StackNavigator({
Orders: { screen: ListOrdersScreen },
OrderDetails: { screen: OrderDetailsScreen }
},{
headerMode : 'float'
});
const FreeOrderNavi = StackNavigator({
Orders: { screen: ListFreeOrdersScreen },
OrderDetails: { screen: FreeOrderDetailsScreen }
},{
headerMode : 'float'
});
const HomeStack = TabNavigator({
OrdersStack: {
screen: FreeOrderNavi,
navigationOptions: {
title: 'Ελεύθερες Παραγγελίες',
}
},
MyOrders: {
screen: OrderNavi,
navigationOptions: {
title: 'Οι παραγγελίες μου',
}
},
Map: {
screen: MapScreen,
navigationOptions: {
title: 'Χάρτης',
}
}
}, {
tabBarPosition: 'bottom',
animationEnabled: true,
tabBarOptions: {
activeTintColor: colors.white,
style: {
backgroundColor: colors.secondary,
}
}
});
const RootNavi = StackNavigator({
Login : {
screen : LoginScreen
},
HomeStack : {
screen : HomeStack
}
}, {
headerMode : 'none',
cardStyle: {
backgroundColor : '#000'
}
});
//////////////////////////////////////////////
//////// END OF NAVI STUFF //////////////////
////////////////////////////////////////////
//////// TRACKING STUFF ///////////////////
//////////////////////////////////////////
const DEBUG = false;
const info = (m) => {
if(DEBUG)console.log(m);
}
const saveLocation = (coords) => {
info("Location to be saved!");
info(coords);
//check token first!
API.postWithToken('log/mylocation', coords);
}
let Watcher = null;
const setupTracking = () => {
Watcher = Location.watchPositionAsync({
timeInterval: 10000,
distanceInterval: 50
}, saveLocation);
}
const disableTracking = () => {
if(Watcher !== null)
Watcher.remove();
}
////////////////////////////////////////////
//////// END OF TRACKING STUFF ///////////////////
//////////////////////////////////////////
class App extends React.Component {
constructor(props){
super(props);
this.state = {page:'second'};
}
componentWillMount() { setupTracking() }
componentWillUnmount() { disableTracking() }
render() {
return (
<RootNavi styles={styles.mainContainer}/>
);
}
}
export default App;