Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inline styles warning in Libraries #22161

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;