-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
134 lines (116 loc) · 3.5 KB
/
Copy pathexample.js
File metadata and controls
134 lines (116 loc) · 3.5 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
//@flow
import React from 'react'
import { Text, View, Animated } from 'react-native'
import { Font } from 'expo'
import { Entypo, Feather } from '@expo/vector-icons'
import styled from 'styled-components/native'
import { chunk } from 'lodash'
import PadLocker from './padlocker'
const DURATION = 10000
const VIBRATE_NOPE_PATTERN = [200, 400]
const Body = styled.View`
height: 100%;
padding: 20px 10px 0px 10px;
background: #21ce99;
flex-direction: column;
justify-content: space-between;
`
const LogoIcon = styled(Entypo)`
padding: 1px;
align-self: center;
margin-top: 40px;
flex: 1;
`
class FadeIn extends React.Component<
{ duration: number, style?: Object },
any
> {
state = {
fadeAnim: new Animated.Value(0), // Initial value for opacity: 0
}
componentDidMount() {
Animated.timing(
// Animate over time
this.state.fadeAnim, // The animated value to drive
{
toValue: 1, // Animate to opacity: 1 (opaque)
duration: this.props.duration || 1000, // Make it take a while
}
).start()
}
render() {
const { style, ...rest } = this.props
return (
<Animated.View // Special animatable View
style={{
opacity: this.state.fadeAnim, // Bind opacity to animated value
...style,
}}
{...rest}
/>
)
}
}
type AppState = {
loaded: boolean,
selected?: string,
status: string,
unlocked: boolean,
}
export default class App extends React.Component<{}, AppState> {
state = {
loaded: false,
unlocked: false,
selected: '',
status: '',
}
async handleFontLoad() {
try {
await Font.loadAsync({
roboto: require('./assets/fonts/Roboto-Light.ttf'),
robotoMed: require('./assets/fonts/Roboto-Medium.ttf'),
entypo: require('./node_modules/@expo/vector-icons/fonts/Entypo.ttf'),
})
this.setState({ loaded: true })
} catch (error) {
// alert('error loading font')
}
}
componentDidMount() {
this.handleFontLoad()
}
render() {
let { loaded } = this.state
if (!loaded) return null
return (
<PadLocker
correctPin={1111}
backgroundColor="#21ce99"
handleAfterLock={() => console.log('Unlocked')}
handleFailedAttempt={() => console.log('failed attempt')}
renderMainIcon={() => (
<LogoIcon name="bowl" size={70} color="white" />
)}
renderBackIcon={() => (
<Feather name="delete" size={30} color="white" />
)}
renderAfterUnlock={() => (
<FadeIn duration={1000}>
<Body>
<LogoIcon name="bowl" size={70} color="teal" />
<Text
style={{
flex: 1,
alignSelf: 'center',
fontSize: 40,
}}
>
Secrect area!!
</Text>
</Body>
</FadeIn>
)}
/>
)
}
}