added small UI indicator for fabric-based surfaces

Summary: To make debugging/testing easier, optionally display fabric label on the top-right of the surface if it's rendered on fabric mode.

Reviewed By: mdvacca

Differential Revision: D9206473

fbshipit-source-id: ef6f0396ff749f2a0415688b1cf4fe1a4b83124d
This commit is contained in:
Kevin Gozali 2018-08-07 21:20:58 -07:00 committed by Facebook Github Bot
parent c298e0ae06
commit 235d9017cf
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
'use strict';
const React = require('React');
const StyleSheet = require('StyleSheet');
const Text = require('Text');
const View = require('View');
function ReactFabricIndicator(): React.Node {
return (
<View style={styles.container}>
<Text style={styles.text}>FABRIC</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'rgba(0,0,0, 0.25)',
position: 'absolute',
top: 0,
right: 0,
padding: 2,
},
text: {
fontSize: 6,
color: '#ffffff',
},
});
module.exports = ReactFabricIndicator;

View File

@ -12,6 +12,7 @@
const AppContainer = require('AppContainer');
const React = require('React');
const ReactFabricIndicator = require('ReactFabricIndicator');
const invariant = require('fbjs/lib/invariant');
@ -24,12 +25,16 @@ function renderApplication<Props: Object>(
rootTag: any,
WrapperComponent?: ?React.ComponentType<*>,
fabric?: boolean,
showFabricIndicator?: boolean,
) {
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
let renderable = (
<AppContainer rootTag={rootTag} WrapperComponent={WrapperComponent}>
<RootComponent {...initialProps} rootTag={rootTag} />
{fabric === true && showFabricIndicator === true ? (
<ReactFabricIndicator />
) : null}
</AppContainer>
);