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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
import React, {useState} from 'react'
import {
Animated,
Image,
SafeAreaView,
StyleSheet,
TouchableOpacity,
useWindowDimensions,
View,
} from 'react-native'
import {TabView, SceneMap, Route, TabBarProps} from 'react-native-tab-view'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Text} from '../util/text/Text'
import {UserGroupIcon} from '../../lib/icons'
import {useStores} from '../../../state'
import {s} from '../../lib/styles'
import {SCENE_EXPLAINER, TABS_EXPLAINER} from '../../lib/assets'
import {TABS_ENABLED} from '../../../build-flags'
const Intro = () => (
<View style={styles.explainer}>
<Text
style={[
styles.explainerHeading,
s.normal,
{lineHeight: 60, paddingTop: 50, paddingBottom: 50},
]}>
Welcome to <Text style={[s.bold, s.blue3, {fontSize: 56}]}>Bluesky</Text>
</Text>
<Text style={[styles.explainerDesc, {fontSize: 24}]}>
Let's do a quick tour through the new features.
</Text>
</View>
)
const Scenes = () => (
<View style={styles.explainer}>
<View style={styles.explainerIcon}>
<View style={s.flex1} />
<UserGroupIcon style={s.black} size="48" />
<View style={s.flex1} />
</View>
<Text style={styles.explainerHeading}>Scenes</Text>
<Text style={styles.explainerDesc}>
Scenes are invite-only groups of users. Follow them to see what's trending
with the scene's members.
</Text>
<Text style={styles.explainerDesc}>
<Image source={SCENE_EXPLAINER} style={styles.explainerImg} />
</Text>
</View>
)
const Tabs = () => (
<View style={styles.explainer}>
<View style={styles.explainerIcon}>
<View style={s.flex1} />
<FontAwesomeIcon
icon={['far', 'clone']}
style={[s.black, s.mb5]}
size={36}
/>
<View style={s.flex1} />
</View>
<Text style={styles.explainerHeading}>Tabs</Text>
<Text style={styles.explainerDesc}>
Never lose your place! Long-press to open posts and profiles in a new tab.
</Text>
<Text style={styles.explainerDesc}>
<Image source={TABS_EXPLAINER} style={styles.explainerImg} />
</Text>
</View>
)
const SCENE_MAP = {
intro: Intro,
scenes: Scenes,
tabs: Tabs,
}
const renderScene = SceneMap(SCENE_MAP)
export const FeatureExplainer = () => {
const layout = useWindowDimensions()
const store = useStores()
const [index, setIndex] = useState(0)
const routes = [
{key: 'intro', title: 'Intro'},
{key: 'scenes', title: 'Scenes'},
TABS_ENABLED ? {key: 'tabs', title: 'Tabs'} : undefined,
].filter(Boolean)
const onPressSkip = () => store.onboard.next()
const onPressNext = () => {
if (index >= routes.length - 1) {
store.onboard.next()
} else {
setIndex(index + 1)
}
}
const renderTabBar = (props: TabBarProps<Route>) => {
const inputRange = props.navigationState.routes.map((x, i) => i)
return (
<View style={styles.tabBar}>
<View style={s.flex1} />
{props.navigationState.routes.map((route, i) => {
const opacity = props.position.interpolate({
inputRange,
outputRange: inputRange.map(inputIndex =>
inputIndex === i ? 1 : 0.5,
),
})
return (
<TouchableOpacity
key={i}
style={styles.tabItem}
onPress={() => setIndex(i)}>
<Animated.Text style={{opacity}}>°</Animated.Text>
</TouchableOpacity>
)
})}
<View style={s.flex1} />
</View>
)
}
const FirstExplainer = SCENE_MAP[routes[0]?.key as keyof typeof SCENE_MAP]
return (
<SafeAreaView style={styles.container}>
{routes.length > 1 ? (
<TabView
navigationState={{index, routes}}
renderScene={renderScene}
renderTabBar={renderTabBar}
onIndexChange={setIndex}
initialLayout={{width: layout.width}}
tabBarPosition="bottom"
/>
) : FirstExplainer ? (
<FirstExplainer />
) : (
<View />
)}
<View style={styles.footer}>
<TouchableOpacity onPress={onPressSkip}>
<Text style={[s.blue3, s.f18]}>Skip</Text>
</TouchableOpacity>
<View style={s.flex1} />
<TouchableOpacity onPress={onPressNext}>
<Text style={[s.blue3, s.f18]}>Next</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
tabBar: {
flexDirection: 'row',
},
tabItem: {
alignItems: 'center',
padding: 16,
},
explainer: {
flex: 1,
paddingHorizontal: 16,
paddingTop: 80,
},
explainerIcon: {
flexDirection: 'row',
},
explainerHeading: {
fontSize: 42,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 16,
},
explainerDesc: {
fontSize: 18,
textAlign: 'center',
marginBottom: 16,
},
explainerImg: {
resizeMode: 'contain',
maxWidth: '100%',
maxHeight: 330,
},
footer: {
flexDirection: 'row',
paddingHorizontal: 32,
paddingBottom: 24,
},
})
|