Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9179e76

Browse files
committed
Smart quote/dash configuration support in iOS
1 parent 7b0c11e commit 9179e76

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 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 = UITextSmartQuotesTypeDefault;
200+
_smartDashesType = UITextSmartDashesTypeDefault;
201+
}
196202
}
197203

198204
return self;
@@ -764,6 +770,16 @@ - (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* enableSmartDashes = configuration[@"enableSmartDashes"];
775+
_activeView.smartDashesType = enableSmartDashes && ![enableSmartDashes boolValue]
776+
? UITextSmartDashesTypeNo
777+
: UITextSmartDashesTypeDefault;
778+
NSString* enableSmartQuotes = configuration[@"enableSmartQuotes"];
779+
_activeView.smartQuotesType = enableSmartQuotes && ![enableSmartQuotes boolValue]
780+
? UITextSmartQuotesTypeNo
781+
: UITextSmartQuotesTypeDefault;
782+
}
767783
if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) {
768784
_activeView.keyboardAppearance = UIKeyboardAppearanceDark;
769785
} else if ([keyboardAppearance isEqualToString:@"Brightness.light"]) {

0 commit comments

Comments
 (0)