Skip to content

Commit d36107b

Browse files
authored
Configure Prettier (react-native-image-picker#945)
1 parent ac0c31a commit d36107b

File tree

6 files changed

+165
-139
lines changed

6 files changed

+165
-139
lines changed

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true,
4+
"arrowParens": "always"
5+
}

README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
A React Native module that allows you to use native UI to select a photo/video from the device library or directly from the camera, like so:
1010

11-
iOS | Android
12-
------- | ----
13-
<img title="iOS" src="https://github.com/react-community/react-native-image-picker/blob/master/images/ios-image.png"> | <img title="Android" src="https://github.com/react-community/react-native-image-picker/blob/master/images/android-image.png">
11+
| iOS | Android |
12+
| --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
13+
| <img title="iOS" src="https://github.com/react-community/react-native-image-picker/blob/master/images/ios-image.png"> | <img title="Android" src="https://github.com/react-community/react-native-image-picker/blob/master/images/android-image.png"> |
1414

1515
#### _Before you open an issue_
1616

@@ -33,9 +33,7 @@ import ImagePicker from 'react-native-image-picker';
3333
// More info on all the options is below in the API Reference... just some common use cases shown here
3434
const options = {
3535
title: 'Select Avatar',
36-
customButtons: [
37-
{name: 'fb', title: 'Choose Photo from Facebook'},
38-
],
36+
customButtons: [{ name: 'fb', title: 'Choose Photo from Facebook' }],
3937
storageOptions: {
4038
skipBackup: true,
4139
path: 'images',
@@ -51,14 +49,11 @@ ImagePicker.showImagePicker(options, (response) => {
5149

5250
if (response.didCancel) {
5351
console.log('User cancelled image picker');
54-
}
55-
else if (response.error) {
52+
} else if (response.error) {
5653
console.log('ImagePicker Error: ', response.error);
57-
}
58-
else if (response.customButton) {
54+
} else if (response.customButton) {
5955
console.log('User tapped custom button: ', response.customButton);
60-
}
61-
else {
56+
} else {
6257
const source = { uri: response.uri };
6358

6459
// You can also display the image using data:
@@ -69,9 +64,10 @@ ImagePicker.showImagePicker(options, (response) => {
6964
});
7065
}
7166
});
72-
7367
```
68+
7469
Then later, if you want to display this image in your render() method:
70+
7571
```javascript
7672
<Image source={this.state.avatarSource} style={styles.uploadAvatar} />
7773
```
@@ -83,12 +79,12 @@ do the following:
8379

8480
```javascript
8581
// Launch Camera:
86-
ImagePicker.launchCamera(options, (response) => {
82+
ImagePicker.launchCamera(options, (response) => {
8783
// Same code as in above section!
8884
});
8985

9086
// Open Image Library:
91-
ImagePicker.launchImageLibrary(options, (response) => {
87+
ImagePicker.launchImageLibrary(options, (response) => {
9288
// Same code as in above section!
9389
});
9490
```

docs/Install.md

Lines changed: 78 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Add the required permissions in `AndroidManifest.xml`:
4444

4545
### Android (Optional)
4646

47-
If you've defined *[project-wide properties](https://developer.android.com/studio/build/gradle-tips.html)* (**recommended**) in your root `build.gradle`, this library will detect the presence of the following properties:
47+
If you've defined _[project-wide properties](https://developer.android.com/studio/build/gradle-tips.html)_ (**recommended**) in your root `build.gradle`, this library will detect the presence of the following properties:
4848

4949
```groovy
5050
buildscript {...}
@@ -89,86 +89,93 @@ Customization settings of dialog `android/app/res/values/themes.xml` (`android/a
8989
1. Compile and have fun.
9090

9191
### Android
92+
9293
1. Add the following lines to `android/settings.gradle`:
93-
```gradle
94-
include ':react-native-image-picker'
95-
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
96-
```
94+
95+
```gradle
96+
include ':react-native-image-picker'
97+
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
98+
```
9799

98100
2. Update the android build tools version to `2.2.+` in `android/build.gradle`:
99-
```gradle
100-
buildscript {
101-
...
102-
dependencies {
103-
classpath 'com.android.tools.build:gradle:2.2.+' // <- USE 2.2.+ version
104-
}
105-
...
106-
}
107-
...
108-
```
101+
102+
```gradle
103+
buildscript {
104+
...
105+
dependencies {
106+
classpath 'com.android.tools.build:gradle:2.2.+' // <- USE 2.2.+ version
107+
}
108+
...
109+
}
110+
...
111+
```
109112

110113
3. Update the gradle version to `2.14.1` in `android/gradle/wrapper/gradle-wrapper.properties`:
111-
```
112-
...
113-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
114-
```
114+
115+
```
116+
...
117+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
118+
```
115119

116120
4. Add the compile line to the dependencies in `android/app/build.gradle`:
117-
```gradle
118-
dependencies {
119-
compile project(':react-native-image-picker')
120-
}
121-
```
121+
122+
```gradle
123+
dependencies {
124+
compile project(':react-native-image-picker')
125+
}
126+
```
122127

123128
5. Add the import and link the package in `MainApplication.java`:
124-
```java
125-
import com.imagepicker.ImagePickerPackage; // <-- add this import
126-
127-
public class MainApplication extends Application implements ReactApplication {
128-
@Override
129-
protected List<ReactPackage> getPackages() {
130-
return Arrays.<ReactPackage>asList(
131-
new MainReactPackage(),
132-
new ImagePickerPackage(), // <-- add this line
133-
// OR if you want to customize dialog style
134-
new ImagePickerPackage(R.style.my_dialog_style)
135-
);
136-
}
137-
}
138-
```
129+
130+
```java
131+
import com.imagepicker.ImagePickerPackage; // <-- add this import
132+
133+
public class MainApplication extends Application implements ReactApplication {
134+
@Override
135+
protected List<ReactPackage> getPackages() {
136+
return Arrays.<ReactPackage>asList(
137+
new MainReactPackage(),
138+
new ImagePickerPackage(), // <-- add this line
139+
// OR if you want to customize dialog style
140+
new ImagePickerPackage(R.style.my_dialog_style)
141+
);
142+
}
143+
}
144+
```
139145

140146
6. If `MainActivity` is not instance of `ReactActivity`, you will need to implement `OnImagePickerPermissionsCallback` to `MainActivity`:
141-
```java
142-
import com.imagepicker.permissions.OnImagePickerPermissionsCallback; // <- add this import
143-
import com.facebook.react.modules.core.PermissionListener; // <- add this import
144-
145-
public class MainActivity extends YourActivity implements OnImagePickerPermissionsCallback {
146-
private PermissionListener listener; // <- add this attribute
147-
148-
// Your methods here
149-
150-
// Copy from here
151-
152-
@Override
153-
public void setPermissionListener(PermissionListener listener)
154-
{
155-
this.listener = listener;
156-
}
157-
158-
@Override
159-
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
160-
{
161-
if (listener != null)
162-
{
163-
listener.onRequestPermissionsResult(requestCode, permissions, grantResults);
164-
}
165-
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
166-
}
167-
168-
// To here
169-
}
170-
```
171-
172-
This code allows to pass result of request permissions to native part.
147+
148+
```java
149+
import com.imagepicker.permissions.OnImagePickerPermissionsCallback; // <- add this import
150+
import com.facebook.react.modules.core.PermissionListener; // <- add this import
151+
152+
public class MainActivity extends YourActivity implements OnImagePickerPermissionsCallback {
153+
private PermissionListener listener; // <- add this attribute
154+
155+
// Your methods here
156+
157+
// Copy from here
158+
159+
@Override
160+
public void setPermissionListener(PermissionListener listener)
161+
{
162+
this.listener = listener;
163+
}
164+
165+
@Override
166+
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
167+
{
168+
if (listener != null)
169+
{
170+
listener.onRequestPermissionsResult(requestCode, permissions, grantResults);
171+
}
172+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
173+
}
174+
175+
// To here
176+
}
177+
```
178+
179+
This code allows to pass result of request permissions to native part.
173180

174181
7. Refer to [Post-install Steps](Install.md#post-install-steps).

0 commit comments

Comments
 (0)