diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index a02626978..9337b488a 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -491,7 +491,12 @@ class InputBar extends StatelessWidget { textInputAction: textInputAction, autofocus: autofocus!, inputFormatters: [ - LengthLimitingTextInputFormatter((maxPDUSize / 3).floor()), + //#Pangea + //LengthLimitingTextInputFormatter((maxPDUSize / 3).floor()), + //setting max character count to 1000 + //after max, nothing else can be typed + LengthLimitingTextInputFormatter(1000), + //Pangea# ], onSubmitted: (text) { // fix for library for now diff --git a/lib/pangea/controllers/my_analytics_controller.dart b/lib/pangea/controllers/my_analytics_controller.dart index 058bad359..12baeb689 100644 --- a/lib/pangea/controllers/my_analytics_controller.dart +++ b/lib/pangea/controllers/my_analytics_controller.dart @@ -229,11 +229,8 @@ class MyAnalyticsController { /// top level analytics sending function. Gather recent messages and activity records, /// convert them into the correct formats, and send them to the analytics room Future _updateAnalytics() async { - // if missing important info, don't send analytics - if (userL2 == null || _client.userID == null) { - debugger(when: kDebugMode); - return; - } + // if missing important info, don't send analytics. Could happen if user just signed up. + if (userL2 == null || _client.userID == null) return; // analytics room for the user and current target language final Room analyticsRoom = await _client.getMyAnalyticsRoom(userL2!); diff --git a/lib/pangea/pages/p_user_age/p_user_age_view.dart b/lib/pangea/pages/p_user_age/p_user_age_view.dart index 1438cf0fe..693099994 100644 --- a/lib/pangea/pages/p_user_age/p_user_age_view.dart +++ b/lib/pangea/pages/p_user_age/p_user_age_view.dart @@ -17,32 +17,25 @@ class PUserAgeView extends StatelessWidget { ), body: ListView( children: [ - Container( - margin: const EdgeInsets.only(top: 10), - padding: const EdgeInsets.all(15), - child: Text( - L10n.of(context)!.yourBirthdayPlease, - textAlign: TextAlign.justify, - style: const TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox( - height: 10, - ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Theme.of(context) - .colorScheme - .onSecondaryContainer - .withAlpha(50), + color: Theme.of(context).colorScheme.onSecondaryContainer.withAlpha(50), ), child: Column( children: [ + Padding( + padding: const EdgeInsets.all(15), + child: Text( + L10n.of(context)!.yourBirthdayPlease, + textAlign: TextAlign.justify, + style: const TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.normal, + ), + ), + ), ListTile( title: Text( L10n.of(context)!.certifyAge(13), @@ -70,23 +63,16 @@ class PUserAgeView extends StatelessWidget { ], ), ), - const SizedBox( - height: 10, - ), - if (controller.error != null) - Padding( - padding: const EdgeInsets.all(12), - child: Text( - controller.error!, - style: const TextStyle(color: Colors.white), - ), - ), + const SizedBox(height: 20), Hero( tag: 'loginButton', child: Padding( - padding: const EdgeInsets.all(12), + padding: const EdgeInsets.symmetric(horizontal: 12), child: ElevatedButton( onPressed: controller.createUserInPangea, + style: ElevatedButton.styleFrom( + minimumSize: const Size.fromHeight(50), + ), child: controller.loading ? const LinearProgressIndicator() : Text(L10n.of(context)!.getStarted), @@ -95,7 +81,6 @@ class PUserAgeView extends StatelessWidget { ), ], ), - // ), ); } } diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 07b0ad0d5..930a1dc1e 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -193,6 +193,8 @@ class MessageToolbarState extends State { late StreamSubscription toolbarModeStream; void updateMode(MessageMode newMode) { + //Early exit from the function if the widget has been unmounted to prevent updates on an inactive widget. + if (!mounted) return; if (updatingMode) return; debugPrint("updating toolbar mode"); final bool subscribed = diff --git a/lib/utils/error_reporter.dart b/lib/utils/error_reporter.dart index f3b3bfabd..d44b48dcb 100644 --- a/lib/utils/error_reporter.dart +++ b/lib/utils/error_reporter.dart @@ -11,57 +11,67 @@ class ErrorReporter { void onErrorCallback(Object error, [StackTrace? stackTrace]) async { Logs().e(message ?? 'Error caught', error, stackTrace); // #Pangea + // Attempt to retrieve the L10n instance using the current context + final L10n? l10n = L10n.of(context); + + // Check if the L10n instance is null + if (l10n == null) { + // Log an error message saying that the localization object is null + Logs().e('Localization object is null, cannot show error message.'); + // Exits early to prevent further execution + return; + } ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - L10n.of(context)!.oopsSomethingWentWrong, + l10n.oopsSomethingWentWrong, // Use the non-null L10n instance to get the error message ), ), ); - // final text = '$error\n${stackTrace ?? ''}'; - // await showAdaptiveDialog( - // context: context, - // builder: (context) => AlertDialog.adaptive( - // title: Text(L10n.of(context)!.reportErrorDescription), - // content: SizedBox( - // height: 256, - // width: 256, - // child: SingleChildScrollView( - // child: HighlightView( - // text, - // language: 'sh', - // theme: shadesOfPurpleTheme, - // ), - // ), - // ), - // actions: [ - // TextButton( - // onPressed: () => Navigator.of(context).pop(), - // child: Text(L10n.of(context)!.close), - // ), - // TextButton( - // onPressed: () => Clipboard.setData( - // ClipboardData(text: text), - // ), - // child: Text(L10n.of(context)!.copy), - // ), - // TextButton( - // onPressed: () => launchUrl( - // AppConfig.newIssueUrl.resolveUri( - // Uri( - // queryParameters: { - // 'template': 'bug_report.yaml', - // 'title': '[BUG]: ${message ?? error.toString()}', - // }, - // ), - // ), - // mode: LaunchMode.externalApplication, - // ), - // child: Text(L10n.of(context)!.report), - // ), - // ], - // ), - // ); - // Pangea# } + // final text = '$error\n${stackTrace ?? ''}'; + // await showAdaptiveDialog( + // context: context, + // builder: (context) => AlertDialog.adaptive( + // title: Text(L10n.of(context)!.reportErrorDescription), + // content: SizedBox( + // height: 256, + // width: 256, + // child: SingleChildScrollView( + // child: HighlightView( + // text, + // language: 'sh', + // theme: shadesOfPurpleTheme, + // ), + // ), + // ), + // actions: [ + // TextButton( + // onPressed: () => Navigator.of(context).pop(), + // child: Text(L10n.of(context)!.close), + // ), + // TextButton( + // onPressed: () => Clipboard.setData( + // ClipboardData(text: text), + // ), + // child: Text(L10n.of(context)!.copy), + // ), + // TextButton( + // onPressed: () => launchUrl( + // AppConfig.newIssueUrl.resolveUri( + // Uri( + // queryParameters: { + // 'template': 'bug_report.yaml', + // 'title': '[BUG]: ${message ?? error.toString()}', + // }, + // ), + // ), + // mode: LaunchMode.externalApplication, + // ), + // child: Text(L10n.of(context)!.report), + // ), + // ], + // ), + // ); + // Pangea# }