From e3c9105b1c84b4adbcdd1854b18982395988dcf1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 4 May 2020 19:05:21 +0200 Subject: [PATCH] Improve login route --- lib/ui/routes/login_route.dart | 12 +++---- lib/ui/widgets/login_scaffold.dart | 57 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 lib/ui/widgets/login_scaffold.dart diff --git a/lib/ui/routes/login_route.dart b/lib/ui/routes/login_route.dart index 1604185..2e6afee 100644 --- a/lib/ui/routes/login_route.dart +++ b/lib/ui/routes/login_route.dart @@ -3,6 +3,7 @@ import 'package:comunic/models/authentication_details.dart'; import 'package:comunic/ui/routes/create_account_route.dart'; import 'package:comunic/ui/routes/reset_password_route.dart'; import 'package:comunic/ui/widgets/init_widget.dart'; +import 'package:comunic/ui/widgets/login_scaffold.dart'; import 'package:comunic/utils/input_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/ui_utils.dart'; @@ -96,7 +97,6 @@ class _LoginRouteState extends State { padding: const EdgeInsets.all(8.0), child: Column( children: [ - Text(tr("Please sign into your Comunic account: ")), Container( child: _buildErrorCard(), ), @@ -136,7 +136,7 @@ class _LoginRouteState extends State { InkWell( child: Text( tr("Create an account"), - style: TextStyle(color: Colors.blue), + style: TextStyle(color: Colors.blue.shade100), ), onTap: () => _openCreateAccountPage(), ), @@ -146,7 +146,7 @@ class _LoginRouteState extends State { InkWell( child: Text( tr("Password forgotten"), - style: TextStyle(color: Colors.blue), + style: TextStyle(color: Colors.blue.shade100), ), onTap: _openResetPasswordPage, ), @@ -158,10 +158,6 @@ class _LoginRouteState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("Comunic"), - ), - body: _buildLoginForm()); + return LoginScaffold(child: _buildLoginForm()); } } diff --git a/lib/ui/widgets/login_scaffold.dart b/lib/ui/widgets/login_scaffold.dart new file mode 100644 index 0000000..ae7f31d --- /dev/null +++ b/lib/ui/widgets/login_scaffold.dart @@ -0,0 +1,57 @@ +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; + +/// Custom "Scaffold" for signed out users +/// +/// @author Pierre Hubert + +class LoginScaffold extends StatelessWidget { + final Widget child; + + const LoginScaffold({Key key, @required this.child}) + : assert(child != null), + super(key: key); + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + + final availableHeight = + mediaQuery.size.height - mediaQuery.viewInsets.bottom; + final minHeight = 400.0; + + final contentHeight = + availableHeight < minHeight ? minHeight : availableHeight; + + return Scaffold( + body: SingleChildScrollView( + child: Center( + child: Container( + height: contentHeight, + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 300), + child: Column( + children: [ + Spacer(flex: 3), + Text("Comunic", style: TextStyle(fontSize: 50)), + Spacer(flex: 1), + Text(tr("Free social network that respect your privacy")), + Spacer(flex: 1), + Padding( + padding: const EdgeInsets.all(8.0), + child: Material( + child: child, + color: Colors.indigo.shade500, + ), + ), + Spacer(flex: 5), + ], + ), + ), + ), + ), + ), + backgroundColor: Colors.indigo.shade900, + ); + } +}