1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 06:53:23 +00:00
comunicmobile/lib/ui/routes/create_account_route.dart

93 lines
3.2 KiB
Dart

import 'package:comunic/models/config.dart';
import 'package:comunic/ui/widgets/create_account_widget.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Create account route
///
/// @author Pierre HUBERT
class CreateAccountRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Config.get().splashBackgroundColor,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
title: Text(tr("Create an account")),
),
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(),
),
);
}
}
class _CreateAccountRouteBody extends StatefulWidget {
@override
__CreateAccountRouteBodyState createState() =>
__CreateAccountRouteBodyState();
}
class __CreateAccountRouteBodyState extends State<_CreateAccountRouteBody> {
@override
Widget build(BuildContext context) =>
CreateAccountWidget(onCreated: _accountCreated);
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();
}
}