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.
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_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_windows=C:\\Libs\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\path_provider_windows-0.0.5\\
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_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_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"}
\ No newline at end of file
{"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
This diff is collapsed.
sdk.dir=C:\\Users\\herry\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\Libs\\flutter
\ No newline at end of file
sdk.dir=C:\\Users\\Manuel\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\_libs\\flutter
\ No newline at end of file
This diff is collapsed.
......@@ -6,32 +6,25 @@ class LoginForm extends StatefulWidget {
final Function(String, String) loginAttempt;
final String error;
final bool isBusy;
LoginForm(this.loginAttempt, this.error);
LoginForm(this.loginAttempt, this.error, this.isBusy);
}
class _LoginFormState extends State<LoginForm> {
bool _busy = false;
String _username = "";
String _password = "";
void _submit() {
setState(() {
_busy = true;
});
widget.loginAttempt(_username, _password);
if (!widget.isBusy) widget.loginAttempt(_username, _password);
}
@override
Widget build(BuildContext context) {
_busy = false;
return FractionallySizedBox(
widthFactor: .3,
child: FocusTraversalGroup(
policy: OrderedTraversalPolicy(),
return FocusTraversalGroup(
policy: OrderedTraversalPolicy(),
child: FractionallySizedBox(
widthFactor: .6,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
......@@ -41,10 +34,11 @@ class _LoginFormState extends State<LoginForm> {
),
SizedBox(height: 32),
TextField(
readOnly: _busy,
readOnly: widget.isBusy,
autofocus: true,
decoration: InputDecoration(
hintText: "Username",
counterText: "",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
......@@ -58,12 +52,14 @@ class _LoginFormState extends State<LoginForm> {
maxLines: 1,
maxLength: 50,
),
SizedBox(height: 16),
TextField(
readOnly: _busy,
readOnly: widget.isBusy,
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: "Password",
counterText: "",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5.0),
borderSide: BorderSide(
......@@ -86,7 +82,8 @@ class _LoginFormState extends State<LoginForm> {
style: TextStyle(color: Colors.red),
),
),
// login button
SizedBox(height: 16),
TextButton.icon(
onPressed: _submit,
icon: Icon(
......@@ -99,7 +96,9 @@ class _LoginFormState extends State<LoginForm> {
style: TextStyle(fontSize: 20, color: Colors.white),
),
style: TextButton.styleFrom(
backgroundColor: Theme.of(context).primaryColor,
backgroundColor: widget.isBusy
? Colors.grey
: Theme.of(context).primaryColor,
padding: EdgeInsets.all(18),
),
),
......
......@@ -16,24 +16,81 @@ class LoginPage extends StatefulWidget {
class _LoginPageState extends State<LoginPage> {
String _error;
bool _isBusy = false;
final Logger logger = Logger();
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: LoginForm(tryLogin, _error),
body: Container(
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 {
logger.i("Loggin Attempt($username, ******)");
setState(() {
_error = "";
_isBusy = true;
});
BackendUser user;
await Future.delayed(Duration(seconds: 1));
try {
user = await LoginHelper().login(username, password);
} on LoginException catch (e) {
setState(() {
_error = e.message;
_isBusy = false;
});
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