Skip to content

Commit a7b6ee5

Browse files
authored
Smart quote/dash configuration support in iOS (#13863)
Support for UITextSmartDashesType and UITextSmartQuotesType in iOS
1 parent 97634d2 commit a7b6ee5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ @interface FlutterTextInputView : UIView <UITextInput>
159159
@property(nonatomic) UIKeyboardType keyboardType;
160160
@property(nonatomic) UIReturnKeyType returnKeyType;
161161
@property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry;
162+
@property(nonatomic) UITextSmartQuotesType smartQuotesType API_AVAILABLE(ios(11.0));
163+
@property(nonatomic) UITextSmartDashesType smartDashesType API_AVAILABLE(ios(11.0));
162164

163165
@property(nonatomic, assign) id<FlutterTextInputDelegate> textInputDelegate;
164166

@@ -193,6 +195,10 @@ - (instancetype)init {
193195
_keyboardType = UIKeyboardTypeDefault;
194196
_returnKeyType = UIReturnKeyDone;
195197
_secureTextEntry = NO;
198+
if (@available(iOS 11.0, *)) {
199+
_smartQuotesType = UITextSmartQuotesTypeYes;
200+
_smartDashesType = UITextSmartDashesTypeYes;
201+
}
196202
}
197203

198204
return self;
@@ -764,6 +770,18 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur
764770
_activeView.keyboardType = ToUIKeyboardType(inputType);
765771
_activeView.returnKeyType = ToUIReturnKeyType(configuration[@"inputAction"]);
766772
_activeView.autocapitalizationType = ToUITextAutoCapitalizationType(configuration);
773+
if (@available(iOS 11.0, *)) {
774+
NSString* smartDashesType = configuration[@"smartDashesType"];
775+
// This index comes from the SmartDashesType enum in the framework.
776+
bool smartDashesIsDisabled = smartDashesType && [smartDashesType isEqualToString:@"0"];
777+
_activeView.smartDashesType =
778+
smartDashesIsDisabled ? UITextSmartDashesTypeNo : UITextSmartDashesTypeYes;
779+
NSString* smartQuotesType = configuration[@"smartQuotesType"];
780+
// This index comes from the SmartQuotesType enum in the framework.
781+
bool smartQuotesIsDisabled = smartQuotesType && [smartQuotesType isEqualToString:@"0"];
782+
_activeView.smartQuotesType =
783+
smartQuotesIsDisabled ? UITextSmartQuotesTypeNo : UITextSmartQuotesTypeYes;
784+
}
767785
if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) {
768786
_activeView.keyboardAppearance = UIKeyboardAppearanceDark;
769787
} else if ([keyboardAppearance isEqualToString:@"Brightness.light"]) {

0 commit comments

Comments
 (0)