Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Add support auto-capitalization-type for WXEditComponent #1597

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXEditComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ @interface WXEditComponent()
@property (nonatomic, copy) NSString *inputType;
@property (nonatomic) NSUInteger rows;
@property (nonatomic) BOOL hideDoneButton;
@property (nonatomic) UITextAutocapitalizationType autocapitalizationType;

//style
@property (nonatomic) WXPixelType fontSize;
Expand Down Expand Up @@ -154,6 +155,10 @@ - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDict
}else {
_placeholderColor = [UIColor colorWithRed:0x99/255.0 green:0x99/255.0 blue:0x99/255.0 alpha:1.0];
}

if (attributes[@"autoCapitalizationType"]) {
_autocapitalizationType = [WXConvert UITextAutocapitalizationType:attributes[@"autoCapitalizationType"]];
}
}

return self;
Expand Down Expand Up @@ -182,6 +187,7 @@ - (void)viewDidLoad
[self setEnabled:!_disabled];
[self setRows:_rows];
[self setReturnKeyType:_returnKeyType];
[self setAutocapitalizationType:_autocapitalizationType];
[self updatePattern];

if (!self.hideDoneButton) {
Expand Down Expand Up @@ -305,6 +311,10 @@ -(void)setReturnKeyType:(UIReturnKeyType)returnKeyType
{
}

- (void)setAutocapitalizationType:(UITextAutocapitalizationType)autocapitalizationType {

}

-(void)setInputAccessoryView:(UIView *)inputAccessoryView
{
}
Expand Down Expand Up @@ -447,6 +457,11 @@ - (void)updateAttributes:(NSDictionary *)attributes
_rows = 2;
[self setRows:_rows];
}

if (attributes[@"autoCapitalizationType"]) {
_autocapitalizationType = [WXConvert UITextAutocapitalizationType:attributes[@"autoCapitalizationType"]];
[self setAutocapitalizationType:_autocapitalizationType];
}
}

#pragma mark - upate styles
Expand Down
4 changes: 4 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXTextAreaComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ -(void)setRows:(NSUInteger)rows
[self setNeedsLayout];
}

- (void)setAutocapitalizationType:(UITextAutocapitalizationType)type {
_textView.autocapitalizationType = type;
}

#pragma mark -Private Method
- (void)_updateTextContentInset
{
Expand Down
5 changes: 5 additions & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXTextInputComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ -(void)setReturnKeyType:(UIReturnKeyType)returnKeyType
{
_inputView.returnKeyType = returnKeyType;
}

- (void)setAutocapitalizationType:(UITextAutocapitalizationType)type {
_inputView.autocapitalizationType = type;
}

-(void)setInputAccessoryView:(UIView *)inputAccessoryView
{
_inputView.inputAccessoryView = inputAccessoryView;
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Utility/WXConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef BOOL WXClipType;
+ (WXTextDecoration)WXTextDecoration:(id)value;
+ (NSTextAlignment)NSTextAlignment:(id)value;
+ (UIReturnKeyType)UIReturnKeyType:(id)value;
+ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)value;

+ (WXScrollDirection)WXScrollDirection:(id)value;
+ (UITableViewRowAnimation)UITableViewRowAnimation:(id)value;
Expand Down
16 changes: 16 additions & 0 deletions ios/sdk/WeexSDK/Sources/Utility/WXConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,22 @@ + (UIReturnKeyType)UIReturnKeyType:(id)value
return UIReturnKeyDefault;
}

+ (UITextAutocapitalizationType)UITextAutocapitalizationType:(id)value
{
if([value isKindOfClass:[NSString class]]){
NSString *string = (NSString *)value;
if ([string isEqualToString:@"none"])
return UITextAutocapitalizationTypeNone;
else if ([string isEqualToString:@"words"])
return UITextAutocapitalizationTypeWords;
else if ([string isEqualToString:@"sentences"])
return UITextAutocapitalizationTypeSentences;
else if ([string isEqualToString:@"allcharacters"])
return UITextAutocapitalizationTypeAllCharacters;
}
return UITextAutocapitalizationTypeSentences;
}

+ (WXTextStyle)WXTextStyle:(id)value
{
if([value isKindOfClass:[NSString class]]){
Expand Down
4 changes: 2 additions & 2 deletions ios/sdk/WeexSDK/Sources/Utility/WXVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#import "WXVersion.h"
#import "WXDefine.h"

static const char* WeexSDKBuildTime = "2018-09-20 09:52:40 UTC";
static const unsigned long WeexSDKBuildTimestamp = 1537437160;
static const char* WeexSDKBuildTime = "2018-09-30 09:57:57 UTC";
static const unsigned long WeexSDKBuildTimestamp = 1538301477;

NSString* GetWeexSDKVersion(void)
{
Expand Down