ft/disables buttons on submit
This commit is contained in:
parent
7750972a42
commit
ef7f6c093f
@ -3,11 +3,28 @@ import 'package:app/widgets/background.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
Future<bool> showLogin(BuildContext context) async {
|
Future<bool> showLogin(BuildContext context) async {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final formKey = GlobalKey<FormState>();
|
||||||
final mailController = TextEditingController();
|
final mailController = TextEditingController();
|
||||||
final passwordController = TextEditingController();
|
final passwordController = TextEditingController();
|
||||||
|
|
||||||
bool _loggedin = false;
|
bool submitted = false;
|
||||||
|
bool loggedin = false;
|
||||||
|
void login() {
|
||||||
|
if (formKey.currentState!.validate()) {
|
||||||
|
submitted = true;
|
||||||
|
BackendService.login(
|
||||||
|
email: mailController.text,
|
||||||
|
password: passwordController.text,
|
||||||
|
).then(
|
||||||
|
(r) {
|
||||||
|
if (r) {
|
||||||
|
loggedin = r;
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
@ -42,7 +59,7 @@ Future<bool> showLogin(BuildContext context) async {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Form(
|
Form(
|
||||||
key: _formKey,
|
key: formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
@ -97,27 +114,15 @@ Future<bool> showLogin(BuildContext context) async {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: !submitted
|
||||||
Navigator.pop(context);
|
? () {
|
||||||
},
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
child: const Icon(Icons.arrow_back),
|
child: const Icon(Icons.arrow_back),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: !submitted ? login : null,
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
BackendService.login(
|
|
||||||
email: mailController.text,
|
|
||||||
password: passwordController.text,
|
|
||||||
).then(
|
|
||||||
(r) {
|
|
||||||
if (r) {
|
|
||||||
_loggedin = r;
|
|
||||||
Navigator.pop(context, true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.login),
|
child: const Icon(Icons.login),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -130,5 +135,5 @@ Future<bool> showLogin(BuildContext context) async {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return _loggedin;
|
return loggedin;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user