1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Improve signup route

This commit is contained in:
Pierre HUBERT 2021-04-17 10:59:06 +02:00
parent 9555d35521
commit ab60593f12
5 changed files with 90 additions and 47 deletions

View File

@ -1,3 +1,4 @@
import 'package:comunic/models/config.dart';
import 'package:comunic/ui/widgets/create_account_widget.dart'; import 'package:comunic/ui/widgets/create_account_widget.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -11,10 +12,52 @@ class CreateAccountRoute extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Config.get().splashBackgroundColor,
appBar: AppBar( appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
title: Text(tr("Create an account")), title: Text(tr("Create an account")),
), ),
body: _CreateAccountRouteBody(), body: Theme(
data: Theme.of(context).copyWith(
iconTheme: IconThemeData(color: Colors.white),
inputDecorationTheme: InputDecorationTheme(
fillColor: Colors.white,
hintStyle: TextStyle(color: Colors.white),
labelStyle: TextStyle(color: Colors.white),
prefixStyle: TextStyle(color: Colors.white),
hoverColor: Colors.white,
errorStyle: TextStyle(color: Colors.deepOrangeAccent),
),
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.all(Colors.white),
checkColor:
MaterialStateProperty.all(Config.get().splashBackgroundColor),
),
primaryColor: Colors.white,
backgroundColor: Config.get().splashBackgroundColor,
disabledColor: Colors.grey,
highlightColor: Colors.white,
accentColor: Colors.white,
hintColor: Colors.white,
textTheme: TextTheme(subtitle1: TextStyle(color: Colors.white)),
colorScheme: ColorScheme(
primary: Colors.white,
primaryVariant: Colors.white,
secondary: Colors.white,
secondaryVariant: Colors.white,
surface: Config.get().splashBackgroundColor,
background: Config.get().splashBackgroundColor,
error: Colors.redAccent,
onPrimary: Config.get().splashBackgroundColor,
onSecondary: Config.get().splashBackgroundColor,
onSurface: Colors.white,
onBackground: Colors.white,
onError: Colors.redAccent,
brightness: Brightness.dark,
)),
child: _CreateAccountRouteBody(),
),
); );
} }
} }

View File

@ -1,8 +1,6 @@
import 'package:comunic/ui/routes/create_account_route.dart'; import 'package:comunic/ui/routes/create_account_route.dart';
import 'package:comunic/ui/routes/forgot_password_route.dart'; import 'package:comunic/ui/routes/forgot_password_route.dart';
import 'package:comunic/ui/widgets/init_widget.dart';
import 'package:comunic/ui/widgets/login_scaffold.dart'; import 'package:comunic/ui/widgets/login_scaffold.dart';
import 'package:comunic/ui/widgets/login_widget.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -10,12 +8,12 @@ import 'package:flutter/material.dart';
/// ///
/// @author Pierre HUBERT /// @author Pierre HUBERT
class LoginRoute extends StatefulWidget { class WelcomeRoute extends StatefulWidget {
@override @override
State<StatefulWidget> createState() => _LoginRouteState(); State<StatefulWidget> createState() => _WelcomeRouteState();
} }
class _LoginRouteState extends State<LoginRoute> { class _WelcomeRouteState extends State<WelcomeRoute> {
void _openCreateAccountPage() { void _openCreateAccountPage() {
Navigator.of(context) Navigator.of(context)
.push(MaterialPageRoute(builder: (c) => CreateAccountRoute())); .push(MaterialPageRoute(builder: (c) => CreateAccountRoute()));
@ -28,36 +26,27 @@ class _LoginRouteState extends State<LoginRoute> {
/// Build login form /// Build login form
Widget _buildLoginForm() { Widget _buildLoginForm() {
return SingleChildScrollView( return Material(
child: Padding( color: Colors.transparent,
padding: const EdgeInsets.all(8.0), child: Column(
child: Column( children: <Widget>[
children: <Widget>[ ListTile(
LoginWidget( leading: Icon(Icons.login, color: Colors.white),
onSignedIn: () => Navigator.pushReplacement(context, title: Text(tr("Login")),
MaterialPageRoute(builder: (b) => InitializeWidget())), ),
), ListTile(
InkWell( leading: Icon(Icons.person_add_alt_1, color: Colors.white),
child: Text( title: Text(tr("Join the network")),
tr("Create an account"), onTap: _openCreateAccountPage,
style: TextStyle(color: Colors.blue.shade100), )
), ],
onTap: () => _openCreateAccountPage(),
),
Container(height: 10),
InkWell(
child: Text(
tr("Password forgotten"),
style: TextStyle(color: Colors.blue.shade100),
),
onTap: _openResetPasswordPage,
),
],
),
), ),
); );
} }
@override @override
Widget build(BuildContext context) => LoginScaffold(child: _buildLoginForm()); Widget build(BuildContext context) => LoginScaffold(
child: null,
noStyleChild: _buildLoginForm(),
);
} }

View File

@ -278,6 +278,7 @@ class _InputEntry extends StatelessWidget {
obscureText: isPassword, obscureText: isPassword,
maxLength: maxLength, maxLength: maxLength,
decoration: InputDecoration( decoration: InputDecoration(
counterText: "",
alignLabelWithHint: true, alignLabelWithHint: true,
errorText: error, errorText: error,
labelText: label, labelText: label,

View File

@ -59,7 +59,7 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
/// Open login page /// Open login page
_openLoginPage() { _openLoginPage() {
Navigator.of(context) Navigator.of(context)
.pushReplacement(MaterialPageRoute(builder: (c) => LoginRoute())); .pushReplacement(MaterialPageRoute(builder: (c) => WelcomeRoute()));
} }
/// Try to connect to server /// Try to connect to server

View File

@ -1,3 +1,4 @@
import 'package:comunic/models/config.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -7,9 +8,10 @@ import 'package:flutter/material.dart';
class LoginScaffold extends StatelessWidget { class LoginScaffold extends StatelessWidget {
final Widget child; final Widget child;
final Widget noStyleChild;
const LoginScaffold({Key key, @required this.child}) const LoginScaffold({Key key, @required this.child, this.noStyleChild})
: assert(child != null), : assert(child != null || noStyleChild != null),
super(key: key); super(key: key);
@override @override
@ -34,7 +36,7 @@ class LoginScaffold extends StatelessWidget {
fillColor: Colors.white, fillColor: Colors.white,
hoverColor: Colors.white, hoverColor: Colors.white,
), ),
scaffoldBackgroundColor: Colors.indigo.shade900, scaffoldBackgroundColor: Config.get().splashBackgroundColor,
textTheme: TextTheme( textTheme: TextTheme(
bodyText2: TextStyle(color: Colors.white), bodyText2: TextStyle(color: Colors.white),
button: TextStyle(color: Colors.white), button: TextStyle(color: Colors.white),
@ -50,18 +52,26 @@ class LoginScaffold extends StatelessWidget {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Spacer(flex: 3), Spacer(flex: 3),
Text("Comunic", style: TextStyle(fontSize: 50)), Text("Comunic",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 50)),
Spacer(flex: 1), Spacer(flex: 1),
Text(tr("Free social network that respect your privacy")), Text(
Spacer(flex: 1), tr("Free social network that respect your privacy"),
Padding( textAlign: TextAlign.center,
padding: const EdgeInsets.all(8.0),
child: Material(
child: child,
color: Colors.indigo.shade500,
),
), ),
Spacer(flex: 5), Spacer(flex: 3),
child != null
? Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
child: child,
color: Colors.indigo.shade500,
),
)
: Container(),
noStyleChild ?? Container(),
Spacer(flex: 3),
], ],
), ),
), ),