visiblePassword uses ASCII keyboard on iOS (flutter/engine#50293)

Fixes https://github.com/flutter/flutter/issues/129113

The documentation states that the `visiblePassword` input type
> Requests a keyboard with ready access to both letters and numbers.

`UIKeyboardTypeASCIICapable` seems to be the closest match.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
LongCatIsLooong
2024-02-05 13:34:09 -08:00
committed by GitHub
parent b763483b43
commit 0c52de1fda
2 changed files with 17 additions and 0 deletions

View File

@@ -137,6 +137,9 @@ static UIKeyboardType ToUIKeyboardType(NSDictionary* type) {
if ([inputType isEqualToString:@"TextInputType.url"]) {
return UIKeyboardTypeURL;
}
if ([inputType isEqualToString:@"TextInputType.visiblePassword"]) {
return UIKeyboardTypeASCIICapable;
}
return UIKeyboardTypeDefault;
}

View File

@@ -307,6 +307,20 @@ FLUTTER_ASSERT_ARC
XCTAssertEqual(inputView.keyboardType, UIKeyboardTypeURL);
}
- (void)testVisiblePasswordUseAlphanumeric {
NSDictionary* config = self.mutableTemplateCopy;
[config setValue:@{@"name" : @"TextInputType.visiblePassword"} forKey:@"inputType"];
[self setClientId:123 configuration:config];
// Find all the FlutterTextInputViews we created.
NSArray<FlutterTextInputView*>* inputFields = self.installedInputViews;
FlutterTextInputView* inputView = inputFields[0];
// Verify keyboardType is set to the value specified in config.
XCTAssertEqual(inputView.keyboardType, UIKeyboardTypeASCIICapable);
}
- (void)testSettingKeyboardTypeNoneDisablesSystemKeyboard {
NSDictionary* config = self.mutableTemplateCopy;
[config setValue:@{@"name" : @"TextInputType.none"} forKey:@"inputType"];