fluffychat/lib/pages/views/sign_up_ui.dart

118 lines
4.1 KiB
Dart
Raw Normal View History

2021-01-16 12:46:38 +01:00
import 'package:adaptive_page_layout/adaptive_page_layout.dart';
2021-05-22 08:57:49 +02:00
import 'package:fluffychat/pages/sign_up.dart';
2021-05-22 08:53:52 +02:00
import 'package:fluffychat/widgets/fluffy_banner.dart';
2020-10-04 17:01:54 +02:00
2021-05-22 08:53:52 +02:00
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/layouts/one_page_card.dart';
2020-01-09 22:52:27 +01:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-01-09 22:52:27 +01:00
class SignUpUI extends StatelessWidget {
2021-04-12 17:31:53 +02:00
final SignUpController controller;
2020-01-09 22:52:27 +01:00
const SignUpUI(this.controller, {Key key}) : super(key: key);
2020-01-09 22:52:27 +01:00
@override
Widget build(BuildContext context) {
2021-04-09 14:56:23 +02:00
return OnePageCard(
child: Scaffold(
appBar: AppBar(
elevation: 0,
2021-04-12 17:31:53 +02:00
leading: controller.loading ? Container() : BackButton(),
2021-04-09 14:56:23 +02:00
title: Text(
Matrix.of(context)
.client
.homeserver
.toString()
.replaceFirst('https://', ''),
),
2020-01-09 22:52:27 +01:00
),
2021-04-09 14:56:23 +02:00
body: ListView(children: <Widget>[
Hero(
tag: 'loginBanner',
child: FluffyBanner(),
),
SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: TextField(
2021-04-12 17:31:53 +02:00
readOnly: controller.loading,
2021-04-09 14:56:23 +02:00
autocorrect: false,
2021-04-12 17:31:53 +02:00
controller: controller.usernameController,
onSubmitted: controller.signUpAction,
autofillHints:
controller.loading ? null : [AutofillHints.newUsername],
2021-04-09 14:56:23 +02:00
decoration: InputDecoration(
prefixIcon: Icon(Icons.account_circle_outlined),
hintText: L10n.of(context).username,
2021-04-12 17:31:53 +02:00
errorText: controller.usernameError,
2021-04-09 14:56:23 +02:00
labelText: L10n.of(context).chooseAUsername,
2021-01-24 17:26:59 +01:00
),
),
2021-04-09 14:56:23 +02:00
),
SizedBox(height: 8),
ListTile(
leading: CircleAvatar(
2021-04-12 17:31:53 +02:00
backgroundImage: controller.avatar == null
? null
: MemoryImage(controller.avatar.bytes),
backgroundColor: controller.avatar == null
2021-04-09 14:56:23 +02:00
? Theme.of(context).brightness == Brightness.dark
? Color(0xff121212)
: Colors.white
: Theme.of(context).secondaryHeaderColor,
2021-04-12 17:31:53 +02:00
child: controller.avatar == null
2021-04-09 14:56:23 +02:00
? Icon(Icons.camera_alt_outlined,
color: Theme.of(context).primaryColor)
: null,
2020-01-09 22:52:27 +01:00
),
2021-04-12 17:31:53 +02:00
trailing: controller.avatar == null
2021-04-09 14:56:23 +02:00
? null
: Icon(
Icons.close,
color: Colors.red,
),
2021-04-12 17:31:53 +02:00
title: Text(controller.avatar == null
2021-04-09 14:56:23 +02:00
? L10n.of(context).setAProfilePicture
: L10n.of(context).discardPicture),
2021-04-12 17:31:53 +02:00
onTap: controller.avatar == null
? controller.setAvatarAction
: controller.resetAvatarAction,
2021-04-09 14:56:23 +02:00
),
SizedBox(height: 16),
Hero(
tag: 'loginButton',
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12),
child: ElevatedButton(
2021-04-12 17:31:53 +02:00
onPressed: controller.loading ? null : controller.signUpAction,
child: controller.loading
2021-04-09 14:56:23 +02:00
? LinearProgressIndicator()
: Text(
L10n.of(context).signUp.toUpperCase(),
style: TextStyle(color: Colors.white, fontSize: 16),
),
2020-01-09 22:52:27 +01:00
),
),
2021-04-09 14:56:23 +02:00
),
Center(
child: TextButton(
onPressed: () =>
AdaptivePageLayout.of(context).pushNamed('/login'),
child: Text(
L10n.of(context).alreadyHaveAnAccount,
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.blue,
fontSize: 16,
2020-01-09 22:52:27 +01:00
),
),
),
2021-04-09 14:56:23 +02:00
),
]),
),
2020-01-09 22:52:27 +01:00
);
}
}