diff --git a/codecov b/codecov new file mode 100755 index 000000000..b4f90ca58 Binary files /dev/null and b/codecov differ diff --git a/packages/uni_app/lib/model/entities/login_exceptions.dart b/packages/uni_app/lib/model/entities/login_exceptions.dart deleted file mode 100644 index d701801d4..000000000 --- a/packages/uni_app/lib/model/entities/login_exceptions.dart +++ /dev/null @@ -1,11 +0,0 @@ -class ExpiredCredentialsException implements Exception { - ExpiredCredentialsException(); -} - -class InternetStatusException implements Exception { - InternetStatusException(); -} - -class WrongCredentialsException implements Exception { - WrongCredentialsException(); -} diff --git a/packages/uni_app/lib/session/exception.dart b/packages/uni_app/lib/session/exception.dart index 712ceae75..e1fb9232f 100644 --- a/packages/uni_app/lib/session/exception.dart +++ b/packages/uni_app/lib/session/exception.dart @@ -1,4 +1,5 @@ enum AuthenticationExceptionType { + internetError, wrongCredentials, expiredCredentials, other, diff --git a/packages/uni_app/lib/session/flows/credentials/request.dart b/packages/uni_app/lib/session/flows/credentials/request.dart index 727935b29..cc658bd95 100644 --- a/packages/uni_app/lib/session/flows/credentials/request.dart +++ b/packages/uni_app/lib/session/flows/credentials/request.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'package:http/http.dart' as http; import 'package:uni/controller/fetchers/faculties_fetcher.dart'; import 'package:uni/session/exception.dart'; @@ -35,11 +36,20 @@ class CredentialsSessionRequest extends SessionRequest { 'Failed to authenticate user', AuthenticationExceptionType.expiredCredentials, ); - } else { + } else if (failureReason == LoginFailureReason.internetError) { + throw const AuthenticationException( + 'Failed to authenticate user', + AuthenticationExceptionType.internetError, + ); + } else if (failureReason == LoginFailureReason.wrongCredentials) { throw const AuthenticationException( 'Failed to authenticate user', AuthenticationExceptionType.wrongCredentials, ); + } else { + throw const AuthenticationException( + 'Failed to authenticate user', + ); } } diff --git a/packages/uni_app/lib/sigarra/endpoints/html/authentication/login/response.dart b/packages/uni_app/lib/sigarra/endpoints/html/authentication/login/response.dart index 4399da48f..dc8a26db1 100644 --- a/packages/uni_app/lib/sigarra/endpoints/html/authentication/login/response.dart +++ b/packages/uni_app/lib/sigarra/endpoints/html/authentication/login/response.dart @@ -8,6 +8,7 @@ class LoginResponse extends SigarraResponse { enum LoginFailureReason { serverError, + internetError, wrongCredentials, expiredCredentials, blockedAccount, diff --git a/packages/uni_app/lib/view/common_widgets/pages_layouts/general/general.dart b/packages/uni_app/lib/view/common_widgets/pages_layouts/general/general.dart index e91bffc7b..a95227356 100644 --- a/packages/uni_app/lib/view/common_widgets/pages_layouts/general/general.dart +++ b/packages/uni_app/lib/view/common_widgets/pages_layouts/general/general.dart @@ -10,7 +10,6 @@ import 'package:uni/model/providers/startup/profile_provider.dart'; import 'package:uni/model/providers/startup/session_provider.dart'; import 'package:uni/view/common_widgets/expanded_image_label.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/widgets/bottom_navigation_bar.dart'; -import 'package:uni/view/common_widgets/pages_layouts/general/widgets/profile_button.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/widgets/refresh_state.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/widgets/top_navigation_bar.dart'; @@ -136,7 +135,6 @@ abstract class GeneralPageViewState extends State { AppTopNavbar? getTopNavbar(BuildContext context) { return AppTopNavbar( title: this.getTitle(), - rightButton: const ProfileButton(), ); } } diff --git a/packages/uni_app/lib/view/common_widgets/pages_layouts/general/widgets/top_navigation_bar.dart b/packages/uni_app/lib/view/common_widgets/pages_layouts/general/widgets/top_navigation_bar.dart index a22633b05..fcedf7676 100644 --- a/packages/uni_app/lib/view/common_widgets/pages_layouts/general/widgets/top_navigation_bar.dart +++ b/packages/uni_app/lib/view/common_widgets/pages_layouts/general/widgets/top_navigation_bar.dart @@ -16,37 +16,53 @@ class AppTopNavbar extends StatelessWidget implements PreferredSizeWidget { final Widget? leftButton; Widget _createTopWidgets(BuildContext context) { - return Padding( - padding: EdgeInsets.fromLTRB(leftButton == null ? 20 : 12, 0, 20, 0), - child: Row( - children: [ - if (leftButton != null) - Padding( - padding: const EdgeInsets.only(right: 8), - child: leftButton, - ), - Expanded( - child: PageTitle( - name: title ?? '', - pad: false, - center: false, - ), + final shouldShowDivider = title == 'Faculty' || title == 'Restaurants'; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.fromLTRB(leftButton == null ? 20 : 12, 0, 20, 0), + child: Row( + children: [ + if (leftButton != null) + Padding( + padding: const EdgeInsets.only(right: 8), + child: leftButton, + ), + Expanded( + child: PageTitle( + name: title ?? '', + pad: false, + center: false, + ), + ), + if (rightButton != null) + Padding( + padding: const EdgeInsets.only(left: 8), + child: rightButton, + ), + ], ), - if (rightButton != null) - Padding( - padding: const EdgeInsets.only(left: 8), - child: rightButton, + ), + if (shouldShowDivider) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14), + child: Container( + height: 1, + color: + const Color(0xFF7F7F7F).withOpacity(0.5), // Adjusted opacity ), - ], - ), + ), + ], ); } @override - Size get preferredSize => const Size.fromHeight(kToolbarHeight); + Size get preferredSize => const Size.fromHeight(kToolbarHeight + 10); @override - AppBar build(BuildContext context) { + Widget build(BuildContext context) { return AppBar( automaticallyImplyLeading: false, elevation: 0, diff --git a/packages/uni_app/lib/view/home/home.dart b/packages/uni_app/lib/view/home/home.dart index 8b6177a6e..a5604cc22 100644 --- a/packages/uni_app/lib/view/home/home.dart +++ b/packages/uni_app/lib/view/home/home.dart @@ -4,7 +4,6 @@ import 'package:uni/generated/l10n.dart'; import 'package:uni/utils/favorite_widget_type.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; -import 'package:uni/view/common_widgets/pages_layouts/general/widgets/profile_button.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/widgets/top_navigation_bar.dart'; import 'package:uni/view/home/widgets/main_cards_list.dart'; import 'package:uni/view/home/widgets/tracking_banner.dart'; @@ -132,7 +131,6 @@ class HomePageViewState extends GeneralPageViewState { padding: EdgeInsets.symmetric(horizontal: 8), child: UniIcon(), ), - rightButton: ProfileButton(), ); } } diff --git a/packages/uni_app/lib/view/login/login.dart b/packages/uni_app/lib/view/login/login.dart index cab5cfcb2..9c1cbb45a 100644 --- a/packages/uni_app/lib/view/login/login.dart +++ b/packages/uni_app/lib/view/login/login.dart @@ -9,9 +9,9 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:uni/app_links/uni_app_links.dart'; import 'package:uni/controller/networking/url_launcher.dart'; import 'package:uni/generated/l10n.dart'; -import 'package:uni/model/entities/login_exceptions.dart'; import 'package:uni/model/providers/startup/session_provider.dart'; import 'package:uni/model/providers/state_providers.dart'; +import 'package:uni/session/exception.dart'; import 'package:uni/session/flows/credentials/initiator.dart'; import 'package:uni/session/flows/federated/initiator.dart'; import 'package:uni/utils/constants.dart'; @@ -99,36 +99,51 @@ class LoginPageViewState extends State _loggingIn = false; }); } - } catch (err, st) { + } on AuthenticationException catch (err, st) { setState(() { _loggingIn = false; }); - if (err is ExpiredCredentialsException) { - _updatePasswordDialog(); - } else if (err is InternetStatusException) { - if (mounted) { - unawaited( - ToastMessage.warning( - context, - S.of(context).internet_status_exception, - ), - ); - } - } else if (err is WrongCredentialsException) { - if (mounted) { - unawaited( - ToastMessage.error( - context, - S.of(context).wrong_credentials_exception, - ), - ); - } - } else { - Logger().e(err, stackTrace: st); - unawaited(Sentry.captureException(err, stackTrace: st)); - if (mounted) { - unawaited(ToastMessage.error(context, S.of(context).failed_login)); - } + + switch (err.type) { + case AuthenticationExceptionType.expiredCredentials: + _updatePasswordDialog(); + case AuthenticationExceptionType.internetError: + if (mounted) { + unawaited( + ToastMessage.warning( + context, + S.of(context).internet_status_exception, + ), + ); + } + case AuthenticationExceptionType.wrongCredentials: + if (mounted) { + unawaited( + ToastMessage.error( + context, + S.of(context).wrong_credentials_exception, + ), + ); + } + default: + Logger().e(err, stackTrace: st); + unawaited(Sentry.captureException(err, stackTrace: st)); + if (mounted) { + unawaited( + ToastMessage.error(context, S.of(context).failed_login), + ); + } + } + } + // Handles other unexpected exceptions + catch (err, st) { + setState(() { + _loggingIn = false; + }); + Logger().e(err, stackTrace: st); + unawaited(Sentry.captureException(err, stackTrace: st)); + if (mounted) { + unawaited(ToastMessage.error(context, S.of(context).failed_login)); } } } diff --git a/packages/uni_app/pubspec.yaml b/packages/uni_app/pubspec.yaml index 7c5d3d057..a9d41f398 100644 --- a/packages/uni_app/pubspec.yaml +++ b/packages/uni_app/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: "none" # We do not publish to pub.dev # To change it manually, override the value in app_version.txt. # The app version code is automatically also bumped by CI. # Do not change it manually. -version: 1.10.0-beta.35+338 +version: 1.10.0-beta.36+339 environment: sdk: ">=3.4.0 <4.0.0"