Commit 663b2342 authored by Manuel's avatar Manuel

added nice design to login page

parent e30cd5ab
# This is a generated file; do not edit or check into version control. # This is a generated file; do not edit or check into version control.
integration_test=C:\\Libs\\flutter\\packages\\integration_test\\ integration_test=C:\\_libs\\flutter\\packages\\integration_test\\
path_provider=C:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider-1.6.27\\ path_provider=C:\\_libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider-1.6.27\\
path_provider_linux=C:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_linux-0.0.1+2\\ path_provider_linux=C:\\_libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_linux-0.0.1+2\\
path_provider_macos=C:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_macos-0.0.4+8\\ path_provider_macos=C:\\_libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_macos-0.0.4+8\\
path_provider_windows=C:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_windows-0.0.5\\ path_provider_windows=C:\\_libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_windows-0.0.5\\
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+8\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.5\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-03-10 23:11:13.267004","version":"2.0.1"} {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\_libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\_libs\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.27\\\\","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-0.0.4+8\\\\","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-0.0.1+2\\\\","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\_libs\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-0.0.5\\\\","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2021-03-11 10:31:52.781121","version":"2.0.1"}
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
sdk.dir=C:\\Users\\herry\\AppData\\Local\\Android\\sdk sdk.dir=C:\\Users\\Manuel\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\Libs\\flutter flutter.sdk=C:\\_libs\\flutter
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
...@@ -6,32 +6,25 @@ class LoginForm extends StatefulWidget { ...@@ -6,32 +6,25 @@ class LoginForm extends StatefulWidget {
final Function(String, String) loginAttempt; final Function(String, String) loginAttempt;
final String error; final String error;
final bool isBusy;
LoginForm(this.loginAttempt, this.error); LoginForm(this.loginAttempt, this.error, this.isBusy);
} }
class _LoginFormState extends State<LoginForm> { class _LoginFormState extends State<LoginForm> {
bool _busy = false;
String _username = ""; String _username = "";
String _password = ""; String _password = "";
void _submit() { void _submit() {
setState(() { if (!widget.isBusy) widget.loginAttempt(_username, _password);
_busy = true;
});
widget.loginAttempt(_username, _password);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_busy = false; return FocusTraversalGroup(
policy: OrderedTraversalPolicy(),
return FractionallySizedBox( child: FractionallySizedBox(
widthFactor: .3, widthFactor: .6,
child: FocusTraversalGroup(
policy: OrderedTraversalPolicy(),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
...@@ -41,10 +34,11 @@ class _LoginFormState extends State<LoginForm> { ...@@ -41,10 +34,11 @@ class _LoginFormState extends State<LoginForm> {
), ),
SizedBox(height: 32), SizedBox(height: 32),
TextField( TextField(
readOnly: _busy, readOnly: widget.isBusy,
autofocus: true, autofocus: true,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Username", hintText: "Username",
counterText: "",
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0), borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide( borderSide: BorderSide(
...@@ -58,12 +52,14 @@ class _LoginFormState extends State<LoginForm> { ...@@ -58,12 +52,14 @@ class _LoginFormState extends State<LoginForm> {
maxLines: 1, maxLines: 1,
maxLength: 50, maxLength: 50,
), ),
SizedBox(height: 16),
TextField( TextField(
readOnly: _busy, readOnly: widget.isBusy,
autofocus: false, autofocus: false,
obscureText: true, obscureText: true,
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Password", hintText: "Password",
counterText: "",
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0), borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide( borderSide: BorderSide(
...@@ -86,7 +82,8 @@ class _LoginFormState extends State<LoginForm> { ...@@ -86,7 +82,8 @@ class _LoginFormState extends State<LoginForm> {
style: TextStyle(color: Colors.red), style: TextStyle(color: Colors.red),
), ),
), ),
// login button
SizedBox(height: 16),
TextButton.icon( TextButton.icon(
onPressed: _submit, onPressed: _submit,
icon: Icon( icon: Icon(
...@@ -99,7 +96,9 @@ class _LoginFormState extends State<LoginForm> { ...@@ -99,7 +96,9 @@ class _LoginFormState extends State<LoginForm> {
style: TextStyle(fontSize: 20, color: Colors.white), style: TextStyle(fontSize: 20, color: Colors.white),
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor, backgroundColor: widget.isBusy
? Colors.grey
: Theme.of(context).primaryColor,
padding: EdgeInsets.all(18), padding: EdgeInsets.all(18),
), ),
), ),
......
...@@ -16,24 +16,81 @@ class LoginPage extends StatefulWidget { ...@@ -16,24 +16,81 @@ class LoginPage extends StatefulWidget {
class _LoginPageState extends State<LoginPage> { class _LoginPageState extends State<LoginPage> {
String _error; String _error;
bool _isBusy = false;
final Logger logger = Logger(); final Logger logger = Logger();
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Center( body: Container(
child: LoginForm(tryLogin, _error), decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.blue[300],
Colors.blue,
],
),
),
padding: EdgeInsets.symmetric(horizontal: 32, vertical: 64),
child: Container(
color: Colors.white,
child: Row(
children: [
Expanded(
flex: 4,
child: Container(
child: LoginForm(tryLogin, _error, _isBusy),
),
),
Expanded(
flex: 3,
child: Container(
constraints: BoxConstraints.expand(),
child: Stack(
children: [
Container(
constraints: BoxConstraints.expand(),
child: Image.asset(
"assets/login_image.jpg",
fit: BoxFit.cover,
alignment: Alignment(-.2, 0),
),
),
Container(
color: Color.fromRGBO(33, 150, 243, .5),
),
],
),
),
),
],
),
),
), ),
); );
} }
///
/// attempts to receive a token from the server
///
void tryLogin(String username, String password) async { void tryLogin(String username, String password) async {
logger.i("Loggin Attempt($username, ******)");
setState(() {
_error = "";
_isBusy = true;
});
BackendUser user; BackendUser user;
await Future.delayed(Duration(seconds: 1));
try { try {
user = await LoginHelper().login(username, password); user = await LoginHelper().login(username, password);
} on LoginException catch (e) { } on LoginException catch (e) {
setState(() { setState(() {
_error = e.message; _error = e.message;
_isBusy = false;
}); });
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment