Add support for TextInputType.emailAddress (flutter/engine#3729)

Adds support for requesting a platform keyboard optimised for entering
email addresses.
This commit is contained in:
Chris Bracken
2017-06-02 15:04:35 -07:00
committed by GitHub
parent 3d69c9e24a
commit 0d10984a47
2 changed files with 9 additions and 3 deletions

View File

@@ -80,9 +80,13 @@ public class TextInputPlugin implements MethodCallHandler {
return InputType.TYPE_CLASS_NUMBER;
if (inputType.equals("TextInputType.phone"))
return InputType.TYPE_CLASS_PHONE;
return obscureText
? InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
: InputType.TYPE_CLASS_TEXT;
int textType = InputType.TYPE_CLASS_TEXT;
if (inputType.equals("TextInputType.emailAddress"))
textType |= InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
if (obscureText)
textType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
return textType;
}
public InputConnection createInputConnection(FlutterView view, EditorInfo outAttrs)

View File

@@ -16,6 +16,8 @@ static UIKeyboardType ToUIKeyboardType(NSString* inputType) {
return UIKeyboardTypeDecimalPad;
if ([inputType isEqualToString:@"TextInputType.phone"])
return UIKeyboardTypePhonePad;
if ([inputType isEqualToString:@"TextInputType.emailAddress"])
return UIKeyboardTypeEmailAddress;
return UIKeyboardTypeDefault;
}