-
Notifications
You must be signed in to change notification settings - Fork 2
/
example.js
60 lines (52 loc) · 1.72 KB
/
example.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 from 'react'
import { ActivityIndicator, Button, StyleSheet, Text, View } from 'react-native'
import { Location } from './src'
class LocationExample extends React.PureComponent {
state = {
isLoading: false,
}
_requestPermission = async () => {
try {
this.setState({ isLoading: true })
await this.props.requestLocationPermission()
} finally {
this.setState({ isLoading: false })
}
}
render() {
const { test, locationPermission, requestLocationPermission } = this.props
const { isLoading } = this.state
return (
<View style={ styles.container }>
<Text>
{ 'havePermission: ' + locationPermission }
</Text>
<Text>
{ test }
</Text>
<Button
title={ locationPermission === Location.Permission.RESULT.GRANTED ? 'good to go' : 'request permisssion' }
style={ { alignSelf: 'center', marginTop: 50 } }
onPress={ this._requestPermission }
/>
{
isLoading &&
<ActivityIndicator
style={ StyleSheet.absoluteFill }
animating={ true }
size={ 'large' }
/>
}
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'space-between',
alignItems: 'center',
marginVertical: 150,
}
})
export default Location.WithPermission(LocationExample)