-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
181 lines (162 loc) · 4.08 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import React from 'react';
import { StyleSheet, Text, View, AsyncStorage, ActivityIndicator, Image } from 'react-native';
import { Container } from 'native-base';
import Swiper from 'react-native-swiper';
import AppIntroSlider from 'react-native-app-intro-slider';
import Timer from './Components/Timer';
import Data from './Components/Data';
import { LinearGradient } from 'expo-linear-gradient';
const slides = [
{
key: 1,
title: 'Thanks Downloading\n\nSportTimer',
text: '',
image: require('./assets/intro1.png'),
backgroundColor: '#59b2ab',
},
{
key: 2,
title: 'Sport Timer',
text: 'Will help you to improve your regularity\nin your training',
image: require('./assets/intro2.png'),
backgroundColor: '#febe29',
},
{
key: 3,
title: 'App in Beta',
text: 'Now, sport us !',
image: require('./assets/intro3.png'),
backgroundColor: '#19B1F0',
}
];
const styles = StyleSheet.create({
slideDefault: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
// backgroundColor: '#9DD6EB',
},
text: {
color: 'white',
fontSize: 30,
fontWeight: 'bold',
},
});
const style_slide = StyleSheet.create({
image: {
width: 200,
height: 200,
resizeMode: 'contain'
},
text: {
fontSize: 18,
color: 'white',
textAlign: 'center',
paddingVertical: 30,
},
title: {
fontSize: 25,
color: 'white',
textAlign: 'center',
fontWeight: 'bold',
marginBottom: 16,
},
});
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
showRealApp: false,
loading: true,
NbRepetitions: 3,
TimeExec: 45,
TimeRest: 15
};
this.getData = this.getData.bind(this)
}
componentDidMount() {
AsyncStorage.getItem('first_time').then((value) => {
this.setState({ showRealApp: !!value, loading: false});
})
}
_onDone = () => {
AsyncStorage.setItem('first_time', 'true').then(() => {
this.setState({ showRealApp: true});
// this.props.navigation.navigation('Home');
});
};
_onSkip = () => {
AsyncStorage.setItem('first_time', 'true').then(() => {
this.setState({ showRealApp: true });
// this.props.navigation.navigate('Home');
});
};
getData(nb, type) {
if (type == 'NbRepetitions') {
this.setState({
NbRepetitions: nb
});
}
if (type == 'TimeExec') {
this.setState({
TimeExec: nb
});
}
if (type == 'TimeRest') {
this.setState({
TimeRest: nb
});
}
}
_renderItem = ({ item }) => {
return (
<View
style={{
flex: 1,
backgroundColor: item.backgroundColor,
alignItems: 'center',
justifyContent: 'center',
paddingBottom: 100
}}>
<Text style={style_slide.title}>{item.title}</Text>
<Image style={style_slide.image} source={item.image} />
<Text style={style_slide.text}>{item.text}</Text>
</View>
);
}
render() {
if (this.state.showRealApp) {
return (
<Container>
<LinearGradient colors={['#5E9DD7', '#6785C6', '#4c669f', '#3b5998', '#192f6a']} style={{flex:1}}>
<Swiper
loop={false}
showsPagination={false}
index={1}
>
<View style={styles.slideDefault}>
<Data sendData={this.getData}></Data>
</View>
<View style={styles.slideDefault}>
<Timer NbRepetitions={this.state.NbRepetitions} TimeExec={this.state.TimeExec} TimeRest={this.state.TimeRest}></Timer>
</View>
<View style={styles.slideDefault}>
<Text style={styles.text}>Settings In Development</Text>
</View>
</Swiper>
</LinearGradient>
</Container>
);
} else {
return (
<Container>
<AppIntroSlider
renderItem={this._renderItem}
data={slides}
onDone={this._onDone}
/>
</Container>
)
}
}
}