-
-
Notifications
You must be signed in to change notification settings - Fork 430
Expand file tree
/
Copy pathApp.jsx
More file actions
178 lines (169 loc) · 4.22 KB
/
App.jsx
File metadata and controls
178 lines (169 loc) · 4.22 KB
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
import { Ionicons } from "@expo/vector-icons";
import React, { useEffect, useState } from "react";
import {
Image,
SafeAreaView,
StyleSheet,
Switch,
Text,
TouchableOpacity,
View,
} from "react-native";
import {
CopilotProvider,
CopilotStep,
walkthroughable,
useCopilot,
} from "react-native-copilot";
const WalkthroughableText = walkthroughable(Text);
const WalkthroughableImage = walkthroughable(Image);
function App() {
const { start, copilotEvents } = useCopilot();
const [secondStepActive, setSecondStepActive] = useState(true);
const [lastEvent, setLastEvent] = useState(null);
useEffect(() => {
copilotEvents.on("stepChange", (step) => {
setLastEvent(`stepChange: ${step.name}`);
});
copilotEvents.on("start", () => {
setLastEvent(`start`);
});
copilotEvents.on("stop", () => {
setLastEvent(`stop`);
});
}, [copilotEvents]);
return (
<SafeAreaView style={styles.container}>
<CopilotStep
text="Hey! This is the first step of the tour!"
order={1}
name="openApp"
>
<WalkthroughableText style={styles.title}>
{'Welcome to the demo of\n"React Native Copilot"'}
</WalkthroughableText>
</CopilotStep>
<View style={styles.middleView}>
<CopilotStep
active={secondStepActive}
text="Here goes your profile picture!"
order={2}
name="secondText"
>
<WalkthroughableImage
source={{
uri: "https://pbs.twimg.com/profile_images/527584017189982208/l3wwN-l-_400x400.jpeg",
}}
style={styles.profilePhoto}
/>
</CopilotStep>
<View style={styles.activeSwitchContainer}>
<Text>Profile photo step activated?</Text>
<View style={{ flexGrow: 1 }} />
<Switch
onValueChange={(secondStepActive) =>
setSecondStepActive(secondStepActive)
}
value={secondStepActive}
/>
</View>
<TouchableOpacity style={styles.button} onPress={() => start()}>
<Text style={styles.buttonText}>START THE TUTORIAL!</Text>
</TouchableOpacity>
<View style={styles.eventContainer}>
<Text>{lastEvent && `Last event: ${lastEvent}`}</Text>
</View>
</View>
<View style={styles.row}>
<CopilotStep
text="Here is an item in the corner of the screen."
order={3}
name="thirdText"
>
<WalkthroughableText style={styles.tabItem}>
<Ionicons name="apps" size={25} color="#888" />
</WalkthroughableText>
</CopilotStep>
<Ionicons
style={styles.tabItem}
name="airplane"
size={25}
color="#888"
/>
<Ionicons
style={styles.tabItem}
name="ios-globe"
size={25}
color="#888"
/>
<Ionicons
style={styles.tabItem}
name="ios-navigate-outline"
size={25}
color="#888"
/>
<Ionicons
style={styles.tabItem}
name="ios-rainy"
size={25}
color="#888"
/>
</View>
</SafeAreaView>
);
}
const AppwithProvider = () => (
<CopilotProvider stopOnOutsideClick androidStatusBarVisible>
<App />
</CopilotProvider>
);
export default AppwithProvider;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
paddingTop: 25,
},
title: {
fontSize: 24,
textAlign: "center",
},
profilePhoto: {
width: 140,
height: 140,
borderRadius: 70,
marginVertical: 20,
},
middleView: {
flex: 1,
alignItems: "center",
},
button: {
backgroundColor: "#2980b9",
paddingVertical: 10,
paddingHorizontal: 15,
},
buttonText: {
color: "white",
fontSize: 16,
},
row: {
flexDirection: "row",
justifyContent: "space-between",
},
tabItem: {
flex: 1,
textAlign: "center",
},
activeSwitchContainer: {
flexDirection: "row",
justifyContent: "space-between",
marginBottom: 20,
alignItems: "center",
paddingHorizontal: 25,
},
eventContainer: {
marginTop: 20,
},
});