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 1 commit
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
6 changes: 0 additions & 6 deletions ios/sdk/WeexSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,8 @@
B8394F3821468AF100CA1EFF /* render_action_trigger_vsync.h in Headers */ = {isa = PBXBuildFile; fileRef = B8394F3521468AF100CA1EFF /* render_action_trigger_vsync.h */; };
B8394F3921468AF100CA1EFF /* render_action_trigger_vsync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B8394F3621468AF100CA1EFF /* render_action_trigger_vsync.cpp */; };
B8394F3A21468AF100CA1EFF /* render_action_trigger_vsync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B8394F3621468AF100CA1EFF /* render_action_trigger_vsync.cpp */; };
B858E1272158BE0A00722366 /* render_document.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B858E1252158BE0900722366 /* render_document.cpp */; };
B858E1282158BE0A00722366 /* render_document.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B858E1252158BE0900722366 /* render_document.cpp */; };
B858E1292158BE0A00722366 /* render_document.h in Headers */ = {isa = PBXBuildFile; fileRef = B858E1262158BE0A00722366 /* render_document.h */; };
B858E12A2158BE0A00722366 /* render_document.h in Headers */ = {isa = PBXBuildFile; fileRef = B858E1262158BE0A00722366 /* render_document.h */; };
B858E12C2158BE1000722366 /* render_document_factory.h in Headers */ = {isa = PBXBuildFile; fileRef = B858E12B2158BE1000722366 /* render_document_factory.h */; };
B858E12D2158BE1000722366 /* render_document_factory.h in Headers */ = {isa = PBXBuildFile; fileRef = B858E12B2158BE1000722366 /* render_document_factory.h */; };
B85ED3032126715100EBEC11 /* WXRecyclerComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 745B2D601E5A8E1E0092D38A /* WXRecyclerComponent.h */; };
B863DF322107308000EA887D /* WXBridgeContext.m in Sources */ = {isa = PBXBuildFile; fileRef = B863DF312107307F00EA887D /* WXBridgeContext.m */; };
Expand Down Expand Up @@ -2756,7 +2753,6 @@
77D1614B1C02E3790010B15B /* WXConvert.h in Headers */,
1746EA7320E9D253007E55BD /* WXComponent_performance.h in Headers */,
59A596221CB6311F0012CD52 /* WXNavigatorModule.h in Headers */,
B858E12C2158BE1000722366 /* render_document_factory.h in Headers */,
B8F2C7082133A83C00635B37 /* rax_parser_context.h in Headers */,
33CE190E2153443000CF9670 /* WXJSFrameworkLoadDefaultImpl.h in Headers */,
C47B78CE1F2998EE001D3B0C /* WXExtendCallNativeManager.h in Headers */,
Expand Down Expand Up @@ -2818,7 +2814,6 @@
C4F0127D1E1502A6003378D0 /* WXWebSocketHandler.h in Headers */,
B8D66C9D21255730003960BD /* json11.hpp in Headers */,
DC03ADBA1D508719003F76E7 /* WXTextAreaComponent.h in Headers */,
B858E1292158BE0A00722366 /* render_document.h in Headers */,
B8D66C5721255730003960BD /* render_action_layout.h in Headers */,
2AC750241C7565690041D390 /* WXIndicatorComponent.h in Headers */,
B8F2C6E82133A83C00635B37 /* class_array.h in Headers */,
Expand Down Expand Up @@ -3546,7 +3541,6 @@
B8D66C4D21255730003960BD /* render_action_move_element.cpp in Sources */,
742AD7341DF98C45007DC46C /* WXResourceResponse.m in Sources */,
B87B9E7F21539B3300B6DC61 /* WXVersion.m in Sources */,
B858E1272158BE0A00722366 /* render_document.cpp in Sources */,
77E65A161C155EB5008B8775 /* WXTextComponent.mm in Sources */,
C4D872261E5DDF7500E39BC1 /* WXBoxShadow.m in Sources */,
B8D66BB32125572F003960BD /* parser.cc in Sources */,
Expand Down
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-28 12:00:22 UTC";
static const unsigned long WeexSDKBuildTimestamp = 1538136022;

NSString* GetWeexSDKVersion(void)
{
Expand Down