-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStep1Page.tsx
48 lines (42 loc) · 1.16 KB
/
Step1Page.tsx
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
import { useFlow } from "@bam.tech/flow-navigator";
import { Button, Text, View } from "react-native";
import { useAppContext } from "./flow";
export const Step1Page = () => {
const {
goToNextStep,
goToPreviousStep,
canGoToNextStep,
canGoToPreviousStep,
quitFlow,
} = useFlow();
const { setStep2Enabled, step2Enabled } = useAppContext();
const goNext = async () => {
setStep2Enabled(true);
// canGoToNextStep is not enabled here?
if (canGoToNextStep) {
goToNextStep();
} else {
console.warn(
"Should not happen because we enable step 2 first so we can always go to a next step"
);
}
};
const goBack = () => {
if (canGoToPreviousStep) {
goToPreviousStep();
} else {
quitFlow();
}
};
const toggleNextScreen = () => {
setStep2Enabled(!step2Enabled);
};
return (
<View>
<Text>Step 2 enabled:{step2Enabled ? "YES" : "NO"}</Text>
<Button title="Toggle next screen" onPress={toggleNextScreen} />
<Button title="Enable step 2 and go to next page" onPress={goNext} />
<Button title="Go to previous page" onPress={goBack} />
</View>
);
};