Skip to content

Commit

Permalink
Passing in values from js-land to objc-world.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tj committed Aug 13, 2015
1 parent 64664d5 commit db01c70
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Libraries/Text/RCTShadowText.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extern NSString *const RCTReactTagAttributeName;
@property (nonatomic, assign) RCTTextDecorationLineType textDecorationLine;
@property (nonatomic, assign) CGFloat fontSizeMultiplier;
@property (nonatomic, assign) BOOL allowFontScaling;
@property (nonatomic, assign) BOOL adjustsFontSizeToFit;
@property (nonatomic, assign) CGFloat minimumFontScale;

- (void)recomputeText;

Expand Down
10 changes: 7 additions & 3 deletions Libraries/Text/RCTShadowText.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ - (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks
NSTextStorage *textStorage = [self buildTextStorageForWidth:self.frame.size.width];
[applierBlocks addObject:^(RCTSparseArray *viewRegistry) {
RCTText *view = viewRegistry[self.reactTag];
view.adjustsFontSizeToFit = self.adjustsFontSizeToFit;
view.minimumFontScale = self.minimumFontScale;
view.textStorage = textStorage;
}];

Expand Down Expand Up @@ -327,6 +329,7 @@ - (void)set##setProp:(type)value; \
[self dirtyText]; \
}

RCT_TEXT_PROPERTY(AdjustsFontSizeToFit, _adjustsFontSizeToFit, BOOL)
RCT_TEXT_PROPERTY(Color, _color, UIColor *)
RCT_TEXT_PROPERTY(FontFamily, _fontFamily, NSString *)
RCT_TEXT_PROPERTY(FontSize, _fontSize, CGFloat)
Expand All @@ -335,12 +338,13 @@ - (void)set##setProp:(type)value; \
RCT_TEXT_PROPERTY(IsHighlighted, _isHighlighted, BOOL)
RCT_TEXT_PROPERTY(LetterSpacing, _letterSpacing, CGFloat)
RCT_TEXT_PROPERTY(LineHeight, _lineHeight, CGFloat)
RCT_TEXT_PROPERTY(MinimumFontScale, _minimumFontScale, CGFloat)
RCT_TEXT_PROPERTY(NumberOfLines, _numberOfLines, NSUInteger)
RCT_TEXT_PROPERTY(ShadowOffset, _shadowOffset, CGSize)
RCT_TEXT_PROPERTY(TextAlign, _textAlign, NSTextAlignment)
RCT_TEXT_PROPERTY(TextDecorationColor, _textDecorationColor, UIColor *);
RCT_TEXT_PROPERTY(TextDecorationLine, _textDecorationLine, RCTTextDecorationLineType);
RCT_TEXT_PROPERTY(TextDecorationStyle, _textDecorationStyle, NSUnderlineStyle);
RCT_TEXT_PROPERTY(TextDecorationColor, _textDecorationColor, UIColor *)
RCT_TEXT_PROPERTY(TextDecorationLine, _textDecorationLine, RCTTextDecorationLineType)
RCT_TEXT_PROPERTY(TextDecorationStyle, _textDecorationStyle, NSUnderlineStyle)
RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection)

- (void)setAllowFontScaling:(BOOL)allowFontScaling
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Text/RCTTextManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ - (RCTShadowView *)shadowView
RCT_EXPORT_SHADOW_PROPERTY(textDecorationLine, RCTTextDecorationLineType)
RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection)
RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL)
RCT_EXPORT_SHADOW_PROPERTY(adjustsFontSizeToFit, BOOL)
RCT_EXPORT_SHADOW_PROPERTY(minimumFontScale, CGFloat)

- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(RCTSparseArray *)shadowViewRegistry
{
Expand Down
13 changes: 12 additions & 1 deletion Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var viewConfig = {
isHighlighted: true,
numberOfLines: true,
allowFontScaling: true,
adjustsFontSizeToFit: true,
minimumFontScale: true,
}),
uiViewClassName: 'RCTText',
};
Expand Down Expand Up @@ -104,6 +106,15 @@ var Text = React.createClass({
* Specifies should fonts scale to respect Text Size accessibility setting on iOS.
*/
allowFontScaling: React.PropTypes.bool,
/**
* Specifies that font should shrink to fit container size.
*/
adjustsFontSizeToFit: React.PropTypes.bool,
/**
* Minimum amount that a font should scale down to fit container.
* Used in conjuction with adjustsFontSizeToFit
*/
minimumFontScale: React.PropTypes.number,
},

viewConfig: viewConfig,
Expand All @@ -113,7 +124,7 @@ var Text = React.createClass({
isHighlighted: false,
});
},

getDefaultProps: function(): Object {
return {
allowFontScaling: true,
Expand Down

0 comments on commit db01c70

Please sign in to comment.