Merge pull request #457 from pangeachat/blue7/08
Added null checks, error handling, and used non-null version of l10n
This commit is contained in:
commit
8d8e7eada3
5 changed files with 84 additions and 85 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<void> _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!);
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
),
|
||||
],
|
||||
),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,6 +193,8 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
late StreamSubscription<MessageMode> 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 =
|
||||
|
|
|
|||
|
|
@ -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#
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue