Signed-off-by: Nikolai Rodionov <allanger@posteo.de>
This commit is contained in:
@@ -49,78 +49,104 @@ class _LoginForm extends ConsumerState<LoginForm> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = ref.read(authorizationControllerProvider.notifier);
|
||||
return SizedBox(
|
||||
width: 400,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
final state = ref.watch(authorizationControllerProvider);
|
||||
return LayoutBuilder(
|
||||
builder: ((context, constraints) {
|
||||
return Stack(
|
||||
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,
|
||||
),
|
||||
child: const Text(
|
||||
"Sign up now",
|
||||
style: TextStyle(decoration: TextDecoration.underline),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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),
|
||||
width: 400,
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
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,
|
||||
),
|
||||
child: const Text(
|
||||
"Sign up now",
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _submitForm,
|
||||
child: const Text('Log in'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
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()),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user