fluffychat/lib/pages/sign_up/signup_view.dart

92 lines
3.4 KiB
Dart
Raw Normal View History

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/config/themes.dart';
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(
automaticallyImplyLeading: !controller.loading,
backgroundColor: Colors.transparent,
iconTheme: const IconThemeData(color: Colors.white),
elevation: 0,
title: Text(
L10n.of(context)!.signUp,
style: const TextStyle(color: Colors.white),
2021-09-10 10:30:54 +02:00
),
2022-04-15 11:42:59 +02:00
),
body: Form(
key: controller.formKey,
child: ListView(
children: [
Padding(
padding: const EdgeInsets.all(16.0),
child: TextFormField(
readOnly: controller.loading,
autocorrect: false,
autofillHints:
controller.loading ? null : [AutofillHints.password],
controller: controller.passwordController,
obscureText: !controller.showPassword,
validator: controller.password1TextFieldValidator,
decoration: FluffyThemes.loginTextFieldDecoration(
prefixIcon: const Icon(Icons.vpn_key_outlined),
suffixIcon: IconButton(
tooltip: L10n.of(context)!.showPassword,
icon: Icon(controller.showPassword
? Icons.visibility_off_outlined
: Icons.visibility_outlined),
onPressed: controller.toggleShowPassword,
2021-10-30 14:06:10 +02:00
),
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
),
Padding(
padding: const EdgeInsets.all(16.0),
child: TextFormField(
readOnly: controller.loading,
autocorrect: false,
controller: controller.emailController,
keyboardType: TextInputType.emailAddress,
autofillHints:
controller.loading ? null : [AutofillHints.username],
validator: controller.emailTextFieldValidator,
decoration: FluffyThemes.loginTextFieldDecoration(
2021-10-30 14:06:10 +02:00
prefixIcon: const Icon(Icons.mail_outlined),
2022-04-15 11:42:59 +02:00
hintText: L10n.of(context)!.enterAnEmailAddress,
errorText: controller.error),
2021-09-10 10:30:54 +02:00
),
2022-04-15 11:42:59 +02:00
),
Hero(
tag: 'loginButton',
child: Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
onPressed: controller.loading ? () {} : controller.signup,
style: ElevatedButton.styleFrom(
primary: Colors.white.withAlpha(200),
onPrimary: Colors.black,
shadowColor: Colors.white,
2021-10-30 14:06:10 +02:00
),
2022-04-15 11:42:59 +02:00
child: controller.loading
? 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
),
),
);
}
}