started exception screen

This commit is contained in:
Zypherift 2024-03-03 22:14:40 +01:00
parent 8c46b941ae
commit 73d596c645
3 changed files with 80 additions and 15 deletions

View File

@ -14,16 +14,12 @@ class ErrorReportScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: Colors.red, backgroundColor: Color(0xFFE3EBFB),
body: SafeArea( body: SafeArea(
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Column( child: Column(
children: [ children: [
const Align(
alignment: Alignment.topLeft,
child: BackButton(),
),
const Spacer(), const Spacer(),
const Icon( const Icon(
FeatherIcons.alertTriangle, FeatherIcons.alertTriangle,
@ -59,12 +55,24 @@ class ErrorReportScreen extends StatelessWidget {
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0), borderRadius: BorderRadius.circular(12.0),
color: Colors.black.withOpacity(.2)), 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( child: SingleChildScrollView(
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
child: Text( child: Text(
details.exceptionAsString(), 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( style: ButtonStyle(
padding: MaterialStateProperty.all( padding: MaterialStateProperty.all(
const EdgeInsets.symmetric(vertical: 14.0)), const EdgeInsets.symmetric(vertical: 14.0)),
backgroundColor: MaterialStateProperty.all(Colors.white), backgroundColor:
MaterialStateProperty.all(const Color(0xFF0E275A)),
shape: MaterialStateProperty.all( shape: MaterialStateProperty.all(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0)), borderRadius: BorderRadius.circular(12.0)),
@ -94,14 +103,42 @@ class ErrorReportScreen extends StatelessWidget {
child: Text( child: Text(
"submit".i18n, "submit".i18n,
style: const TextStyle( style: const TextStyle(
color: Colors.black, color: Color(0xFFF7F9FC),
fontSize: 17.0, fontSize: 18.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.w700,
), fontFamily: 'Montserrat'),
), ),
onPressed: () => reportProblem(context), 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) const SizedBox(height: 32.0)
], ],
), ),

View File

@ -7,6 +7,7 @@ extension SettingsLocalization on String {
"uhoh": "Uh Oh!", "uhoh": "Uh Oh!",
"description": "An error occurred!", "description": "An error occurred!",
"submit": "Submit", "submit": "Submit",
"goback": "Go back",
"details": "Details", "details": "Details",
"error": "Error", "error": "Error",
"os": "Operating System", "os": "Operating System",
@ -17,7 +18,8 @@ extension SettingsLocalization on String {
"hu_hu": { "hu_hu": {
"uhoh": "Ajajj!", "uhoh": "Ajajj!",
"description": "Hiba történt!", "description": "Hiba történt!",
"submit": "Probléma Jelentése", "submit": "Hiba jelentése",
"goback": "Vissza",
"details": "Részletek", "details": "Részletek",
"error": "Hiba", "error": "Hiba",
"os": "Operációs Rendszer", "os": "Operációs Rendszer",
@ -29,6 +31,7 @@ extension SettingsLocalization on String {
"uhoh": "Uh Oh!", "uhoh": "Uh Oh!",
"description": "Ein Fehler ist aufgetreten!", "description": "Ein Fehler ist aufgetreten!",
"submit": "Abschicken", "submit": "Abschicken",
"goback": "Zurück",
"details": "Details", "details": "Details",
"error": "Fehler", "error": "Fehler",
"os": "Betriebssystem", "os": "Betriebssystem",

View File

@ -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_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/modify_teacher_names.dart';
// import 'package:refilc_plus/ui/mobile/settings/welcome_message.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'; import 'submenu/general_screen.dart';
class SettingsScreen extends StatefulWidget { class SettingsScreen extends StatefulWidget {
@ -198,6 +199,17 @@ class SettingsScreenState extends State<SettingsScreen>
vsync: this, duration: const Duration(milliseconds: 200)); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
user = Provider.of<UserProvider>(context); user = Provider.of<UserProvider>(context);
@ -993,6 +1005,19 @@ class SettingsScreenState extends State<SettingsScreen>
), ),
], ],
), ),
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 // developer options
if (settings.developerMode) if (settings.developerMode)