Skip to content

Commit 47521c1

Browse files
authored
Merge pull request #351 from react-native-community/@vonovak/actually-use-prettier
enable prettier by default
2 parents d540dfb + c228a97 commit 47521c1

File tree

7 files changed

+71
-66
lines changed

7 files changed

+71
-66
lines changed

.prettierrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
2-
"requirePragma": true,
32
"singleQuote": true,
43
"trailingComma": "all",
54
"bracketSpacing": false,
6-
"jsxBracketSameLine": true,
7-
"parser": "flow"
5+
"jsxBracketSameLine": true
86
}

example/App.js

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Basic [iOS] Example for react-native-blur
33
* https://github.com/react-native-community/react-native-blur
44
*/
5-
import React, { Component } from 'react';
5+
import React, {Component} from 'react';
66
import {
77
Image,
88
SegmentedControlIOS,
@@ -13,7 +13,7 @@ import {
1313
View,
1414
} from 'react-native';
1515

16-
import { BlurView, VibrancyView } from '@react-native-community/blur';
16+
import {BlurView, VibrancyView} from '@react-native-community/blur';
1717

1818
export default class Basic extends Component {
1919
constructor(props) {
@@ -37,7 +37,9 @@ export default class Basic extends Component {
3737
}
3838

3939
_onVibrancyChange(event) {
40-
this.setState({vibrancyActiveSegment: event.nativeEvent.selectedSegmentIndex});
40+
this.setState({
41+
vibrancyActiveSegment: event.nativeEvent.selectedSegmentIndex,
42+
});
4143
}
4244

4345
_onVibrancyValueChange(value) {
@@ -62,17 +64,22 @@ export default class Basic extends Component {
6264
blurAmount={100}
6365
reducedTransparencyFallbackColor={'pink'}
6466
style={[styles.blurView]}>
65-
<Text style={[styles.text, { color: tintColor }]}>
67+
<Text style={[styles.text, {color: tintColor}]}>
6668
Blur component ({platform})
6769
</Text>
68-
{Platform.OS === 'ios' &&
69-
<SegmentedControlIOS
70-
values={['xlight', 'light', 'dark', 'regular', 'prominent']}
71-
selectedIndex={this.state.blurActiveSegment}
72-
onChange={(event) => {this._onBlurChange(event);}}
73-
onValueChange={(value) => {this._onBlurValueChange(value);}}
74-
tintColor={tintColor}
75-
/>}
70+
{Platform.OS === 'ios' && (
71+
<SegmentedControlIOS
72+
values={['xlight', 'light', 'dark', 'regular', 'prominent']}
73+
selectedIndex={this.state.blurActiveSegment}
74+
onChange={(event) => {
75+
this._onBlurChange(event);
76+
}}
77+
onValueChange={(value) => {
78+
this._onBlurValueChange(value);
79+
}}
80+
tintColor={tintColor}
81+
/>
82+
)}
7683
</BlurView>
7784
</View>
7885

@@ -81,48 +88,49 @@ export default class Basic extends Component {
8188
VibrancyView is only supported on iOS, and must contain child views,
8289
otherwise the vibrancy effect doesn't work.
8390
*/
84-
Platform.OS === 'ios' &&
85-
<VibrancyView
86-
blurType={this.state.vibrancyBlurType}
87-
blurAmount={10}
88-
reducedTransparencyFallbackColor={'pink'}
89-
style={[styles.container, styles.blurContainer]}>
90-
91-
<Text style={styles.text}>
92-
Vibrancy component (iOS-only)
93-
</Text>
94-
95-
<SegmentedControlIOS
96-
values={['xlight', 'light', 'dark', 'regular', 'prominent']}
97-
selectedIndex={this.state.vibrancyActiveSegment}
98-
onChange={(event) => {this._onVibrancyChange(event);}}
99-
onValueChange={(value) => {this._onVibrancyValueChange(value);}}
100-
tintColor="white"
101-
/>
102-
</VibrancyView>
91+
Platform.OS === 'ios' && (
92+
<VibrancyView
93+
blurType={this.state.vibrancyBlurType}
94+
blurAmount={10}
95+
reducedTransparencyFallbackColor={'pink'}
96+
style={[styles.container, styles.blurContainer]}>
97+
<Text style={styles.text}>Vibrancy component (iOS-only)</Text>
98+
99+
<SegmentedControlIOS
100+
values={['xlight', 'light', 'dark', 'regular', 'prominent']}
101+
selectedIndex={this.state.vibrancyActiveSegment}
102+
onChange={(event) => {
103+
this._onVibrancyChange(event);
104+
}}
105+
onValueChange={(value) => {
106+
this._onVibrancyValueChange(value);
107+
}}
108+
tintColor="white"
109+
/>
110+
</VibrancyView>
111+
)
103112
}
104113
</View>
105114
);
106115
}
107116

108117
render() {
109118
return (
110-
<View
111-
style={styles.container}>
119+
<View style={styles.container}>
112120
<Image
113121
source={require('./bgimage.jpeg')}
114122
resizeMode="cover"
115-
style={styles.img}/>
123+
style={styles.img}
124+
/>
116125

117-
{ this.state.showBlurs ? this.renderBlurs() : null }
126+
{this.state.showBlurs ? this.renderBlurs() : null}
118127

119-
<View
120-
style={styles.blurToggle}>
128+
<View style={styles.blurToggle}>
121129
<Switch
122130
onValueChange={(value) => this.setState({showBlurs: value})}
123-
value={this.state.showBlurs} />
131+
value={this.state.showBlurs}
132+
/>
124133
</View>
125-
126134
</View>
127135
);
128136
}

example/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* @format
3-
*/
4-
51
import {AppRegistry} from 'react-native';
62
import App from './App';
73
import {name as appName} from './app.json';

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"lint": "eslint src index.js"
8+
"lint": "eslint src index.js example"
99
},
1010
"repository": {
1111
"type": "git",
@@ -42,8 +42,7 @@
4242
},
4343
"lint-staged": {
4444
"*.{js,json,css,md}": [
45-
"prettier --write",
46-
"git add"
45+
"prettier --write"
4746
]
4847
}
4948
}

src/BlurView.android.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'react';
1+
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {
44
View,
@@ -16,7 +16,7 @@ const OVERLAY_COLORS = {
1616

1717
class BlurView extends Component {
1818
componentDidMount() {
19-
DeviceEventEmitter.addListener('ReactNativeBlurError', message => {
19+
DeviceEventEmitter.addListener('ReactNativeBlurError', (message) => {
2020
throw new Error(`[ReactNativeBlur]: ${message}`);
2121
});
2222
}
@@ -33,12 +33,12 @@ class BlurView extends Component {
3333
}
3434

3535
blurRadius() {
36-
const { blurRadius, blurAmount } = this.props;
36+
const {blurRadius, blurAmount} = this.props;
3737

3838
if (blurRadius != null) {
3939
if (blurRadius > 25) {
4040
throw new Error(
41-
`[ReactNativeBlur]: blurRadius cannot be greater than 25! (was: ${blurRadius})`
41+
`[ReactNativeBlur]: blurRadius cannot be greater than 25! (was: ${blurRadius})`,
4242
);
4343
}
4444
return blurRadius;
@@ -55,32 +55,31 @@ class BlurView extends Component {
5555
}
5656

5757
downsampleFactor() {
58-
const { downsampleFactor, blurRadius } = this.props;
58+
const {downsampleFactor, blurRadius} = this.props;
5959
if (downsampleFactor != null) {
6060
return downsampleFactor;
6161
}
6262
return blurRadius;
6363
}
6464

6565
render() {
66-
const { style } = this.props;
66+
const {style} = this.props;
6767

6868
return (
6969
<NativeBlurView
7070
blurRadius={this.blurRadius()}
7171
downsampleFactor={this.downsampleFactor()}
7272
overlayColor={this.overlayColor()}
7373
pointerEvents="none"
74-
style={StyleSheet.compose(styles.transparent, style)}
75-
>
74+
style={StyleSheet.compose(styles.transparent, style)}>
7675
{this.props.children}
7776
</NativeBlurView>
7877
);
7978
}
8079
}
8180

8281
const styles = StyleSheet.create({
83-
transparent: { backgroundColor: 'transparent' },
82+
transparent: {backgroundColor: 'transparent'},
8483
});
8584

8685
BlurView.propTypes = {

src/BlurView.ios.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import React, { Component } from 'react';
1+
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
import {View, requireNativeComponent, ViewPropTypes, StyleSheet} from 'react-native';
3+
import {
4+
View,
5+
requireNativeComponent,
6+
ViewPropTypes,
7+
StyleSheet,
8+
} from 'react-native';
49

510
class BlurView extends Component {
6-
setNativeProps = nativeProps => {
11+
setNativeProps = (nativeProps) => {
712
if (this._root) {
813
this._root.setNativeProps(nativeProps);
914
}
@@ -12,7 +17,7 @@ class BlurView extends Component {
1217
render() {
1318
return (
1419
<NativeBlurView
15-
ref={e => (this._root = e)}
20+
ref={(e) => (this._root = e)}
1621
{...this.props}
1722
style={StyleSheet.compose(styles.transparent, this.props.style)}
1823
/>
@@ -21,7 +26,7 @@ class BlurView extends Component {
2126
}
2227

2328
const styles = StyleSheet.create({
24-
transparent: { backgroundColor: 'transparent' },
29+
transparent: {backgroundColor: 'transparent'},
2530
});
2631

2732
BlurView.propTypes = {

src/VibrancyView.ios.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { Component } from 'react';
1+
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {requireNativeComponent, StyleSheet} from 'react-native';
44

55
class VibrancyView extends Component {
6-
setNativeProps = nativeProps => {
6+
setNativeProps = (nativeProps) => {
77
if (this._root) {
88
this._root.setNativeProps(nativeProps);
99
}
@@ -20,7 +20,7 @@ class VibrancyView extends Component {
2020
}
2121

2222
const styles = StyleSheet.create({
23-
transparent: { backgroundColor: 'transparent' },
23+
transparent: {backgroundColor: 'transparent'},
2424
});
2525

2626
VibrancyView.propTypes = {

0 commit comments

Comments
 (0)