Skip to content

Commit 9c3a907

Browse files
committed
Update example RN version
1 parent 8988150 commit 9c3a907

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5742
-2307
lines changed

example/.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/.buckconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/.flowconfig

Lines changed: 0 additions & 48 deletions
This file was deleted.

example/.gitignore

Lines changed: 0 additions & 53 deletions
This file was deleted.

example/.watchmanconfig

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/App.js

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22

3-
import React, { Component } from 'react'
3+
import React, {Component} from 'react';
4+
45
import {
56
StyleSheet,
67
TouchableHighlight,
@@ -9,38 +10,38 @@ import {
910
Alert,
1011
AppState,
1112
Platform,
12-
} from 'react-native'
13+
} from 'react-native';
1314

14-
import Permissions from 'react-native-permissions'
15+
import Permissions from 'react-native-permissions';
1516

1617
export default class App extends Component {
1718
state = {
1819
types: [],
1920
status: {},
20-
}
21+
};
2122

2223
componentDidMount() {
23-
let types = Permissions.getTypes()
24-
let canOpenSettings = Permissions.canOpenSettings()
24+
let types = Permissions.getTypes();
25+
let canOpenSettings = Permissions.canOpenSettings();
2526

26-
this.setState({ types, canOpenSettings })
27-
this._updatePermissions(types)
28-
AppState.addEventListener('change', this._handleAppStateChange)
27+
this.setState({types, canOpenSettings});
28+
this._updatePermissions(types);
29+
AppState.addEventListener('change', this._handleAppStateChange);
2930
}
3031

3132
componentWillUnmount() {
32-
AppState.removeEventListener('change', this._handleAppStateChange)
33+
AppState.removeEventListener('change', this._handleAppStateChange);
3334
}
3435

3536
//update permissions when app comes back from settings
3637
_handleAppStateChange = appState => {
3738
if (appState == 'active') {
38-
this._updatePermissions(this.state.types)
39+
this._updatePermissions(this.state.types);
3940
}
40-
}
41+
};
4142

4243
_openSettings = () =>
43-
Permissions.openSettings().then(() => alert('back to app!!'))
44+
Permissions.openSettings().then(() => alert('back to app!!'));
4445

4546
_updatePermissions = types => {
4647
Permissions.checkMultiple(types)
@@ -49,47 +50,47 @@ export default class App extends Component {
4950
return Permissions.check('location', 'always').then(location => ({
5051
...status,
5152
location,
52-
}))
53+
}));
5354
}
54-
return status
55+
return status;
5556
})
56-
.then(status => this.setState({ status }))
57-
}
57+
.then(status => this.setState({status}));
58+
};
5859

5960
_requestPermission = permission => {
60-
var options
61+
var options;
6162

6263
if (permission == 'location') {
63-
options = this.state.isAlways ? 'always' : 'whenInUse'
64+
options = this.state.isAlways ? 'always' : 'whenInUse';
6465
}
6566

6667
Permissions.request(permission, options)
6768
.then(res => {
6869
this.setState({
69-
status: { ...this.state.status, [permission]: res },
70-
})
70+
status: {...this.state.status, [permission]: res},
71+
});
7172
if (res != 'authorized') {
72-
var buttons = [{ text: 'Cancel', style: 'cancel' }]
73+
var buttons = [{text: 'Cancel', style: 'cancel'}];
7374
if (this.state.canOpenSettings)
7475
buttons.push({
7576
text: 'Open Settings',
7677
onPress: this._openSettings,
77-
})
78+
});
7879

7980
Alert.alert(
8081
'Whoops!',
8182
'There was a problem getting your permission. Please enable it from settings.',
8283
buttons,
83-
)
84+
);
8485
}
8586
})
86-
.catch(e => console.warn(e))
87-
}
87+
.catch(e => console.warn(e));
88+
};
8889

8990
_onLocationSwitchChange = () => {
90-
this.setState({ isAlways: !this.state.isAlways })
91-
this._updatePermissions(this.state.types)
92-
}
91+
this.setState({isAlways: !this.state.isAlways});
92+
this._updatePermissions(this.state.types);
93+
};
9394

9495
render() {
9596
return (
@@ -98,8 +99,7 @@ export default class App extends Component {
9899
<TouchableHighlight
99100
style={[styles.button, styles[this.state.status[p]]]}
100101
key={p}
101-
onPress={() => this._requestPermission(p)}
102-
>
102+
onPress={() => this._requestPermission(p)}>
103103
<View>
104104
<Text style={styles.text}>
105105
{Platform.OS == 'ios' && p == 'location'
@@ -113,8 +113,7 @@ export default class App extends Component {
113113
<View style={styles.footer}>
114114
<TouchableHighlight
115115
style={styles['footer_' + Platform.OS]}
116-
onPress={this._onLocationSwitchChange}
117-
>
116+
onPress={this._onLocationSwitchChange}>
118117
<Text style={styles.text}>Toggle location type</Text>
119118
</TouchableHighlight>
120119

@@ -131,7 +130,7 @@ export default class App extends Component {
131130
crash. This is normal on iOS. Google "ios crash permission change"
132131
</Text>
133132
</View>
134-
)
133+
);
135134
}
136135
}
137136

@@ -179,4 +178,4 @@ const styles = StyleSheet.create({
179178
height: 0,
180179
width: 0,
181180
},
182-
})
181+
});

example/__tests__/index.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

example/android/app/BUCK

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
# - `buck install -r android/app` - compile, install and run application
99
#
1010

11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
1113
lib_deps = []
1214

13-
for jarfile in glob(['libs/*.jar']):
14-
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15-
lib_deps.append(':' + name)
16-
prebuilt_jar(
17-
name = name,
18-
binary_jar = jarfile,
19-
)
15+
create_aar_targets(glob(["libs/*.aar"]))
2016

21-
for aarfile in glob(['libs/*.aar']):
22-
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23-
lib_deps.append(':' + name)
24-
android_prebuilt_aar(
25-
name = name,
26-
aar = aarfile,
27-
)
17+
create_jar_targets(glob(["libs/*.jar"]))
2818

2919
android_library(
3020
name = "all-libs",
@@ -45,12 +35,12 @@ android_library(
4535

4636
android_build_config(
4737
name = "build_config",
48-
package = "com.example",
38+
package = "com.rnpermissionsexample",
4939
)
5040

5141
android_resource(
5242
name = "res",
53-
package = "com.example",
43+
package = "com.rnpermissionsexample",
5444
res = "src/main/res",
5545
)
5646

0 commit comments

Comments
 (0)