2021-04-17 08:59:06 +00:00
|
|
|
import 'package:comunic/models/config.dart';
|
2021-04-17 08:10:31 +00:00
|
|
|
import 'package:comunic/ui/widgets/create_account_widget.dart';
|
2019-11-02 17:09:34 +00:00
|
|
|
import 'package:comunic/utils/intl_utils.dart';
|
2019-11-02 17:54:30 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2019-11-02 17:09:34 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Create account route
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
|
|
|
class CreateAccountRoute extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2021-04-17 08:59:06 +00:00
|
|
|
backgroundColor: Config.get().splashBackgroundColor,
|
2019-11-02 17:09:34 +00:00
|
|
|
appBar: AppBar(
|
2021-04-17 08:59:06 +00:00
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
elevation: 0,
|
2019-11-02 17:09:34 +00:00
|
|
|
title: Text(tr("Create an account")),
|
|
|
|
),
|
2021-04-17 08:59:06 +00:00
|
|
|
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(),
|
|
|
|
),
|
2019-11-02 17:09:34 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CreateAccountRouteBody extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
__CreateAccountRouteBodyState createState() =>
|
|
|
|
__CreateAccountRouteBodyState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> {
|
|
|
|
@override
|
2021-04-17 08:10:31 +00:00
|
|
|
Widget build(BuildContext context) =>
|
|
|
|
CreateAccountWidget(onCreated: _accountCreated);
|
2019-11-02 17:54:30 +00:00
|
|
|
|
|
|
|
void _accountCreated() async {
|
|
|
|
await showCupertinoDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (c) => CupertinoAlertDialog(
|
|
|
|
title: Text(tr("Account created")),
|
|
|
|
content: Text(tr(
|
|
|
|
"Your account has been successfully created. You can now login to start to use it.")),
|
|
|
|
actions: <Widget>[
|
|
|
|
CupertinoButton(
|
|
|
|
child: Text(tr("Login")), onPressed: () => Navigator.of(c).pop())
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
2019-11-02 17:16:16 +00:00
|
|
|
}
|
2019-11-02 17:09:34 +00:00
|
|
|
}
|