Skip to content

Commit

Permalink
Smart quote/dash configuration support in iOS (flutter#13863)
Browse files Browse the repository at this point in the history
Support for UITextSmartDashesType and UITextSmartQuotesType in iOS
  • Loading branch information
justinmc committed Dec 12, 2019
1 parent 97634d2 commit a7b6ee5
Showing 1 changed file with 18 additions and 0 deletions.
Expand Up @@ -159,6 +159,8 @@ @interface FlutterTextInputView : UIView <UITextInput>
@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<FlutterTextInputDelegate> textInputDelegate;

Expand Down Expand Up @@ -193,6 +195,10 @@ - (instancetype)init {
_keyboardType = UIKeyboardTypeDefault;
_returnKeyType = UIReturnKeyDone;
_secureTextEntry = NO;
if (@available(iOS 11.0, *)) {
_smartQuotesType = UITextSmartQuotesTypeYes;
_smartDashesType = UITextSmartDashesTypeYes;
}
}

return self;
Expand Down Expand Up @@ -764,6 +770,18 @@ - (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* smartDashesType = configuration[@"smartDashesType"];
// This index comes from the SmartDashesType enum in the framework.
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"];
_activeView.smartQuotesType =
smartQuotesIsDisabled ? UITextSmartQuotesTypeNo : UITextSmartQuotesTypeYes;
}
if ([keyboardAppearance isEqualToString:@"Brightness.dark"]) {
_activeView.keyboardAppearance = UIKeyboardAppearanceDark;
} else if ([keyboardAppearance isEqualToString:@"Brightness.light"]) {
Expand Down

0 comments on commit a7b6ee5

Please sign in to comment.