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';
|
|
|
|
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:fluffychat/widgets/layouts/one_page_card.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) {
|
|
|
|
return OnePageCard(
|
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
2022-01-29 12:35:03 +01:00
|
|
|
title: Text(L10n.of(context)!.signUp),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
2021-10-30 14:06:10 +02:00
|
|
|
body: Form(
|
|
|
|
key: controller.formKey,
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
controller: controller.usernameController,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.username],
|
|
|
|
validator: controller.usernameTextFieldValidator,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.account_circle_outlined),
|
2022-01-29 12:35:03 +01:00
|
|
|
hintText: L10n.of(context)!.username,
|
|
|
|
labelText: L10n.of(context)!.username,
|
2021-10-30 14:06:10 +02:00
|
|
|
prefixText: '@',
|
|
|
|
prefixStyle: const TextStyle(fontWeight: FontWeight.bold),
|
|
|
|
suffixStyle: const TextStyle(fontWeight: FontWeight.w200),
|
|
|
|
suffixText: ':${controller.domain}'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.password],
|
|
|
|
controller: controller.passwordController,
|
|
|
|
obscureText: !controller.showPassword,
|
|
|
|
validator: controller.password1TextFieldValidator,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.vpn_key_outlined),
|
|
|
|
hintText: '****',
|
|
|
|
suffixIcon: IconButton(
|
2022-01-29 12:35:03 +01:00
|
|
|
tooltip: L10n.of(context)!.showPassword,
|
2021-10-30 14:06:10 +02:00
|
|
|
icon: Icon(controller.showPassword
|
|
|
|
? Icons.visibility_off_outlined
|
|
|
|
: Icons.visibility_outlined),
|
|
|
|
onPressed: controller.toggleShowPassword,
|
|
|
|
),
|
2022-01-29 12:35:03 +01:00
|
|
|
labelText: L10n.of(context)!.password,
|
2021-10-30 14:06:10 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.password],
|
|
|
|
controller: controller.passwordController2,
|
|
|
|
obscureText: true,
|
|
|
|
validator: controller.password2TextFieldValidator,
|
2021-11-04 16:13:02 +01:00
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.repeat_outlined),
|
2021-10-30 14:06:10 +02:00
|
|
|
hintText: '****',
|
2022-01-29 12:35:03 +01:00
|
|
|
labelText: L10n.of(context)!.repeatPassword,
|
2021-10-30 14:06:10 +02:00
|
|
|
),
|
|
|
|
),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
2021-10-30 14:06:10 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: TextFormField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
controller: controller.emailController,
|
|
|
|
keyboardType: TextInputType.emailAddress,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.username],
|
|
|
|
validator: controller.emailTextFieldValidator,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
prefixIcon: const Icon(Icons.mail_outlined),
|
2022-01-29 12:35:03 +01:00
|
|
|
labelText: L10n.of(context)!.addEmail,
|
2021-10-30 14:06:10 +02:00
|
|
|
hintText: 'email@example.abc',
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-10-30 14:06:10 +02:00
|
|
|
const Divider(),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
if (controller.error != null) ...[
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
|
|
child: Text(
|
2022-01-29 12:35:03 +01:00
|
|
|
controller.error!,
|
2021-10-30 14:06:10 +02:00
|
|
|
style: const TextStyle(color: Colors.red),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
const Divider(),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
],
|
|
|
|
Hero(
|
|
|
|
tag: 'loginButton',
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
|
|
child: ElevatedButton(
|
|
|
|
onPressed: controller.loading ? null : controller.signup,
|
|
|
|
child: controller.loading
|
|
|
|
? const LinearProgressIndicator()
|
2022-01-29 12:35:03 +01:00
|
|
|
: Text(L10n.of(context)!.signUp),
|
2021-10-30 14:06:10 +02:00
|
|
|
),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
|
|
|
),
|
2021-10-30 14:06:10 +02:00
|
|
|
],
|
|
|
|
),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|