-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS textTransform style support #18387
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -860,6 +860,42 @@ exports.examples = [ | |
title: 'Text `alignItems: \'baseline\'` style', | ||
render: function() { | ||
return <TextBaseLineLayoutExample />; | ||
} | ||
}, | ||
{ | ||
title: 'Transform', | ||
render: function() { | ||
return ( | ||
<View> | ||
<Text style={{ textTransform: 'uppercase'}}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add a test with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
This text should be uppercased. | ||
</Text> | ||
<Text style={{ textTransform: 'lowercase'}}> | ||
This TEXT SHOULD be lowercased. | ||
</Text> | ||
<Text style={{ textTransform: 'capitalize'}}> | ||
This text should be CAPITALIZED. | ||
</Text> | ||
<Text style={{ textTransform: 'capitalize'}}> | ||
Mixed:{' '} | ||
<Text style={{ textTransform: 'uppercase'}}> | ||
uppercase{' '} | ||
</Text> | ||
<Text style={{ textTransform: 'lowercase'}}> | ||
LoWeRcAsE{' '} | ||
</Text> | ||
<Text style={{ textTransform: 'capitalize'}}> | ||
capitalize each word | ||
</Text> | ||
</Text> | ||
<Text>Should be "ABC": | ||
<Text style={{ textTransform: 'uppercase' }}>a<Text>b</Text>c</Text> | ||
</Text> | ||
<Text>Should be "AbC": | ||
<Text style={{ textTransform: 'uppercase' }}>a<Text style={{ textTransform: 'none' }}>b</Text>c</Text> | ||
</Text> | ||
</View> | ||
); | ||
}, | ||
}, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,6 +316,13 @@ + (NSLocale *)NSLocale:(id)json | |
@"underline line-through": @(RCTTextDecorationLineTypeUnderlineStrikethrough), | ||
}), RCTTextDecorationLineTypeNone, integerValue) | ||
|
||
RCT_ENUM_CONVERTER(RCTTextTransform, (@{ | ||
@"none": @(RCTTextTransformNone), | ||
@"capitalize": @(RCTTextTransformCapitalize), | ||
@"uppercase": @(RCTTextTransformUppercase), | ||
@"lowercase": @(RCTTextTransformLowercase), | ||
}), RCTTextTransformNone, integerValue) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value here should be @janicduplessis Right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm not how this works, does [RCTTextAttributes applyTextAttributes] only receives changed attributes (and some undefined value for the ones that did not change)? I think both options would work but I'm not sure if one makes more sense. Maybe check what we do for other enum text attributes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's easy to test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
RCT_ENUM_CONVERTER(NSWritingDirection, (@{ | ||
@"auto": @(NSWritingDirectionNatural), | ||
@"ltr": @(NSWritingDirectionLeftToRight), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
typedef NS_ENUM(NSInteger, RCTTextTransform) { | ||
RCTTextTransformUndefined = 0, | ||
RCTTextTransformNone, | ||
RCTTextTransformCapitalize, | ||
RCTTextTransformUppercase, | ||
RCTTextTransformLowercase, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is why we have to have
undefined
value!