fluffychat/lib/pages/sign_up/signup_view.dart
TheOneWithTheBraid 4572e800a7 chore: implement new onboarding flow
- simplify homeserver selection
- allow to change avatar
- use registration as main action
- friendly animations

Closes: !712

Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
2022-04-05 18:49:06 +02:00

120 lines
4.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:fluffychat/widgets/layouts/one_page_card.dart';
import 'signup.dart';
class SignupPageView extends StatelessWidget {
final SignupPageController controller;
const SignupPageView(this.controller, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return OnePageCard(
child: Scaffold(
appBar: AppBar(
title: Text(L10n.of(context)!.signUpAs(controller.username!)),
),
body: Form(
key: controller.formKey,
child: ListView(
children: [
ListTile(title: Text(L10n.of(context)!.inventPassword)),
Padding(
padding: const EdgeInsets.all(12.0),
child: TextFormField(
readOnly: controller.loading,
autocorrect: false,
autofocus: true,
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(
tooltip: L10n.of(context)!.showPassword,
icon: Icon(controller.showPassword
? Icons.visibility_off_outlined
: Icons.visibility_outlined),
onPressed: controller.toggleShowPassword,
),
labelText: L10n.of(context)!.password,
),
),
),
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,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.repeat_outlined),
hintText: '****',
labelText: L10n.of(context)!.repeatPassword,
),
),
),
const Divider(),
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),
labelText: L10n.of(context)!.addEmail,
hintText: L10n.of(context)!.sampleEmail,
helperText: L10n.of(context)!.emailHelper,
),
),
),
const Divider(),
const SizedBox(height: 12),
if (controller.error != null) ...[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
controller.error!,
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()
: Text(L10n.of(context)!.signUp),
),
),
),
],
),
),
),
);
}
}