Skip to content

Commit

Permalink
Fix inline styles warning in Libraries (#22161)
Browse files Browse the repository at this point in the history
Summary:
Fixes `react-native/no-inline-styles` eslint warnings in the `Libraries` module.
Pull Request resolved: #22161

Differential Revision: D12946899

Pulled By: TheSavior

fbshipit-source-id: c97ffa50dd90529dabf30a3d2cb09476acc568cb
  • Loading branch information
ignacioola authored and facebook-github-bot committed Nov 6, 2018
1 parent 69213ee commit 41eb2da
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 46 deletions.
25 changes: 17 additions & 8 deletions Libraries/Components/Touchable/Touchable.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Platform = require('Platform');
const Position = require('Position');
const React = require('React');
const ReactNative = require('ReactNative');
const StyleSheet = require('StyleSheet');
const TVEventHandler = require('TVEventHandler');
const TouchEventUtils = require('fbjs/lib/TouchEventUtils');
const UIManager = require('UIManager');
Expand Down Expand Up @@ -858,17 +859,25 @@ const Touchable = {
return (
<View
pointerEvents="none"
style={{
position: 'absolute',
borderColor: hexColor.slice(0, -2) + '55', // More opaque
borderWidth: 1,
borderStyle: 'dashed',
backgroundColor: hexColor.slice(0, -2) + '0F', // Less opaque
...debugHitSlopStyle,
}}
style={[
styles.debug,
{
borderColor: hexColor.slice(0, -2) + '55', // More opaque
backgroundColor: hexColor.slice(0, -2) + '0F', // Less opaque
...debugHitSlopStyle,
},
]}
/>
);
},
};

const styles = StyleSheet.create({
debug: {
position: 'absolute',
borderWidth: 1,
borderStyle: 'dashed',
},
});

module.exports = Touchable;
9 changes: 4 additions & 5 deletions Libraries/Experimental/WindowedListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,7 @@ class CellRenderer extends React.Component<CellProps> {
if (DEBUG) {
infoLog('render cell ' + this.props.rowIndex);
const Text = require('Text');
debug = (
<Text style={{backgroundColor: 'lightblue'}}>
Row: {this.props.rowIndex}
</Text>
);
debug = <Text style={styles.debug}>Row: {this.props.rowIndex}</Text>;
}
const style = this._includeInLayoutLatch ? styles.include : styles.remove;
return (
Expand Down Expand Up @@ -819,6 +815,9 @@ const styles = StyleSheet.create({
right: -removedXOffset,
opacity: DEBUG ? 0.1 : 0,
},
debug: {
backgroundColor: 'lightblue',
},
});

module.exports = WindowedListView;
88 changes: 55 additions & 33 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
);
if (this.props.debug) {
return (
<View style={{flex: 1}}>
<View style={styles.debug}>
{ret}
{this._renderDebugOverlay()}
</View>
Expand Down Expand Up @@ -1194,47 +1194,41 @@ class VirtualizedList extends React.PureComponent<Props, State> {
const windowLen = frameLast.offset + frameLast.length - windowTop;
const visTop = this._scrollMetrics.offset;
const visLen = this._scrollMetrics.visibleLength;
const baseStyle = {position: 'absolute', top: 0, right: 0};

return (
<View
style={{
...baseStyle,
bottom: 0,
width: 20,
borderColor: 'blue',
borderWidth: 1,
}}>
<View style={[styles.debugOverlayBase, styles.debugOverlay]}>
{framesInLayout.map((f, ii) => (
<View
key={'f' + ii}
style={{
...baseStyle,
left: 0,
top: f.offset * normalize,
height: f.length * normalize,
backgroundColor: 'orange',
}}
style={[
styles.debugOverlayBase,
styles.debugOverlayFrame,
{
top: f.offset * normalize,
height: f.length * normalize,
},
]}
/>
))}
<View
style={{
...baseStyle,
left: 0,
top: windowTop * normalize,
height: windowLen * normalize,
borderColor: 'green',
borderWidth: 2,
}}
style={[
styles.debugOverlayBase,
styles.debugOverlayFrameLast,
{
top: windowTop * normalize,
height: windowLen * normalize,
},
]}
/>
<View
style={{
...baseStyle,
left: 0,
top: visTop * normalize,
height: visLen * normalize,
borderColor: 'red',
borderWidth: 2,
}}
style={[
styles.debugOverlayBase,
styles.debugOverlayFrameVis,
{
top: visTop * normalize,
height: visLen * normalize,
},
]}
/>
</View>
);
Expand Down Expand Up @@ -1785,6 +1779,34 @@ const styles = StyleSheet.create({
horizontallyInverted: {
transform: [{scaleX: -1}],
},
debug: {
flex: 1,
},
debugOverlayBase: {
position: 'absolute',
top: 0,
right: 0,
},
debugOverlay: {
bottom: 0,
width: 20,
borderColor: 'blue',
borderWidth: 1,
},
debugOverlayFrame: {
left: 0,
backgroundColor: 'orange',
},
debugOverlayFrameLast: {
left: 0,
borderColor: 'green',
borderWidth: 2,
},
debugOverlayFrameVis: {
left: 0,
borderColor: 'red',
borderWidth: 2,
},
});

module.exports = VirtualizedList;

0 comments on commit 41eb2da

Please sign in to comment.