From e5c29eedfe8ff47d844d09098c30b0a0f3bc58f3 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 2 Jun 2022 09:54:38 +0200 Subject: [PATCH] chore: Make error text on email orange and set displayname --- lib/config/themes.dart | 5 +++-- lib/pages/sign_up/signup.dart | 12 +++++++++++- lib/pages/sign_up/signup_view.dart | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/config/themes.dart b/lib/config/themes.dart index ac20d99e..9f4ca2c3 100644 --- a/lib/config/themes.dart +++ b/lib/config/themes.dart @@ -20,6 +20,7 @@ abstract class FluffyThemes { String? hintText, Widget? suffixIcon, Widget? prefixIcon, + Color? errorColor, }) => InputDecoration( border: OutlineInputBorder( @@ -36,12 +37,12 @@ abstract class FluffyThemes { errorText: errorText, errorMaxLines: 4, errorStyle: TextStyle( - color: Colors.red.shade200, + color: errorColor ?? Colors.redAccent.shade200, shadows: const [ Shadow( color: Colors.black, offset: Offset(0, 0), - blurRadius: 5, + blurRadius: 10, ), ], ), diff --git a/lib/pages/sign_up/signup.dart b/lib/pages/sign_up/signup.dart index c6db6815..e4a4d773 100644 --- a/lib/pages/sign_up/signup.dart +++ b/lib/pages/sign_up/signup.dart @@ -97,14 +97,24 @@ class SignupPageController extends State { ); } + final displayname = Matrix.of(context).loginUsername!; + final localPart = displayname.toLowerCase().replaceAll(' ', '_'); + await client.uiaRequestBackground( (auth) => client.register( - username: Matrix.of(context).loginUsername!, + username: localPart, password: passwordController.text, initialDeviceDisplayName: PlatformInfos.clientName, auth: auth, ), ); + // Set displayname + if (displayname != localPart) { + await client.setDisplayName( + client.userID!, + displayname, + ); + } } catch (e) { error = (e).toLocalizedString(context); } finally { diff --git a/lib/pages/sign_up/signup_view.dart b/lib/pages/sign_up/signup_view.dart index 93de63ec..d878c6a5 100644 --- a/lib/pages/sign_up/signup_view.dart +++ b/lib/pages/sign_up/signup_view.dart @@ -94,6 +94,9 @@ class SignupPageView extends StatelessWidget { ), hintText: L10n.of(context)!.enterAnEmailAddress, errorText: controller.error, + errorColor: controller.emailController.text.isEmpty + ? Colors.orangeAccent + : null, ), ), ),