Improve types in RCTFont API
Reviewed By: majak Differential Revision: D3662880 fbshipit-source-id: f54e1ac164373337460047eb3708a588f578b5fc
This commit is contained in:
parent
3d6240f9a6
commit
f571f016d9
|
@ -96,7 +96,7 @@ RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)
|
||||||
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType)
|
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType)
|
||||||
RCT_REMAP_VIEW_PROPERTY(textAlign, textAlignment, NSTextAlignment)
|
RCT_REMAP_VIEW_PROPERTY(textAlign, textAlignment, NSTextAlignment)
|
||||||
RCT_REMAP_VIEW_PROPERTY(selectionColor, tintColor, UIColor)
|
RCT_REMAP_VIEW_PROPERTY(selectionColor, tintColor, UIColor)
|
||||||
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextField)
|
RCT_CUSTOM_VIEW_PROPERTY(fontSize, NSNumber, RCTTextField)
|
||||||
{
|
{
|
||||||
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ RCT_REMAP_VIEW_PROPERTY(secureTextEntry, textView.secureTextEntry, BOOL)
|
||||||
RCT_REMAP_VIEW_PROPERTY(selectionColor, tintColor, UIColor)
|
RCT_REMAP_VIEW_PROPERTY(selectionColor, tintColor, UIColor)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
|
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
|
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
|
||||||
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextView)
|
RCT_CUSTOM_VIEW_PROPERTY(fontSize, NSNumber, RCTTextView)
|
||||||
{
|
{
|
||||||
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,16 @@
|
||||||
* If font is nil, the default system font of size 14 will be used.
|
* If font is nil, the default system font of size 14 will be used.
|
||||||
*/
|
*/
|
||||||
+ (UIFont *)updateFont:(UIFont *)font
|
+ (UIFont *)updateFont:(UIFont *)font
|
||||||
withFamily:(id)family
|
withFamily:(NSString *)family
|
||||||
size:(id)size
|
size:(NSNumber *)size
|
||||||
weight:(id)weight
|
weight:(NSString *)weight
|
||||||
style:(id)style
|
style:(NSString *)style
|
||||||
scaleMultiplier:(CGFloat)scaleMultiplier;
|
scaleMultiplier:(CGFloat)scaleMultiplier;
|
||||||
|
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withFamily:(id)json;
|
+ (UIFont *)updateFont:(UIFont *)font withFamily:(NSString *)family;
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withSize:(id)json;
|
+ (UIFont *)updateFont:(UIFont *)font withSize:(NSNumber *)size;
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withWeight:(id)json;
|
+ (UIFont *)updateFont:(UIFont *)font withWeight:(NSString *)weight;
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withStyle:(id)json;
|
+ (UIFont *)updateFont:(UIFont *)font withStyle:(NSString *)style;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -104,10 +104,10 @@ static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
|
||||||
{
|
{
|
||||||
json = [self NSDictionary:json];
|
json = [self NSDictionary:json];
|
||||||
return [RCTFont updateFont:nil
|
return [RCTFont updateFont:nil
|
||||||
withFamily:json[@"fontFamily"]
|
withFamily:[RCTConvert NSString:json[@"fontFamily"]]
|
||||||
size:json[@"fontSize"]
|
size:[RCTConvert NSNumber:json[@"fontSize"]]
|
||||||
weight:json[@"fontWeight"]
|
weight:[RCTConvert NSString:json[@"fontWeight"]]
|
||||||
style:json[@"fontStyle"]
|
style:[RCTConvert NSString:json[@"fontStyle"]]
|
||||||
scaleMultiplier:1];
|
scaleMultiplier:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,10 +137,10 @@ RCT_ENUM_CONVERTER(RCTFontStyle, (@{
|
||||||
@implementation RCTFont
|
@implementation RCTFont
|
||||||
|
|
||||||
+ (UIFont *)updateFont:(UIFont *)font
|
+ (UIFont *)updateFont:(UIFont *)font
|
||||||
withFamily:(id)family
|
withFamily:(NSString *)family
|
||||||
size:(id)size
|
size:(NSNumber *)size
|
||||||
weight:(id)weight
|
weight:(NSString *)weight
|
||||||
style:(id)style
|
style:(NSString *)style
|
||||||
scaleMultiplier:(CGFloat)scaleMultiplier
|
scaleMultiplier:(CGFloat)scaleMultiplier
|
||||||
{
|
{
|
||||||
// Defaults
|
// Defaults
|
||||||
|
@ -239,24 +239,24 @@ RCT_ENUM_CONVERTER(RCTFontStyle, (@{
|
||||||
return bestMatch;
|
return bestMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withFamily:(id)json
|
+ (UIFont *)updateFont:(UIFont *)font withFamily:(NSString *)family
|
||||||
{
|
{
|
||||||
return [self updateFont:font withFamily:json size:nil weight:nil style:nil scaleMultiplier:1];
|
return [self updateFont:font withFamily:family size:nil weight:nil style:nil scaleMultiplier:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withSize:(id)json
|
+ (UIFont *)updateFont:(UIFont *)font withSize:(NSNumber *)size
|
||||||
{
|
{
|
||||||
return [self updateFont:font withFamily:nil size:json weight:nil style:nil scaleMultiplier:1];
|
return [self updateFont:font withFamily:nil size:size weight:nil style:nil scaleMultiplier:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withWeight:(id)json
|
+ (UIFont *)updateFont:(UIFont *)font withWeight:(NSString *)weight
|
||||||
{
|
{
|
||||||
return [self updateFont:font withFamily:nil size:nil weight:json style:nil scaleMultiplier:1];
|
return [self updateFont:font withFamily:nil size:nil weight:weight style:nil scaleMultiplier:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (UIFont *)updateFont:(UIFont *)font withStyle:(id)json
|
+ (UIFont *)updateFont:(UIFont *)font withStyle:(NSString *)style
|
||||||
{
|
{
|
||||||
return [self updateFont:font withFamily:nil size:nil weight:nil style:json scaleMultiplier:1];
|
return [self updateFont:font withFamily:nil size:nil weight:nil style:style scaleMultiplier:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -27,7 +27,7 @@ RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(color, UIColor)
|
RCT_EXPORT_VIEW_PROPERTY(color, UIColor)
|
||||||
RCT_EXPORT_VIEW_PROPERTY(textAlign, NSTextAlignment)
|
RCT_EXPORT_VIEW_PROPERTY(textAlign, NSTextAlignment)
|
||||||
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTPicker)
|
RCT_CUSTOM_VIEW_PROPERTY(fontSize, NSNumber, RCTPicker)
|
||||||
{
|
{
|
||||||
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
view.font = [RCTFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue