replace error popup with scaffold message

pull/1011/head
Gabby Gurdin 2 years ago
parent e39b19877f
commit d8927b606d

@ -1,17 +1,6 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_highlighter/flutter_highlighter.dart';
import 'package:flutter_highlighter/themes/shades-of-purple.dart';
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart';
class ErrorReporter { class ErrorReporter {
final BuildContext context; final BuildContext context;
@ -21,63 +10,72 @@ class ErrorReporter {
void onErrorCallback(Object error, [StackTrace? stackTrace]) async { void onErrorCallback(Object error, [StackTrace? stackTrace]) async {
Logs().e(message ?? 'Error caught', error, stackTrace); Logs().e(message ?? 'Error caught', error, stackTrace);
final text = '$error\n${stackTrace ?? ''}'; ScaffoldMessenger.of(context).showSnackBar(
final consent = await showAdaptiveDialog<bool>( SnackBar(
context: context, content: Text(
builder: (context) => AlertDialog.adaptive( L10n.of(context)!.oopsSomethingWentWrong,
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<bool>(false),
child: Text(L10n.of(context)!.close),
), ),
TextButton(
onPressed: () => Clipboard.setData(
ClipboardData(text: text),
),
child: Text(L10n.of(context)!.copy),
),
TextButton(
onPressed: () => Navigator.of(context).pop<bool>(true),
child: Text(L10n.of(context)!.report),
),
],
), ),
); );
if (consent != true) return; // #Pangea
final os = kIsWeb ? 'web' : Platform.operatingSystem; // final text = '$error\n${stackTrace ?? ''}';
final version = await PlatformInfos.getVersion(); // final consent = await showAdaptiveDialog<bool>(
final description = ''' // context: context,
- Operating system: $os // builder: (context) => AlertDialog.adaptive(
- Version: $version // 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<bool>(false),
// child: Text(L10n.of(context)!.close),
// ),
// TextButton(
// onPressed: () => Clipboard.setData(
// ClipboardData(text: text),
// ),
// child: Text(L10n.of(context)!.copy),
// ),
// TextButton(
// onPressed: () => Navigator.of(context).pop<bool>(true),
// child: Text(L10n.of(context)!.report),
// ),
// ],
// ),
// );
// if (consent != true) return;
// final os = kIsWeb ? 'web' : Platform.operatingSystem;
// final version = await PlatformInfos.getVersion();
// final description = '''
// - Operating system: $os
// - Version: $version
### Exception // ### Exception
$error // $error
### StackTrace // ### StackTrace
${stackTrace?.toString().split('\n').take(10).join('\n')} // ${stackTrace?.toString().split('\n').take(10).join('\n')}
'''; // ''';
launchUrl( // launchUrl(
AppConfig.newIssueUrl.resolveUri( // AppConfig.newIssueUrl.resolveUri(
Uri( // Uri(
queryParameters: { // queryParameters: {
'title': '[BUG]: ${message ?? error.toString()}', // 'title': '[BUG]: ${message ?? error.toString()}',
'body': description, // 'body': description,
}, // },
), // ),
), // ),
mode: LaunchMode.externalApplication, // mode: LaunchMode.externalApplication,
); // );
// Pangea#
} }
} }

Loading…
Cancel
Save