diff --git a/Taskfile.yml b/Taskfile.yml index 34de945..16fa8ed 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -8,7 +8,7 @@ vars: tasks: serve: desc: Run web-server - cmd: flutter run -d web-server --web-port 8080 + cmd: flutter run -d web-server --web-port '{{ .DEFAULT_PORT }}' silent: true get-proto-from-branch: diff --git a/lib/features/authorization/application/authorization_application.dart b/lib/features/authorization/application/authorization_application.dart index 34bb057..1f391a7 100644 --- a/lib/features/authorization/application/authorization_application.dart +++ b/lib/features/authorization/application/authorization_application.dart @@ -1,4 +1,5 @@ import 'dart:developer'; +import 'dart:io'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:softplayer_web/core/api/v1/public_accounts.dart'; @@ -38,10 +39,10 @@ class AuthorizationController extends AsyncNotifier { Future signin(SignInData form) async { state = const AsyncLoading(); + sleep(Duration(seconds: 10)); state = await AsyncValue.guard(() async { final accountsGrpc = ref.read(publicAccountsGrpcProvider); final tokenCtrl = ref.read(tokensControllerProvider.notifier); - try { final response = await accountsGrpc.signIn(form.toProto()); await tokenCtrl.writeTokenPair(Tokens.fromProto(response.tokenPair)); diff --git a/lib/features/authorization/presentation/login_form.dart b/lib/features/authorization/presentation/login_form.dart index 7b9e94f..821bb9d 100644 --- a/lib/features/authorization/presentation/login_form.dart +++ b/lib/features/authorization/presentation/login_form.dart @@ -58,92 +58,89 @@ class _LoginForm extends ConsumerState { width: 400, child: Form( key: _formKey, - child: Column( - children: [ - Container( - alignment: Alignment.topLeft, - child: SelectableText( - "Welcome back!", - style: Theme.of(context).textTheme.headlineLarge, + child: AutofillGroup( + child: Column( + children: [ + Container( + alignment: Alignment.topLeft, + child: SelectableText( + "Welcome back!", + style: Theme.of(context).textTheme.headlineLarge, + ), ), - ), - SizedBox(height: 12), - Container( - alignment: Alignment.topLeft, - child: Row( - children: [ - Text( - "Don't have an account yet? ", - style: Theme.of(context).textTheme.bodyMedium, - ), - TextButton( - onPressed: widget.toggleAuth, - style: TextButton.styleFrom( - padding: EdgeInsets.zero, - minimumSize: Size(0, 0), - tapTargetSize: MaterialTapTargetSize.shrinkWrap, + SizedBox(height: 12), + Container( + alignment: Alignment.topLeft, + child: Row( + children: [ + Text( + "Don't have an account yet? ", + style: Theme.of(context).textTheme.bodyMedium, ), - child: const Text( - "Sign up now", - style: TextStyle( - decoration: TextDecoration.underline, + TextButton( + onPressed: widget.toggleAuth, + style: TextButton.styleFrom( + padding: EdgeInsets.zero, + minimumSize: Size(0, 0), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + child: const Text( + "Sign up now", + style: TextStyle( + decoration: TextDecoration.underline, + ), ), ), - ), + ], + ), + ), + SizedBox(height: 36), + TextFormField( + autofillHints: const [ + AutofillHints.username, + AutofillHints.email, ], + onFieldSubmitted: (_) => _submitForm(), + controller: emailCtrl, + decoration: InputDecoration(hintText: "Email address"), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Email is required'; + } + return null; + }, ), - ), - SizedBox(height: 36), - TextFormField( - onFieldSubmitted: (_) => _submitForm(), - controller: emailCtrl, - decoration: InputDecoration(hintText: "Email address"), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Email is required'; - } - return null; - }, - ), - SizedBox(height: 16), - TextFormField( - onFieldSubmitted: (_) => _submitForm(), - controller: passwordCtrl, - obscureText: true, - decoration: InputDecoration(hintText: "Password"), - validator: (value) { - if (value == null || value.isEmpty) { - return 'Password is required'; - } - return null; - }, - ), - SizedBox(height: 16), - SizedBox( - width: double.infinity, - child: Text( - "Forgot password?", - textAlign: TextAlign.left, + SizedBox(height: 16), + TextFormField( + onFieldSubmitted: (_) => _submitForm(), + autofillHints: const [AutofillHints.password], + controller: passwordCtrl, + obscureText: true, + decoration: InputDecoration(hintText: "Password"), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Password is required'; + } + return null; + }, ), - ), - ElevatedButton( - onPressed: _submitForm, - child: const Text('Log in'), - ), - ], - ), - ), - ), - if (state.isLoading) - Positioned.fill( - child: AbsorbPointer( - absorbing: true, - child: Container( - color: Colors.black45, - child: const Center(child: CircularProgressIndicator()), + SizedBox(height: 16), + SizedBox( + width: double.infinity, + child: Text( + "Forgot password?", + textAlign: TextAlign.left, + ), + ), + ElevatedButton( + onPressed: _submitForm, + child: const Text('Log in'), + ), + ], ), ), ), + ), ], ); }),