Shared space
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/services/auth.service.dart';
|
||||
@@ -14,9 +15,34 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
|
||||
String? error;
|
||||
bool loading = false;
|
||||
|
||||
FocusNode focusNode = FocusNode();
|
||||
@override Widget build(BuildContext context) {
|
||||
return Padding(padding: const EdgeInsets.all(50), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
return KeyboardListener(focusNode: focusNode,
|
||||
onKeyEvent: (value) {
|
||||
if (value is KeyDownEvent && value.logicalKey == LogicalKeyboardKey.enter) {
|
||||
if (usernameCtrl.text == "" || passwordCtrl.text == "") { return; }
|
||||
error = null;
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
AuthService.login(usernameCtrl.text, passwordCtrl.text).catchError( (e) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
error = "Invalid username or password";
|
||||
});
|
||||
});
|
||||
|
||||
if (error == null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
context.pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(50), child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
const Center(child: Icon(Icons.person_search, size: 150, color: Colors.grey,)),
|
||||
Center(child: Padding( padding: const EdgeInsets.only(top: 5, bottom: 20),
|
||||
child: Text("WELCOME ON OPENCLOUD", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600,
|
||||
@@ -100,6 +126,6 @@ class LoginWidgetState extends State<LoginWidget> {
|
||||
fontSize: 15) ))))),
|
||||
])
|
||||
]),
|
||||
],));
|
||||
],)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user