2021-09-10 10:30:54 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
2021-09-10 10:30:54 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
2022-04-15 11:42:59 +02:00
|
|
|
import 'package:fluffychat/widgets/layouts/login_scaffold.dart';
|
2021-11-09 21:32:16 +01:00
|
|
|
import 'signup.dart';
|
2021-09-10 10:30:54 +02:00
|
|
|
|
|
|
|
class SignupPageView extends StatelessWidget {
|
|
|
|
final SignupPageController controller;
|
2022-01-29 12:35:03 +01:00
|
|
|
const SignupPageView(this.controller, {Key? key}) : super(key: key);
|
2021-09-10 10:30:54 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-04-15 11:42:59 +02:00
|
|
|
return LoginScaffold(
|
|
|
|
appBar: AppBar(
|
2022-10-16 12:37:38 +02:00
|
|
|
leading: controller.loading ? null : const BackButton(),
|
2022-04-15 11:42:59 +02:00
|
|
|
automaticallyImplyLeading: !controller.loading,
|
2022-10-16 12:37:38 +02:00
|
|
|
title: Text(L10n.of(context)!.signUp),
|
2022-04-15 11:42:59 +02:00
|
|
|
),
|
|
|
|
body: Form(
|
|
|
|
key: controller.formKey,
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
|
|
|
Padding(
|
2022-08-05 21:04:37 +02:00
|
|
|
padding: const EdgeInsets.all(12.0),
|
2022-04-15 11:42:59 +02:00
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
2022-05-28 10:01:03 +02:00
|
|
|
onChanged: controller.onPasswordType,
|
2022-04-15 11:42:59 +02:00
|
|
|
autofillHints:
|
2022-05-28 10:01:03 +02:00
|
|
|
controller.loading ? null : [AutofillHints.newPassword],
|
2022-04-15 11:42:59 +02:00
|
|
|
controller: controller.passwordController,
|
|
|
|
obscureText: !controller.showPassword,
|
|
|
|
validator: controller.password1TextFieldValidator,
|
2022-07-07 18:50:13 +02:00
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.vpn_key_outlined),
|
2022-04-15 11:42:59 +02:00
|
|
|
suffixIcon: IconButton(
|
|
|
|
tooltip: L10n.of(context)!.showPassword,
|
2022-04-24 07:57:08 +02:00
|
|
|
icon: Icon(
|
|
|
|
controller.showPassword
|
|
|
|
? Icons.visibility_off_outlined
|
|
|
|
: Icons.visibility_outlined,
|
|
|
|
color: Colors.black,
|
|
|
|
),
|
2022-04-15 11:42:59 +02:00
|
|
|
onPressed: controller.toggleShowPassword,
|
2021-10-30 14:06:10 +02:00
|
|
|
),
|
2022-07-07 18:50:13 +02:00
|
|
|
errorStyle: const TextStyle(color: Colors.orange),
|
2022-04-15 11:42:59 +02:00
|
|
|
hintText: L10n.of(context)!.chooseAStrongPassword,
|
2021-10-30 14:06:10 +02:00
|
|
|
),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
2022-04-15 11:42:59 +02:00
|
|
|
),
|
2022-05-28 10:01:03 +02:00
|
|
|
if (controller.displaySecondPasswordField)
|
|
|
|
Padding(
|
2022-08-05 21:04:37 +02:00
|
|
|
padding: const EdgeInsets.all(12.0),
|
2022-05-28 10:01:03 +02:00
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.newPassword],
|
|
|
|
controller: controller.password2Controller,
|
|
|
|
obscureText: !controller.showPassword,
|
|
|
|
validator: controller.password2TextFieldValidator,
|
2022-07-07 18:50:13 +02:00
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.repeat_outlined),
|
2022-05-28 10:01:03 +02:00
|
|
|
hintText: L10n.of(context)!.repeatPassword,
|
2022-07-07 18:50:13 +02:00
|
|
|
errorStyle: const TextStyle(color: Colors.orange),
|
2022-05-28 10:01:03 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-04-15 11:42:59 +02:00
|
|
|
Padding(
|
2022-08-05 21:04:37 +02:00
|
|
|
padding: const EdgeInsets.all(12.0),
|
2022-04-15 11:42:59 +02:00
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
controller: controller.emailController,
|
|
|
|
keyboardType: TextInputType.emailAddress,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.username],
|
|
|
|
validator: controller.emailTextFieldValidator,
|
2022-07-07 18:50:13 +02:00
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.mail_outlined),
|
2022-05-21 12:08:52 +02:00
|
|
|
hintText: L10n.of(context)!.enterAnEmailAddress,
|
|
|
|
errorText: controller.error,
|
2022-10-16 12:37:38 +02:00
|
|
|
errorMaxLines: 4,
|
2022-07-07 18:50:13 +02:00
|
|
|
errorStyle: TextStyle(
|
|
|
|
color: controller.emailController.text.isEmpty
|
|
|
|
? Colors.orangeAccent
|
|
|
|
: Colors.orange,
|
|
|
|
),
|
2022-05-21 12:08:52 +02:00
|
|
|
),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
2022-04-15 11:42:59 +02:00
|
|
|
),
|
|
|
|
Hero(
|
|
|
|
tag: 'loginButton',
|
|
|
|
child: Padding(
|
2022-08-05 21:04:37 +02:00
|
|
|
padding: const EdgeInsets.all(12),
|
2022-12-29 20:38:13 +01:00
|
|
|
child: ElevatedButton.icon(
|
|
|
|
icon: const Icon(Icons.person_add_outlined),
|
2022-10-16 12:37:38 +02:00
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
2022-04-15 11:42:59 +02:00
|
|
|
onPressed: controller.loading ? () {} : controller.signup,
|
2022-12-29 20:38:13 +01:00
|
|
|
label: controller.loading
|
2022-04-15 11:42:59 +02:00
|
|
|
? const LinearProgressIndicator()
|
|
|
|
: Text(L10n.of(context)!.signUp),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
|
|
|
),
|
2022-04-15 11:42:59 +02:00
|
|
|
),
|
|
|
|
],
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|