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';
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
2021-09-10 10:30:54 +02:00
|
|
|
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).signUp),
|
|
|
|
),
|
|
|
|
body: ListView(
|
|
|
|
children: [
|
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).pleaseChooseAUsername),
|
|
|
|
subtitle: Text(L10n.of(context).newUsernameDescription),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: TextField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
autofocus: true,
|
|
|
|
controller: controller.usernameController,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.username],
|
|
|
|
decoration: InputDecoration(
|
2021-10-14 18:09:30 +02:00
|
|
|
prefixIcon: const Icon(Icons.account_box_outlined),
|
2021-09-10 10:30:54 +02:00
|
|
|
hintText: L10n.of(context).username,
|
|
|
|
errorText: controller.usernameError,
|
|
|
|
labelText: L10n.of(context).username,
|
|
|
|
prefixText: '@',
|
|
|
|
suffixText:
|
2021-09-19 13:48:23 +02:00
|
|
|
':${Matrix.of(context).getLoginClient().homeserver.host}'),
|
2021-09-10 10:30:54 +02:00
|
|
|
),
|
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
const Divider(),
|
2021-09-10 10:30:54 +02:00
|
|
|
ListTile(
|
|
|
|
title: Text(L10n.of(context).chooseAStrongPassword),
|
|
|
|
subtitle: Text(L10n.of(context).newPasswordDescription),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: TextField(
|
|
|
|
readOnly: controller.loading,
|
|
|
|
autocorrect: false,
|
|
|
|
autofillHints:
|
|
|
|
controller.loading ? null : [AutofillHints.password],
|
|
|
|
controller: controller.passwordController,
|
|
|
|
obscureText: !controller.showPassword,
|
|
|
|
onSubmitted: controller.signup,
|
|
|
|
decoration: InputDecoration(
|
2021-10-14 18:09:30 +02:00
|
|
|
prefixIcon: const Icon(Icons.lock_outlined),
|
2021-09-10 10:30:54 +02:00
|
|
|
hintText: '****',
|
|
|
|
errorText: controller.passwordError,
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
const Divider(),
|
|
|
|
const SizedBox(height: 12),
|
2021-09-10 10:30:54 +02:00
|
|
|
Hero(
|
|
|
|
tag: 'loginButton',
|
|
|
|
child: Padding(
|
2021-10-14 18:09:30 +02:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
2021-09-10 10:30:54 +02:00
|
|
|
child: ElevatedButton(
|
|
|
|
onPressed: controller.loading ? null : controller.signup,
|
|
|
|
child: controller.loading
|
2021-10-14 18:09:30 +02:00
|
|
|
? const LinearProgressIndicator()
|
2021-09-10 10:30:54 +02:00
|
|
|
: Text(L10n.of(context).signUp),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|