TF-1434 Implement autofillHints for login view
(cherry picked from commit dde68350d558fece56e46f8ce11916a2f673b26d)
This commit is contained in:
@@ -94,11 +94,13 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildInputCredentialForm(BuildContext context) {
|
Widget buildInputCredentialForm(BuildContext context) {
|
||||||
return Column(
|
return AutofillGroup(
|
||||||
children: [
|
child: Column(
|
||||||
buildUserNameInput(context),
|
children: [
|
||||||
buildPasswordInput(context)
|
buildUserNameInput(context),
|
||||||
],
|
buildPasswordInput(context)
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +113,8 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
controller: loginController.usernameInputController,
|
controller: loginController.usernameInputController,
|
||||||
onChanged: (value) => loginController.setUserNameText(value),
|
onChanged: (value) => loginController.setUserNameText(value),
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
|
autocorrect: false,
|
||||||
|
autofillHints: [AutofillHints.email],
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
decoration: (LoginInputDecorationBuilder()
|
decoration: (LoginInputDecorationBuilder()
|
||||||
..setLabelText(AppLocalizations.of(context).email)
|
..setLabelText(AppLocalizations.of(context).email)
|
||||||
@@ -141,16 +145,21 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 40, right: 24, left: 24),
|
padding: const EdgeInsets.only(bottom: 40, right: 24, left: 24),
|
||||||
child: Container(
|
child: Container(
|
||||||
child: (LoginTextInputBuilder(context, imagePaths)
|
child: (LoginTextInputBuilder(
|
||||||
..setOnSubmitted((value) => loginController.handleLoginPressed())
|
context,
|
||||||
..passwordInput(true)
|
imagePaths,
|
||||||
..key(const Key('login_password_input'))
|
autocorrect: false,
|
||||||
..obscureText(true)
|
autofillHints: [AutofillHints.password]
|
||||||
..onChange((value) => loginController.setPasswordText(value))
|
)
|
||||||
..textInputAction(TextInputAction.done)
|
..setOnSubmitted((value) => loginController.handleLoginPressed())
|
||||||
..hintText(AppLocalizations.of(context).password)
|
..passwordInput(true)
|
||||||
..setFocusNode(passFocusNode))
|
..key(const Key('login_password_input'))
|
||||||
.build()));
|
..obscureText(true)
|
||||||
|
..onChange(loginController.setPasswordText)
|
||||||
|
..textInputAction(TextInputAction.done)
|
||||||
|
..hintText(AppLocalizations.of(context).password)
|
||||||
|
..setFocusNode(passFocusNode))
|
||||||
|
.build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildLoadingCircularProgress() {
|
Widget buildLoadingCircularProgress() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:core/utils/build_utils.dart';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
import 'package:model/account/password.dart';
|
import 'package:model/account/password.dart';
|
||||||
@@ -241,6 +242,8 @@ class LoginController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void handleLoginPressed() {
|
void handleLoginPressed() {
|
||||||
|
TextInput.finishAutofillContext();
|
||||||
|
|
||||||
_saveRecentLoginUsername();
|
_saveRecentLoginUsername();
|
||||||
log('LoginController::handleLoginPressed(): ${loginFormType.value}');
|
log('LoginController::handleLoginPressed(): ${loginFormType.value}');
|
||||||
if (loginFormType.value == LoginFormType.ssoForm) {
|
if (loginFormType.value == LoginFormType.ssoForm) {
|
||||||
|
|||||||
@@ -24,11 +24,19 @@ class LoginTextInputBuilder {
|
|||||||
bool? _passwordInput;
|
bool? _passwordInput;
|
||||||
OnSubmitted? _onSubmitted;
|
OnSubmitted? _onSubmitted;
|
||||||
FocusNode? _focusNode;
|
FocusNode? _focusNode;
|
||||||
|
final List<String>? autofillHints;
|
||||||
|
final bool autocorrect;
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
final ImagePaths imagePaths;
|
final ImagePaths imagePaths;
|
||||||
|
|
||||||
LoginTextInputBuilder(this.context, this.imagePaths);
|
LoginTextInputBuilder(
|
||||||
|
this.context,
|
||||||
|
this.imagePaths,
|
||||||
|
{
|
||||||
|
this.autocorrect = true,
|
||||||
|
this.autofillHints
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
void key(Key key) {
|
void key(Key key) {
|
||||||
_key = key;
|
_key = key;
|
||||||
@@ -119,6 +127,8 @@ class LoginTextInputBuilder {
|
|||||||
onChanged: (value) => _onTextChanged(value, setState),
|
onChanged: (value) => _onTextChanged(value, setState),
|
||||||
obscureText: _obscureText ?? false,
|
obscureText: _obscureText ?? false,
|
||||||
textInputAction: _textInputAction,
|
textInputAction: _textInputAction,
|
||||||
|
autofillHints: autofillHints,
|
||||||
|
autocorrect: autocorrect,
|
||||||
controller: _textEditingController,
|
controller: _textEditingController,
|
||||||
cursorColor: AppColor.primaryColor,
|
cursorColor: AppColor.primaryColor,
|
||||||
style: const TextStyle(color: AppColor.loginTextFieldHintColor, fontSize: 16, fontWeight: FontWeight.normal),
|
style: const TextStyle(color: AppColor.loginTextFieldHintColor, fontSize: 16, fontWeight: FontWeight.normal),
|
||||||
|
|||||||
+6
-5
@@ -772,11 +772,12 @@ packages:
|
|||||||
flutter_typeahead:
|
flutter_typeahead:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_typeahead
|
path: "."
|
||||||
sha256: "3f7509bc1d43e245e0bfdc180f206508bc5ab0e0d84ce1b891cb0e4176b7802f"
|
ref: support-autofillhint
|
||||||
url: "https://pub.dev"
|
resolved-ref: "121707e2c283dae5299dc22974850d65f6c97b83"
|
||||||
source: hosted
|
url: "https://github.com/dab246/flutter_typeahead.git"
|
||||||
version: "4.3.6"
|
source: git
|
||||||
|
version: "4.3.7"
|
||||||
flutter_web_plugins:
|
flutter_web_plugins:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|||||||
+5
-2
@@ -81,6 +81,11 @@ dependencies:
|
|||||||
url: https://github.com/linagora/flutter-date-range-picker.git
|
url: https://github.com/linagora/flutter-date-range-picker.git
|
||||||
ref: master
|
ref: master
|
||||||
|
|
||||||
|
flutter_typeahead:
|
||||||
|
git:
|
||||||
|
url: https://github.com/dab246/flutter_typeahead.git
|
||||||
|
ref: support-autofillhint
|
||||||
|
|
||||||
### Dependencies from pub.dev ###
|
### Dependencies from pub.dev ###
|
||||||
cupertino_icons: 1.0.5
|
cupertino_icons: 1.0.5
|
||||||
|
|
||||||
@@ -100,8 +105,6 @@ dependencies:
|
|||||||
|
|
||||||
flutter_dotenv: 5.0.2
|
flutter_dotenv: 5.0.2
|
||||||
|
|
||||||
flutter_typeahead: 4.3.6
|
|
||||||
|
|
||||||
built_collection: 5.1.1
|
built_collection: 5.1.1
|
||||||
|
|
||||||
textfield_tags: 2.0.2
|
textfield_tags: 2.0.2
|
||||||
|
|||||||
Reference in New Issue
Block a user