From f9105e66e36ec0d9469ae6ab901a218e93b94515 Mon Sep 17 00:00:00 2001 From: Mohammed Zeeshan Valappil <66509181+zeeshanok@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:00:34 +0530 Subject: [PATCH 1/3] feat: make error bird text alignable, scrollable and selectable --- lib/widgets/error_bird.dart | 5 ++++- lib/widgets/error_bird_container.dart | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/widgets/error_bird.dart b/lib/widgets/error_bird.dart index 59eaf8d..95f1114 100644 --- a/lib/widgets/error_bird.dart +++ b/lib/widgets/error_bird.dart @@ -7,11 +7,13 @@ class ErrorBird extends StatelessWidget { this.message, this.size = 100, this.foregroundColor, + this.textAlign, }); final String? message; final double size; final Color? foregroundColor; + final TextAlign? textAlign; @override Widget build(BuildContext context) { @@ -27,13 +29,14 @@ class ErrorBird extends StatelessWidget { ), const SizedBox(height: 10), if (message != null) - Text( + SelectableText( message!, style: TextStyle( color: foregroundColor, fontWeight: FontWeight.bold, fontSize: 16, ), + textAlign: textAlign, ), ], ), diff --git a/lib/widgets/error_bird_container.dart b/lib/widgets/error_bird_container.dart index e0eed60..fff118b 100644 --- a/lib/widgets/error_bird_container.dart +++ b/lib/widgets/error_bird_container.dart @@ -14,9 +14,11 @@ class ErrorBirdContainer extends StatelessWidget { borderRadius: BorderRadius.circular(8), ), padding: EdgeInsets.all(16), - child: ErrorBird( - message: error.toString(), - foregroundColor: Theme.of(context).colorScheme.onErrorContainer, + child: SingleChildScrollView( + child: ErrorBird( + message: error.toString(), + foregroundColor: Theme.of(context).colorScheme.onErrorContainer, + ), ), ); } From 297f8afaf50ebd9689e8df512391f0375e64cf64 Mon Sep 17 00:00:00 2001 From: Mohammed Zeeshan Valappil <66509181+zeeshanok@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:00:50 +0530 Subject: [PATCH 2/3] feat: center no slides message --- lib/modules/multipartus/screens/video.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/modules/multipartus/screens/video.dart b/lib/modules/multipartus/screens/video.dart index 2cd4a81..1aad6e4 100644 --- a/lib/modules/multipartus/screens/video.dart +++ b/lib/modules/multipartus/screens/video.dart @@ -528,6 +528,7 @@ class _SlidesView extends StatelessWidget { if (slides.isEmpty) { return ErrorBird( message: "We couldn't find slides for this lecture", + textAlign: TextAlign.center, ); } From 5e0ae5617d4ebbd3ea41ee34ef2ba5b65e29df1f Mon Sep 17 00:00:00 2001 From: Mohammed Zeeshan Valappil <66509181+zeeshanok@users.noreply.github.com> Date: Wed, 19 Feb 2025 18:01:17 +0530 Subject: [PATCH 3/3] feat: alert user when server 500s --- lib/providers/auth/oidc_auth.dart | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/providers/auth/oidc_auth.dart b/lib/providers/auth/oidc_auth.dart index a862736..a370b46 100644 --- a/lib/providers/auth/oidc_auth.dart +++ b/lib/providers/auth/oidc_auth.dart @@ -2,8 +2,10 @@ import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; +import 'package:get_it/get_it.dart'; import 'package:lex/providers/auth/auth_provider.dart'; import 'package:lex/providers/auth/auth_user.dart'; +import 'package:lex/providers/error.dart'; import 'package:oidc/oidc.dart'; import 'package:oidc_default_store/oidc_default_store.dart'; import 'package:signals/signals.dart'; @@ -32,7 +34,7 @@ class OidcAuthProvider extends AuthProvider { final dioClient = Dio( BaseOptions( baseUrl: _baseUrl, - validateStatus: (status) => true, + validateStatus: (status) => status != null && status < 500, ), ); @@ -60,6 +62,16 @@ class OidcAuthProvider extends AuthProvider { await _authManager.init(); dioClient.interceptors.add(DioAuthInterceptor(authProvider: this)); + dioClient.interceptors.add( + InterceptorsWrapper( + onError: (error, handler) { + final message = error.response?.statusMessage; + GetIt.instance() + .reportError("There was a problem with the Lex server: $message"); + handler.next(error); + }, + ), + ); // if this, for some reason, is null we can't logout assert(_authManager.discoveryDocument.endSessionEndpoint != null);