From fd0f58dcec066aa1603038f426eabbf175d368e5 Mon Sep 17 00:00:00 2001 From: Evsio0n <1344729087@qq.com> Date: Sat, 16 Nov 2019 03:40:44 +0800 Subject: [PATCH 1/3] Add Support for autofill with textContentType textContentType implentation need to bu updated in text_input.dart in Flutter SDK --- .../Source/FlutterTextInputPlugin.mm | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index ad39e710eeb50..b6cc11e7b54e3 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -45,6 +45,13 @@ static UITextAutocapitalizationType ToUITextAutoCapitalizationType(NSDictionary* return UITextAutocapitalizationTypeNone; } +@available iOS (10.0,*) +static UITextContentType ToUITextContentType(NSDictionary* type){ + NSString* contentType = type[@"textType"]; + if ([contentType isEqualToString:@"TextContent.username"]) + return UITextContentTypeUsername; +} + static UIReturnKeyType ToUIReturnKeyType(NSString* inputType) { // Where did the term "unspecified" come from? iOS has a "default" and Android // has "unspecified." These 2 terms seem to mean the same thing but we need @@ -149,6 +156,16 @@ @interface FlutterTextInputView : UIView @property(nonatomic, strong) UITextRange* markedTextRange; @property(nonatomic, copy) NSDictionary* markedTextStyle; @property(nonatomic, assign) id inputDelegate; +/** + This file is to make ios 10 or higher device using autofill + + Reference to github.com/flutter/flutter/issues/33040 + **/ +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 +@property(nonatomic) UITextContentType textContentType; +#else +#endif + // UITextInputTraits @property(nonatomic) UITextAutocapitalizationType autocapitalizationType; @@ -156,7 +173,7 @@ @interface FlutterTextInputView : UIView @property(nonatomic) UITextSpellCheckingType spellCheckingType; @property(nonatomic) BOOL enablesReturnKeyAutomatically; @property(nonatomic) UIKeyboardAppearance keyboardAppearance; -@property(nonatomic) UIKeyboardType keyboardType; +@property(nonatomic) UIKeyboardType keyboardType @property(nonatomic) UIReturnKeyType returnKeyType; @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; @@ -191,6 +208,7 @@ - (instancetype)init { _enablesReturnKeyAutomatically = NO; _keyboardAppearance = UIKeyboardAppearanceDefault; _keyboardType = UIKeyboardTypeDefault; + _keyboardContentType = UITextContentType; _returnKeyType = UIReturnKeyDone; _secureTextEntry = NO; } @@ -754,6 +772,7 @@ - (void)hideTextInput { - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configuration { NSDictionary* inputType = configuration[@"inputType"]; + NSDictionary* contentType = configuration[@"contentType"]; NSString* keyboardAppearance = configuration[@"keyboardAppearance"]; if ([configuration[@"obscureText"] boolValue]) { _activeView = _secureView; @@ -762,6 +781,7 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur } _activeView.keyboardType = ToUIKeyboardType(inputType); + _activeView.textContentType = ToUITextContentType(contentType); _activeView.returnKeyType = ToUIReturnKeyType(configuration[@"inputAction"]); _activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration); if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) { From 6077592c5bcd1071c87da5b4162092d3df2b8e59 Mon Sep 17 00:00:00 2001 From: Evsio0n <1344729087@qq.com> Date: Sat, 16 Nov 2019 03:45:04 +0800 Subject: [PATCH 2/3] Update FlutterTextInputPlugin.mm --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index b6cc11e7b54e3..65a3524147b43 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -173,7 +173,7 @@ @interface FlutterTextInputView : UIView @property(nonatomic) UITextSpellCheckingType spellCheckingType; @property(nonatomic) BOOL enablesReturnKeyAutomatically; @property(nonatomic) UIKeyboardAppearance keyboardAppearance; -@property(nonatomic) UIKeyboardType keyboardType +@property(nonatomic) UIKeyboardType keyboardType; @property(nonatomic) UIReturnKeyType returnKeyType; @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; From 928a0917d25d0f976802adced77adef75971230a Mon Sep 17 00:00:00 2001 From: Evsio0n <1344729087@qq.com> Date: Sat, 16 Nov 2019 04:48:43 +0800 Subject: [PATCH 3/3] Update FlutterTextInputPlugin.mm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update FlutterTextInputPlugin.mm flutter ci formatting fix syntax error Set limitation to iOS 11 due to UITextContentTypeUsername is Up at iOS 11 modified: shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm Set limitation to iOS 11 due to UITextContentTypeUsername is Up at iOS 11 修改: shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm --- .../Source/FlutterTextInputPlugin.mm | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 65a3524147b43..0f38f841cc1c4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -45,9 +45,9 @@ static UITextAutocapitalizationType ToUITextAutoCapitalizationType(NSDictionary* return UITextAutocapitalizationTypeNone; } -@available iOS (10.0,*) -static UITextContentType ToUITextContentType(NSDictionary* type){ - NSString* contentType = type[@"textType"]; +@available iOS (11.0,*) +static UITextContentType ToUITextContentType(NSDictionary* type) { + NSString* contentType = type[@"textType"]; if ([contentType isEqualToString:@"TextContent.username"]) return UITextContentTypeUsername; } @@ -157,14 +157,11 @@ @interface FlutterTextInputView : UIView @property(nonatomic, copy) NSDictionary* markedTextStyle; @property(nonatomic, assign) id inputDelegate; /** - This file is to make ios 10 or higher device using autofill + This file is to make ios 11 or higher device using autofill Reference to github.com/flutter/flutter/issues/33040 **/ -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 -@property(nonatomic) UITextContentType textContentType; -#else -#endif +@property(nonatomic) UITextContentType textContentType API_AVAILABLE(ios(11.0)); // UITextInputTraits @@ -208,7 +205,8 @@ - (instancetype)init { _enablesReturnKeyAutomatically = NO; _keyboardAppearance = UIKeyboardAppearanceDefault; _keyboardType = UIKeyboardTypeDefault; - _keyboardContentType = UITextContentType; + if(@available iOS (11.0,*)) + _keyboardContentType = UITextContentType; _returnKeyType = UIReturnKeyDone; _secureTextEntry = NO; } @@ -772,7 +770,8 @@ - (void)hideTextInput { - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configuration { NSDictionary* inputType = configuration[@"inputType"]; - NSDictionary* contentType = configuration[@"contentType"]; + if(@available iOS (11.0,*)) + NSDictionary* contentType = configuration[@"contentType"]; NSString* keyboardAppearance = configuration[@"keyboardAppearance"]; if ([configuration[@"obscureText"] boolValue]) { _activeView = _secureView; @@ -781,7 +780,8 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur } _activeView.keyboardType = ToUIKeyboardType(inputType); - _activeView.textContentType = ToUITextContentType(contentType); + if(@available iOS (11.0,*)) + _activeView.textContentType = ToUITextContentType(contentType); _activeView.returnKeyType = ToUIReturnKeyType(configuration[@"inputAction"]); _activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration); if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) {