Skip to content

Commit

Permalink
chore: apply review
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Oct 8, 2022
1 parent 88cb06f commit 5a1939b
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -377,34 +377,21 @@ + (NSLocale *)NSLocale:(id)json

+ (NSLineBreakStrategy)NSLineBreakStrategy:(id)json RCT_DYNAMIC
{
static NSDictionary *mapping;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (@available(iOS 14.0, *)) {
mapping = @{
@"none" : @(NSLineBreakStrategyNone),
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000
@"standard" : @(NSLineBreakStrategyStandard),
@"hangul-word" : @(NSLineBreakStrategyHangulWordPriority),
@"push-out": @(NSLineBreakStrategyPushOut)
#else
@"standard" : @(NSLineBreakStrategyNone),
@"hangul-word" : @(NSLineBreakStrategyNone),
@"push-out": @(NSLineBreakStrategyNone)
#endif
};
static NSDictionary *mapping;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
mapping = @{
@"none" : @(NSLineBreakStrategyNone),
@"standard" : @(NSLineBreakStrategyStandard),
@"hangul-word" : @(NSLineBreakStrategyHangulWordPriority),
@"push-out": @(NSLineBreakStrategyPushOut)
};
});
return RCTConvertEnumValue("NSLineBreakStrategy", mapping, @(NSLineBreakStrategyNone), json).integerValue;
} else {
mapping = @{
@"none" : @(NSLineBreakStrategyNone),
@"standard" : @(NSLineBreakStrategyNone),
@"hangul-word" : @(NSLineBreakStrategyNone),
@"push-out": @(NSLineBreakStrategyNone)
};
return NSLineBreakStrategyNone;
}
});

NSLineBreakStrategy type = RCTConvertEnumValue("NSLineBreakStrategy", mapping, @(NSLineBreakStrategyNone), json).integerValue;
return type;
}

RCT_ENUM_CONVERTER(
Expand Down

0 comments on commit 5a1939b

Please sign in to comment.