From 0c52de1fdaf4677a937e10474a0eddb8c722c077 Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:34:09 -0800 Subject: [PATCH] `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 --- .../ios/framework/Source/FlutterTextInputPlugin.mm | 3 +++ .../framework/Source/FlutterTextInputPluginTest.mm | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 5137976f70..75195368a7 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -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; } diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index faee42df1b..17ef8b2f2c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -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* 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"];