From 2533c23703acbde234c91a9455af6a49c742cdf1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 17 Apr 2021 11:46:57 +0200 Subject: [PATCH] Fix tablet appearance of login screens --- lib/ui/routes/create_account_route.dart | 4 +-- lib/ui/routes/forgot_password_route.dart | 4 +-- lib/ui/routes/login_route.dart | 4 +-- lib/ui/routes/password_reset_route.dart | 4 +-- lib/ui/widgets/login_route_container.dart | 36 +++++++++++++++++++++++ 5 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 lib/ui/widgets/login_route_container.dart diff --git a/lib/ui/routes/create_account_route.dart b/lib/ui/routes/create_account_route.dart index 41832b8..0b5e6c0 100644 --- a/lib/ui/routes/create_account_route.dart +++ b/lib/ui/routes/create_account_route.dart @@ -1,6 +1,6 @@ import 'package:comunic/ui/routes/login_route.dart'; import 'package:comunic/ui/widgets/create_account_widget.dart'; -import 'package:comunic/ui/widgets/login_routes_theme.dart'; +import 'package:comunic/ui/widgets/login_route_container.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -12,7 +12,7 @@ import 'package:flutter/material.dart'; class CreateAccountRoute extends StatelessWidget { @override Widget build(BuildContext context) { - return LoginRoutesTheme( + return LoginRouteContainer( child: Scaffold( appBar: AppBar( title: Text(tr("Create an account")), diff --git a/lib/ui/routes/forgot_password_route.dart b/lib/ui/routes/forgot_password_route.dart index 08c3306..86efc6b 100644 --- a/lib/ui/routes/forgot_password_route.dart +++ b/lib/ui/routes/forgot_password_route.dart @@ -1,7 +1,7 @@ import 'package:comunic/helpers/account_helper.dart'; import 'package:comunic/ui/routes/password_reset_route.dart'; import 'package:comunic/ui/widgets/dialogs/cancel_dialog_button.dart'; -import 'package:comunic/ui/widgets/login_routes_theme.dart'; +import 'package:comunic/ui/widgets/login_route_container.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/utils/input_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -17,7 +17,7 @@ import 'package:flutter/rendering.dart'; class ForgotPasswordRoute extends StatelessWidget { @override Widget build(BuildContext context) { - return LoginRoutesTheme( + return LoginRouteContainer( child: Scaffold( appBar: AppBar( title: Text(tr("Password forgotten")), diff --git a/lib/ui/routes/login_route.dart b/lib/ui/routes/login_route.dart index b7c3d86..faa197a 100644 --- a/lib/ui/routes/login_route.dart +++ b/lib/ui/routes/login_route.dart @@ -1,6 +1,6 @@ import 'package:comunic/ui/routes/forgot_password_route.dart'; import 'package:comunic/ui/widgets/init_widget.dart'; -import 'package:comunic/ui/widgets/login_routes_theme.dart'; +import 'package:comunic/ui/widgets/login_route_container.dart'; import 'package:comunic/ui/widgets/login_widget.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; @@ -22,7 +22,7 @@ class _LoginRouteState extends State { @override Widget build(BuildContext context) { - return LoginRoutesTheme( + return LoginRouteContainer( child: Scaffold( appBar: AppBar( title: Text(tr("Login to Comunic")), diff --git a/lib/ui/routes/password_reset_route.dart b/lib/ui/routes/password_reset_route.dart index ad71441..8c55a96 100644 --- a/lib/ui/routes/password_reset_route.dart +++ b/lib/ui/routes/password_reset_route.dart @@ -2,7 +2,7 @@ import 'package:comunic/helpers/account_helper.dart'; import 'package:comunic/models/res_check_password_reset_token.dart'; import 'package:comunic/ui/dialogs/input_new_password_dialog.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart'; -import 'package:comunic/ui/widgets/login_routes_theme.dart'; +import 'package:comunic/ui/widgets/login_route_container.dart'; import 'package:comunic/ui/widgets/new_password_input_widget.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -24,7 +24,7 @@ class PasswordResetRoute extends StatelessWidget { @override Widget build(BuildContext context) { - return LoginRoutesTheme( + return LoginRouteContainer( child: Scaffold( appBar: AppBar( title: Text(tr("Change your password")), diff --git a/lib/ui/widgets/login_route_container.dart b/lib/ui/widgets/login_route_container.dart new file mode 100644 index 0000000..d634cb2 --- /dev/null +++ b/lib/ui/widgets/login_route_container.dart @@ -0,0 +1,36 @@ +import 'package:comunic/models/config.dart'; +import 'package:comunic/ui/widgets/login_routes_theme.dart'; +import 'package:comunic/utils/ui_utils.dart'; +import 'package:flutter/material.dart'; + +/// Login route container +/// +/// Contains both theme and route centering +/// +/// @author Pierre Hubert + +class LoginRouteContainer extends StatelessWidget { + final Widget child; + + const LoginRouteContainer({Key key, @required this.child}) : super(key: key); + + @override + Widget build(BuildContext context) { + if (!isTablet(context)) return LoginRoutesTheme(child: child); + + return Container( + color: Config.get().splashBackgroundColor, + child: Padding( + padding: EdgeInsets.only(top: 10), + child: Center( + child: LoginRoutesTheme( + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 370), + child: child, + ), + ), + ), + ), + ); + } +}