diff --git a/commet/lib/ui/pages/login/login_page.dart b/commet/lib/ui/pages/login/login_page.dart index 5c222cc45..2f81398f6 100644 --- a/commet/lib/ui/pages/login/login_page.dart +++ b/commet/lib/ui/pages/login/login_page.dart @@ -9,6 +9,7 @@ import 'package:commet/utils/debounce.dart'; import 'package:commet/utils/rng.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:commet/ui/navigation/adaptive_dialog.dart'; class LoginPage extends StatefulWidget { const LoginPage({super.key, this.onSuccess, this.canNavigateBack = false}); @@ -19,15 +20,16 @@ class LoginPage extends StatefulWidget { State createState() => LoginPageState(); } + class LoginPageState extends State { String get messageLoginFailed => Intl.message("Login Failed...", name: "messageLoginFailed", desc: "Generic text to show that an attempted login has failed"); - String get messageLoginError => Intl.message("An error occured", - name: "messageLoginError", + String get messageLoginIncorrect => Intl.message("Incorrect username or password.", + name: "messageLoginIncorrect", desc: - "A generic error message to convey that an error occured when attempting to login"); + "A generic error message to convey that an error occured when attempting to login, usually an invalid username or password."); String get messageAlreadyLoggedIn => Intl.message( "You have already logged in to this account", @@ -109,20 +111,21 @@ class LoginPageState extends State { String? message = switch (result) { LoginResult.success => null, LoginResult.failed => messageLoginFailed, - LoginResult.error => messageLoginError, + LoginResult.error => messageLoginIncorrect, LoginResult.alreadyLoggedIn => messageAlreadyLoggedIn, LoginResult.cancelled => "Login cancelled" }; if (message != null) { if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(message), - ), - ); + AdaptiveDialog.show( + context, + title: "Login failed", + builder: (_) => Text("Incorrect login. Ensure that you have entered your username and password correctly, and that you have entered the homeserver address correctly.") + ); + }; } - } + if (result == LoginResult.success) { clientManager?.addClient(loginClient!);