From 9179e7641dff0f58487f362c52ad8e0a86b15f05 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Thu, 14 Nov 2019 09:12:05 -0800 Subject: [PATCH 1/7] Smart quote/dash configuration support in iOS --- .../framework/Source/FlutterTextInputPlugin.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index ad39e710eeb50..1a32bab612b79 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -159,6 +159,8 @@ @interface FlutterTextInputView : UIView @property(nonatomic) UIKeyboardType keyboardType; @property(nonatomic) UIReturnKeyType returnKeyType; @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; +@property(nonatomic) UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0)); +@property(nonatomic) UITextSmartDashesType smartDashesType API_AVAILABLE(ios(11.0)); @property(nonatomic, assign) id textInputDelegate; @@ -193,6 +195,10 @@ - (instancetype)init { _keyboardType = UIKeyboardTypeDefault; _returnKeyType = UIReturnKeyDone; _secureTextEntry = NO; + if (@available(iOS 11.0, *)) { + _smartQuotesType = UITextSmartQuotesTypeDefault; + _smartDashesType = UITextSmartDashesTypeDefault; + } } return self; @@ -764,6 +770,16 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur _activeView.keyboardType = ToUIKeyboardType(inputType); _activeView.returnKeyType = ToUIReturnKeyType(configuration[@"inputAction"]); _activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration); + if (@available(iOS 11.0, *)) { + NSString* enableSmartDashes = configuration[@"enableSmartDashes"]; + _activeView.smartDashesType = enableSmartDashes && ![enableSmartDashes boolValue] + ? UITextSmartDashesTypeNo + : UITextSmartDashesTypeDefault; + NSString* enableSmartQuotes = configuration[@"enableSmartQuotes"]; + _activeView.smartQuotesType = enableSmartQuotes && ![enableSmartQuotes boolValue] + ? UITextSmartQuotesTypeNo + : UITextSmartQuotesTypeDefault; + } if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) { _activeView.keyboardAppearance = UIKeyboardAppearanceDark; } else if ([keyboardAppearance isEqualToString:@"Brightness.light"]) { From 73608330396cbf96b3c9bd1738b68e50e6cf3e4f Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 15 Nov 2019 11:00:12 -0800 Subject: [PATCH 2/7] Formatting --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 1a32bab612b79..7de04a94820fb 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -773,12 +773,12 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur if (@available(iOS 11.0, *)) { NSString* enableSmartDashes = configuration[@"enableSmartDashes"]; _activeView.smartDashesType = enableSmartDashes && ![enableSmartDashes boolValue] - ? UITextSmartDashesTypeNo - : UITextSmartDashesTypeDefault; + ? UITextSmartDashesTypeNo + : UITextSmartDashesTypeDefault; NSString* enableSmartQuotes = configuration[@"enableSmartQuotes"]; _activeView.smartQuotesType = enableSmartQuotes && ![enableSmartQuotes boolValue] - ? UITextSmartQuotesTypeNo - : UITextSmartQuotesTypeDefault; + ? UITextSmartQuotesTypeNo + : UITextSmartQuotesTypeDefault; } if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) { _activeView.keyboardAppearance = UIKeyboardAppearanceDark; From e92ebe30c8ecde7512f8284805f1d6bb1e70ea80 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Wed, 4 Dec 2019 15:59:40 -0800 Subject: [PATCH 3/7] bool to enum --- .../ios/framework/Source/FlutterTextInputPlugin.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 7de04a94820fb..ad8f533cc68f0 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -771,12 +771,16 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur _activeView.returnKeyType = ToUIReturnKeyType(configuration[@"inputAction"]); _activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration); if (@available(iOS 11.0, *)) { - NSString* enableSmartDashes = configuration[@"enableSmartDashes"]; - _activeView.smartDashesType = enableSmartDashes && ![enableSmartDashes boolValue] + NSString* smartDashesType = configuration[@"smartDashesType"]; + // This string comes from the SmartDashesType enum in the framework. + bool smartDashesIsDisabled = smartDashesType && [smartDashesType isEqualToString:@"SmartDashesType.disabled"]; + _activeView.smartDashesType = smartDashesIsDisabled ? UITextSmartDashesTypeNo : UITextSmartDashesTypeDefault; - NSString* enableSmartQuotes = configuration[@"enableSmartQuotes"]; - _activeView.smartQuotesType = enableSmartQuotes && ![enableSmartQuotes boolValue] + NSString* smartQuotesType = configuration[@"smartQuotesType"]; + // This string comes from the SmartQuotesType enum in the framework. + bool smartQuotesIsDisabled = smartQuotesType && [smartQuotesType isEqualToString:@"SmartQuotesType.disabled"]; + _activeView.smartQuotesType = smartQuotesIsDisabled ? UITextSmartQuotesTypeNo : UITextSmartQuotesTypeDefault; } From 133bf65e250a82e3ed43fb9a40bc8894b2e0d65e Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Wed, 4 Dec 2019 16:15:12 -0800 Subject: [PATCH 4/7] Default to 'Yes' instead of 'Default' --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index ad8f533cc68f0..5e54e29c83647 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -196,8 +196,8 @@ - (instancetype)init { _returnKeyType = UIReturnKeyDone; _secureTextEntry = NO; if (@available(iOS 11.0, *)) { - _smartQuotesType = UITextSmartQuotesTypeDefault; - _smartDashesType = UITextSmartDashesTypeDefault; + _smartQuotesType = UITextSmartQuotesTypeYes; + _smartDashesType = UITextSmartDashesTypeYes; } } @@ -776,13 +776,13 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur bool smartDashesIsDisabled = smartDashesType && [smartDashesType isEqualToString:@"SmartDashesType.disabled"]; _activeView.smartDashesType = smartDashesIsDisabled ? UITextSmartDashesTypeNo - : UITextSmartDashesTypeDefault; + : UITextSmartDashesTypeYes; NSString* smartQuotesType = configuration[@"smartQuotesType"]; // This string comes from the SmartQuotesType enum in the framework. bool smartQuotesIsDisabled = smartQuotesType && [smartQuotesType isEqualToString:@"SmartQuotesType.disabled"]; _activeView.smartQuotesType = smartQuotesIsDisabled ? UITextSmartQuotesTypeNo - : UITextSmartQuotesTypeDefault; + : UITextSmartQuotesTypeYes; } if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) { _activeView.keyboardAppearance = UIKeyboardAppearanceDark; From 0af712f3e6b984ded6982607a68e28f9509f112e Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Wed, 4 Dec 2019 16:25:45 -0800 Subject: [PATCH 5/7] Formatting --- .../framework/Source/FlutterTextInputPlugin.mm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 5e54e29c83647..a94eee7bff533 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -773,16 +773,16 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur if (@available(iOS 11.0, *)) { NSString* smartDashesType = configuration[@"smartDashesType"]; // This string comes from the SmartDashesType enum in the framework. - bool smartDashesIsDisabled = smartDashesType && [smartDashesType isEqualToString:@"SmartDashesType.disabled"]; - _activeView.smartDashesType = smartDashesIsDisabled - ? UITextSmartDashesTypeNo - : UITextSmartDashesTypeYes; + bool smartDashesIsDisabled = + smartDashesType && [smartDashesType isEqualToString:@"SmartDashesType.disabled"]; + _activeView.smartDashesType = + smartDashesIsDisabled ? UITextSmartDashesTypeNo : UITextSmartDashesTypeYes; NSString* smartQuotesType = configuration[@"smartQuotesType"]; // This string comes from the SmartQuotesType enum in the framework. - bool smartQuotesIsDisabled = smartQuotesType && [smartQuotesType isEqualToString:@"SmartQuotesType.disabled"]; - _activeView.smartQuotesType = smartQuotesIsDisabled - ? UITextSmartQuotesTypeNo - : UITextSmartQuotesTypeYes; + bool smartQuotesIsDisabled = + smartQuotesType && [smartQuotesType isEqualToString:@"SmartQuotesType.disabled"]; + _activeView.smartQuotesType = + smartQuotesIsDisabled ? UITextSmartQuotesTypeNo : UITextSmartQuotesTypeYes; } if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) { _activeView.keyboardAppearance = UIKeyboardAppearanceDark; From d948698dfa3c71130cd79d909203e419b551c3d0 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 6 Dec 2019 09:43:15 -0800 Subject: [PATCH 6/7] Use an index instead of a string for the enum value --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index a94eee7bff533..4d58528a3a90a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -772,15 +772,15 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur _activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration); if (@available(iOS 11.0, *)) { NSString* smartDashesType = configuration[@"smartDashesType"]; - // This string comes from the SmartDashesType enum in the framework. + // This index comes from the SmartDashesType enum in the framework. bool smartDashesIsDisabled = - smartDashesType && [smartDashesType isEqualToString:@"SmartDashesType.disabled"]; + smartDashesType && [smartDashesType isEqualToString:@"0"]; _activeView.smartDashesType = smartDashesIsDisabled ? UITextSmartDashesTypeNo : UITextSmartDashesTypeYes; NSString* smartQuotesType = configuration[@"smartQuotesType"]; - // This string comes from the SmartQuotesType enum in the framework. + // This index comes from the SmartQuotesType enum in the framework. bool smartQuotesIsDisabled = - smartQuotesType && [smartQuotesType isEqualToString:@"SmartQuotesType.disabled"]; + smartQuotesType && [smartQuotesType isEqualToString:@"0"]; _activeView.smartQuotesType = smartQuotesIsDisabled ? UITextSmartQuotesTypeNo : UITextSmartQuotesTypeYes; } From 4d73a5762006329c27706a88890e5164d1671afb Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 6 Dec 2019 14:49:40 -0800 Subject: [PATCH 7/7] Formatting --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 4d58528a3a90a..76d9a8106b5cb 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -773,14 +773,12 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur if (@available(iOS 11.0, *)) { NSString* smartDashesType = configuration[@"smartDashesType"]; // This index comes from the SmartDashesType enum in the framework. - bool smartDashesIsDisabled = - smartDashesType && [smartDashesType isEqualToString:@"0"]; + bool smartDashesIsDisabled = smartDashesType && [smartDashesType isEqualToString:@"0"]; _activeView.smartDashesType = smartDashesIsDisabled ? UITextSmartDashesTypeNo : UITextSmartDashesTypeYes; NSString* smartQuotesType = configuration[@"smartQuotesType"]; // This index comes from the SmartQuotesType enum in the framework. - bool smartQuotesIsDisabled = - smartQuotesType && [smartQuotesType isEqualToString:@"0"]; + bool smartQuotesIsDisabled = smartQuotesType && [smartQuotesType isEqualToString:@"0"]; _activeView.smartQuotesType = smartQuotesIsDisabled ? UITextSmartQuotesTypeNo : UITextSmartQuotesTypeYes; }