From 73d596c645b84292cf62ae058f3c3a7efcef8543 Mon Sep 17 00:00:00 2001 From: ReinerRego Date: Sun, 3 Mar 2024 22:14:40 +0100 Subject: [PATCH] started exception screen --- .../lib/screens/error_report_screen.dart | 63 +++++++++++++++---- .../lib/screens/error_report_screen.i18n.dart | 5 +- .../lib/screens/settings/settings_screen.dart | 27 +++++++- 3 files changed, 80 insertions(+), 15 deletions(-) diff --git a/refilc_mobile_ui/lib/screens/error_report_screen.dart b/refilc_mobile_ui/lib/screens/error_report_screen.dart index 0e638d4..eb68026 100644 --- a/refilc_mobile_ui/lib/screens/error_report_screen.dart +++ b/refilc_mobile_ui/lib/screens/error_report_screen.dart @@ -14,16 +14,12 @@ class ErrorReportScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Colors.red, + backgroundColor: Color(0xFFE3EBFB), body: SafeArea( child: Padding( padding: const EdgeInsets.all(12.0), child: Column( children: [ - const Align( - alignment: Alignment.topLeft, - child: BackButton(), - ), const Spacer(), const Icon( FeatherIcons.alertTriangle, @@ -58,13 +54,25 @@ class ErrorReportScreen extends StatelessWidget { width: double.infinity, padding: const EdgeInsets.all(12.0), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12.0), - color: Colors.black.withOpacity(.2)), + borderRadius: BorderRadius.circular(12.0), + color: const Color(0xFFF7F9FC), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.2), + spreadRadius: 5, + blurRadius: 7, + offset: + const Offset(0, 3), // changes position of shadow + ), + ], + ), child: SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Text( details.exceptionAsString(), - style: const TextStyle(fontFamily: 'SpaceMono'), + style: const TextStyle( + fontFamily: 'GeistMono', + fontWeight: FontWeight.w500), ), ), ), @@ -85,7 +93,8 @@ class ErrorReportScreen extends StatelessWidget { style: ButtonStyle( padding: MaterialStateProperty.all( const EdgeInsets.symmetric(vertical: 14.0)), - backgroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: + MaterialStateProperty.all(const Color(0xFF0E275A)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0)), @@ -94,14 +103,42 @@ class ErrorReportScreen extends StatelessWidget { child: Text( "submit".i18n, style: const TextStyle( - color: Colors.black, - fontSize: 17.0, - fontWeight: FontWeight.bold, - ), + color: Color(0xFFF7F9FC), + fontSize: 18.0, + fontWeight: FontWeight.w700, + fontFamily: 'Montserrat'), ), onPressed: () => reportProblem(context), ), ), + const SizedBox(height: 8), + SizedBox( + width: double.infinity, + child: OutlinedButton( + style: ButtonStyle( + padding: MaterialStateProperty.all( + const EdgeInsets.symmetric(vertical: 14.0)), + backgroundColor: + MaterialStateProperty.all(Color(0xFFF3F7FE)), + foregroundColor: + MaterialStateProperty.all(const Color(0xFFC7D3EB)), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.0)), + ), + ), + child: Text( + "goback".i18n, + style: const TextStyle( + color: Color(0xFF011234), + fontSize: 18.0, + fontFamily: 'Montserrat', + fontWeight: FontWeight.w700, + ), + ), + onPressed: () => Navigator.maybePop(context), + ), + ), const SizedBox(height: 32.0) ], ), diff --git a/refilc_mobile_ui/lib/screens/error_report_screen.i18n.dart b/refilc_mobile_ui/lib/screens/error_report_screen.i18n.dart index 498e799..59af0e0 100644 --- a/refilc_mobile_ui/lib/screens/error_report_screen.i18n.dart +++ b/refilc_mobile_ui/lib/screens/error_report_screen.i18n.dart @@ -7,6 +7,7 @@ extension SettingsLocalization on String { "uhoh": "Uh Oh!", "description": "An error occurred!", "submit": "Submit", + "goback": "Go back", "details": "Details", "error": "Error", "os": "Operating System", @@ -17,7 +18,8 @@ extension SettingsLocalization on String { "hu_hu": { "uhoh": "Ajajj!", "description": "Hiba történt!", - "submit": "Probléma Jelentése", + "submit": "Hiba jelentése", + "goback": "Vissza", "details": "Részletek", "error": "Hiba", "os": "Operációs Rendszer", @@ -29,6 +31,7 @@ extension SettingsLocalization on String { "uhoh": "Uh Oh!", "description": "Ein Fehler ist aufgetreten!", "submit": "Abschicken", + "goback": "Zurück", "details": "Details", "error": "Fehler", "os": "Betriebssystem", diff --git a/refilc_mobile_ui/lib/screens/settings/settings_screen.dart b/refilc_mobile_ui/lib/screens/settings/settings_screen.dart index 207a7a5..5f14fd1 100644 --- a/refilc_mobile_ui/lib/screens/settings/settings_screen.dart +++ b/refilc_mobile_ui/lib/screens/settings/settings_screen.dart @@ -59,7 +59,8 @@ import 'package:refilc_mobile_ui/screens/settings/user/nickname.dart'; import 'package:refilc_mobile_ui/screens/settings/user/profile_pic.dart'; // import 'package:refilc_plus/ui/mobile/settings/modify_teacher_names.dart'; // import 'package:refilc_plus/ui/mobile/settings/welcome_message.dart'; - +import 'package:refilc_mobile_ui/screens/error_screen.dart'; +import 'package:refilc_mobile_ui/screens/error_report_screen.dart'; import 'submenu/general_screen.dart'; class SettingsScreen extends StatefulWidget { @@ -198,6 +199,17 @@ class SettingsScreenState extends State vsync: this, duration: const Duration(milliseconds: 200)); } + void showErrorScreen(BuildContext context, FlutterErrorDetails details) { + Navigator.of(context, rootNavigator: true) + .push(MaterialPageRoute(builder: (context) { + if (kReleaseMode) { + return ErrorReportScreen(details); + } else { + return ErrorReportScreen(details); + } + })); + } + @override Widget build(BuildContext context) { user = Provider.of(context); @@ -993,6 +1005,19 @@ class SettingsScreenState extends State ), ], ), + ElevatedButton( + onPressed: () { + // Generate fake error details + FlutterErrorDetails fakeErrorDetails = FlutterErrorDetails( + exception: Exception('fasz'), + stack: StackTrace.current, + library: 'MyApp', + context: ErrorDescription('a kurva a-'), + ); + showErrorScreen(context, fakeErrorDetails); + }, + child: Text('hiba_tesztelese'), + ), // developer options if (settings.developerMode)