refactor: Simplify login UX

This commit is contained in:
krille-chan 2024-08-17 12:16:55 +02:00
commit dec588d0c0
No known key found for this signature in database
15 changed files with 172 additions and 486 deletions

View file

@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/widgets/layouts/login_scaffold.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'login.dart';
@ -24,11 +23,6 @@ class LoginView extends StatelessWidget {
final title = L10n.of(context)!.logInTo(homeserver);
final titleParts = title.split(homeserver);
final textFieldFillColor = FluffyThemes.isColumnMode(context)
? theme.colorScheme.surface
// ignore: deprecated_member_use
: theme.colorScheme.surfaceVariant;
return LoginScaffold(
enforceMobileMode: Matrix.of(context).client.isLogged(),
appBar: AppBar(
@ -73,8 +67,8 @@ class LoginView extends StatelessWidget {
prefixIcon: const Icon(Icons.account_box_outlined),
errorText: controller.usernameError,
errorStyle: const TextStyle(color: Colors.orange),
fillColor: textFieldFillColor,
hintText: L10n.of(context)!.emailOrUsername,
hintText: '@username:localpart',
labelText: L10n.of(context)!.emailOrUsername,
),
),
),
@ -94,7 +88,6 @@ class LoginView extends StatelessWidget {
prefixIcon: const Icon(Icons.lock_outlined),
errorText: controller.passwordError,
errorStyle: const TextStyle(color: Colors.orange),
fillColor: textFieldFillColor,
suffixIcon: IconButton(
onPressed: controller.toggleShowPassword,
icon: Icon(
@ -104,21 +97,21 @@ class LoginView extends StatelessWidget {
color: Colors.black,
),
),
hintText: L10n.of(context)!.password,
hintText: '******',
labelText: L10n.of(context)!.password,
),
),
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: ElevatedButton.icon(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: theme.colorScheme.primary,
foregroundColor: theme.colorScheme.onPrimary,
),
onPressed: controller.loading ? null : controller.login,
icon: const Icon(Icons.login_outlined),
label: controller.loading
child: controller.loading
? const LinearProgressIndicator()
: Text(L10n.of(context)!.login),
),
@ -126,15 +119,14 @@ class LoginView extends StatelessWidget {
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: TextButton.icon(
child: TextButton(
onPressed: controller.loading
? () {}
: controller.passwordForgotten,
style: TextButton.styleFrom(
foregroundColor: theme.colorScheme.error,
),
icon: const Icon(Icons.safety_check_outlined),
label: Text(L10n.of(context)!.passwordForgotten),
child: Text(L10n.of(context)!.passwordForgotten),
),
),
const SizedBox(height: 16),