-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMenu.tsx
67 lines (62 loc) · 2 KB
/
Menu.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as React from 'react';
import { ScrollView, View, Text } from 'react-native';
import { ListItem } from 'react-native-elements';
import { NavigationActions, NavigationInjectedProps } from 'react-navigation';
import { Geolocation, GeolocationPermissionStatus } from 'react-native-mo-geolocation';
export default class Menu extends React.PureComponent<NavigationInjectedProps, Menu['state']> {
public state: {
permission?: GeolocationPermissionStatus;
background?: boolean;
} = {
};
public render() {
return (
<ScrollView>
<ListItem
title="GpsInfo"
chevron={true}
onPress={() => {
this.props.navigation.dispatch(NavigationActions.navigate({ routeName: 'GpsInfo' }));
}}
/>
<View style={{ marginTop: 10 }}>
<Text>Permissions:</Text>
<ListItem
title="background"
switch={{
value: this.state.background,
onValueChange: (value) => this.setState({ background: value }),
}}
/>
<ListItem
title="permission"
rightTitle={`${this.state.permission}`}
onPress={() => {
Geolocation.showSettings();
}}
/>
<ListItem
title="request permissions"
onPress={async () => {
const res = await Geolocation.requestPermissions({ background: this.state.background });
this.setState({ permission: res });
}}
/>
<ListItem
title="get permission status"
onPress={async () => {
const res = await Geolocation.getPermissionStatus({ background: this.state.background });
this.setState({ permission: res });
}}
/>
<ListItem
title="open settings"
onPress={async () => {
await Geolocation.openSettings();
}}
/>
</View>
</ScrollView>
);
}
}