Skip to content

Commit

Permalink
Slight modernizing of Text.js to make it compatible with coming changes
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D6688488

fbshipit-source-id: da020b3510ac7163f63cb5cebc27ec4306b1136c
  • Loading branch information
shergin authored and facebook-github-bot committed Jan 15, 2018
1 parent 5dbb3c5 commit 9532062
Showing 1 changed file with 7 additions and 35 deletions.
42 changes: 7 additions & 35 deletions Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,20 @@
const ColorPropType = require('ColorPropType');
const EdgeInsetsPropType = require('EdgeInsetsPropType');
const NativeMethodsMixin = require('NativeMethodsMixin');
const Platform = require('Platform');
const React = require('React');
const PropTypes = require('prop-types');
const ReactNativeViewAttributes = require('ReactNativeViewAttributes');
const StyleSheetPropType = require('StyleSheetPropType');
const TextStylePropTypes = require('TextStylePropTypes');
const Touchable = require('Touchable');
const UIManager = require('UIManager');

const createReactClass = require('create-react-class');
const createReactNativeComponentClass = require('createReactNativeComponentClass');
const requireNativeComponent = require('requireNativeComponent');
const mergeFast = require('mergeFast');
const processColor = require('processColor');

const stylePropType = StyleSheetPropType(TextStylePropTypes);

const viewConfig = {
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
numberOfLines: true,
ellipsizeMode: true,
allowFontScaling: true,
disabled: true,
selectable: true,
selectionColor: true,
adjustsFontSizeToFit: true,
minimumFontScale: true,
textBreakStrategy: true,
}),
uiViewClassName: 'RCTText',
};

/**
* A React component for displaying text.
*
Expand Down Expand Up @@ -418,7 +401,6 @@ const Text = createReactClass({
});
},
mixins: [NativeMethodsMixin],
viewConfig: viewConfig,
getChildContext(): Object {
return {isInAParentText: true};
},
Expand Down Expand Up @@ -568,21 +550,11 @@ type RectOffset = {
bottom: number,
};

var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};

var RCTText = createReactNativeComponentClass(
viewConfig.uiViewClassName,
() => viewConfig,
);
var RCTVirtualText = RCTText;
const PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};

if (Platform.OS === 'android') {
RCTVirtualText = createReactNativeComponentClass('RCTVirtualText', () => ({
validAttributes: mergeFast(ReactNativeViewAttributes.UIView, {
isHighlighted: true,
}),
uiViewClassName: 'RCTVirtualText',
}));
}
const RCTText = requireNativeComponent('RCTText');
const RCTVirtualText = UIManager.RCTVirtualText
? requireNativeComponent('RCTVirtualText')
: RCTText;

module.exports = Text;

0 comments on commit 9532062

Please sign in to comment.