Added explicit types for all view properties

This commit is contained in:
Nick Lockwood
2015-03-25 21:29:28 -07:00
parent 558b8c65e0
commit 19e328fb08
32 changed files with 436 additions and 533 deletions

View File

@@ -23,5 +23,7 @@
return [[RCTShadowRawText alloc] init];
}
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)
@end

View File

@@ -17,7 +17,6 @@ extern NSString *const RCTReactTagAttributeName;
@property (nonatomic, assign) NSWritingDirection writingDirection;
@property (nonatomic, strong) UIColor *textBackgroundColor;
@property (nonatomic, strong) UIColor *color;
@property (nonatomic, strong) UIFont *font;
@property (nonatomic, copy) NSString *fontFamily;
@property (nonatomic, assign) CGFloat fontSize;
@property (nonatomic, copy) NSString *fontWeight;
@@ -27,6 +26,9 @@ extern NSString *const RCTReactTagAttributeName;
@property (nonatomic, assign) NSInteger maxNumberOfLines;
@property (nonatomic, assign) CGSize shadowOffset;
@property (nonatomic, assign) NSTextAlignment textAlign;
// Not exposed to JS
@property (nonatomic, strong) UIFont *font;
@property (nonatomic, assign) NSLineBreakMode truncationMode;
- (NSAttributedString *)attributedString;

View File

@@ -11,7 +11,6 @@
#import "RCTConvert.h"
#import "RCTLog.h"
#import "RCTShadowRawText.h"
#import "RCTUtils.h"
@@ -154,7 +153,7 @@ static css_dim_t RCTMeasure(void *context, float width)
}
}];
// TODO: umm, these can'e be null, so we're mapping left to natural - is that right?
// TODO: umm, these can't be null, so we're mapping left to natural - is that right?
self.textAlign = _textAlign ?: NSTextAlignmentNatural;
self.writingDirection = _writingDirection ?: NSWritingDirectionNatural;

View File

@@ -32,8 +32,8 @@
#pragma mark - View properties
RCT_REMAP_VIEW_PROPERTY(containerBackgroundColor, backgroundColor)
RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, RCTText)
RCT_REMAP_VIEW_PROPERTY(containerBackgroundColor, backgroundColor, UIColor)
RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, NSInteger, RCTText)
{
NSLineBreakMode truncationMode = NSLineBreakByClipping;
view.numberOfLines = json ? [RCTConvert NSInteger:json] : defaultView.numberOfLines;
@@ -45,16 +45,24 @@ RCT_CUSTOM_VIEW_PROPERTY(numberOfLines, RCTText)
#pragma mark - Shadow properties
RCT_CUSTOM_SHADOW_PROPERTY(backgroundColor, RCTShadowText)
{
view.textBackgroundColor = json ? [RCTConvert UIColor:json] : defaultView.textBackgroundColor;
}
RCT_CUSTOM_SHADOW_PROPERTY(containerBackgroundColor, RCTShadowText)
RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection)
RCT_EXPORT_SHADOW_PROPERTY(color, UIColor)
RCT_EXPORT_SHADOW_PROPERTY(fontFamily, NSString)
RCT_EXPORT_SHADOW_PROPERTY(fontSize, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(fontWeight, NSString)
RCT_EXPORT_SHADOW_PROPERTY(fontStyle, NSString)
RCT_EXPORT_SHADOW_PROPERTY(isHighlighted, BOOL)
RCT_EXPORT_SHADOW_PROPERTY(lineHeight, CGFloat)
RCT_EXPORT_SHADOW_PROPERTY(maxNumberOfLines, NSInteger)
RCT_EXPORT_SHADOW_PROPERTY(shadowOffset, CGSize)
RCT_EXPORT_SHADOW_PROPERTY(textAlign, NSTextAlignment)
RCT_REMAP_SHADOW_PROPERTY(backgroundColor, textBackgroundColor, UIColor)
RCT_CUSTOM_SHADOW_PROPERTY(containerBackgroundColor, UIColor, RCTShadowText)
{
view.backgroundColor = json ? [RCTConvert UIColor:json] : defaultView.backgroundColor;
view.isBGColorExplicitlySet = json ? YES : defaultView.isBGColorExplicitlySet;
}
RCT_CUSTOM_SHADOW_PROPERTY(numberOfLines, RCTShadowText)
RCT_CUSTOM_SHADOW_PROPERTY(numberOfLines, NSInteger, RCTShadowText)
{
NSLineBreakMode truncationMode = NSLineBreakByClipping;
view.maxNumberOfLines = json ? [RCTConvert NSInteger:json] : defaultView.maxNumberOfLines;
@@ -63,10 +71,6 @@ RCT_CUSTOM_SHADOW_PROPERTY(numberOfLines, RCTShadowText)
}
view.truncationMode = truncationMode;
}
RCT_CUSTOM_SHADOW_PROPERTY(textAlign, RCTShadowText)
{
view.textAlign = json ? [RCTConvert NSTextAlignment:json] : defaultView.textAlign;
}
- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowText *)shadowView
{