mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Added explicit types for all view properties
This commit is contained in:
@@ -23,5 +23,7 @@
|
||||
return [[RCTShadowRawText alloc] init];
|
||||
}
|
||||
|
||||
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user