-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
61 lines (52 loc) · 2.16 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
import React, { useState, useEffect } from "react"
import { StatusBar, View } from "react-native"
import PagerView from 'react-native-pager-view';
import { styles } from "./src/Screens/styles";
import { ChooseGirl, Goals, Chat, Interests, LoadingGirl, Personality, SetName, Welcome } from "./src/Screens";
let interval = null
export default function App(){
const sliderRef = React.useRef();
const [ active, setActive ] = useState(0)
const [ percentage, setPercentage ] = useState(0)
const goToIndex = (index) => {
sliderRef?.current?.setPage(parseInt(index))
}
const pageScroll = (e) => {
setActive(e.nativeEvent.position)
}
useEffect(() => {
if(active === 6){
interval = setInterval(function () {
setPercentage(s => (s + 10))
}, 1000);
}else{
clearInterval(interval)
}
return () => {
clearInterval(interval)
};
}, [active])
useEffect(() => {
if(percentage > 99){
setPercentage(0)
goToIndex(7)
}
}, [percentage])
return(
<View style={styles.container}>
<StatusBar barStyle="dark-content" translucent backgroundColor="transparent" />
<View style={styles.container}>
<PagerView onPageSelected={pageScroll} scrollEnabled={false} style={styles.container} ref={sliderRef} initialPage={0}>
<Welcome goNext={() => goToIndex(1)} />
<ChooseGirl goNext={() => goToIndex(2)} goBack={() => goToIndex(0)} />
<Personality goNext={() => goToIndex(3)} goBack={() => goToIndex(1)} />
<SetName goNext={() => goToIndex(4)} goBack={() => goToIndex(2)} />
<Interests goNext={() => goToIndex(5)} goBack={() => goToIndex(3)} />
<Goals goNext={() => goToIndex(6)} goBack={() => goToIndex(4)} />
<LoadingGirl percentage={percentage} goBack={() => goToIndex(5)} />
<Chat goBack={() => goToIndex(5)} />
</PagerView>
</View>
</View>
)
}