Anzeigefehler mit Snackbar #166
@@ -37,7 +37,9 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return ScaffoldMessenger(
|
return ScaffoldMessenger(
|
||||||
child: Scaffold(
|
child: Builder(
|
||||||
|
builder: (scaffoldMessengerContext) {
|
||||||
|
return Scaffold(
|
||||||
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
appBar: AppBar(backgroundColor: CustomTheme.backgroundColor),
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
@@ -57,7 +59,11 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 16, top: 10, bottom: 10),
|
padding: const EdgeInsets.only(
|
||||||
|
left: 16,
|
||||||
|
top: 10,
|
||||||
|
bottom: 10,
|
||||||
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
loc.data,
|
loc.data,
|
||||||
@@ -73,13 +79,18 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final String json =
|
final String json =
|
||||||
await DataTransferService.getAppDataAsJson(context);
|
await DataTransferService.getAppDataAsJson(
|
||||||
|
scaffoldMessengerContext,
|
||||||
|
);
|
||||||
final result = await DataTransferService.exportData(
|
final result = await DataTransferService.exportData(
|
||||||
json,
|
json,
|
||||||
'game_tracker-data',
|
'game_tracker-data',
|
||||||
);
|
);
|
||||||
if (!context.mounted) return;
|
if (!scaffoldMessengerContext.mounted) return;
|
||||||
showExportSnackBar(context: context, result: result);
|
showExportSnackBar(
|
||||||
|
context: scaffoldMessengerContext,
|
||||||
|
result: result,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SettingsListTile(
|
SettingsListTile(
|
||||||
@@ -87,9 +98,14 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
icon: Icons.download,
|
icon: Icons.download,
|
||||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final result = await DataTransferService.importData(context);
|
final result = await DataTransferService.importData(
|
||||||
if (!context.mounted) return;
|
scaffoldMessengerContext,
|
||||||
showImportSnackBar(context: context, result: result);
|
);
|
||||||
|
if (!scaffoldMessengerContext.mounted) return;
|
||||||
|
showImportSnackBar(
|
||||||
|
context: scaffoldMessengerContext,
|
||||||
|
result: result,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SettingsListTile(
|
SettingsListTile(
|
||||||
@@ -98,28 +114,33 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
suffixWidget: const Icon(Icons.arrow_forward_ios, size: 16),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog<bool>(
|
showDialog<bool>(
|
||||||
context: context,
|
context: scaffoldMessengerContext,
|
||||||
builder: (context) => AlertDialog(
|
builder: (dialogContext) => AlertDialog(
|
||||||
title: Text('${loc.delete_all_data}?'),
|
title: Text('${loc.delete_all_data}?'),
|
||||||
content: Text(loc.this_cannot_be_undone),
|
content: Text(loc.this_cannot_be_undone),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(false),
|
onPressed: () =>
|
||||||
|
Navigator.of(dialogContext).pop(false),
|
||||||
child: Text(loc.cancel),
|
child: Text(loc.cancel),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(true),
|
onPressed: () =>
|
||||||
|
Navigator.of(dialogContext).pop(true),
|
||||||
child: Text(loc.delete),
|
child: Text(loc.delete),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
).then((confirmed) {
|
).then((confirmed) {
|
||||||
if (confirmed == true && context.mounted) {
|
if (confirmed == true &&
|
||||||
DataTransferService.deleteAllData(context);
|
scaffoldMessengerContext.mounted) {
|
||||||
|
DataTransferService.deleteAllData(
|
||||||
|
scaffoldMessengerContext,
|
||||||
|
);
|
||||||
showSnackbar(
|
showSnackbar(
|
||||||
context: context,
|
context: scaffoldMessengerContext,
|
||||||
message: AppLocalizations.of(
|
message: AppLocalizations.of(
|
||||||
context,
|
scaffoldMessengerContext,
|
||||||
).data_successfully_deleted,
|
).data_successfully_deleted,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -127,7 +148,11 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 16, top: 10, bottom: 10),
|
padding: const EdgeInsets.only(
|
||||||
|
left: 16,
|
||||||
|
top: 10,
|
||||||
|
bottom: 10,
|
||||||
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
textAlign: TextAlign.start,
|
textAlign: TextAlign.start,
|
||||||
loc.legal,
|
loc.legal,
|
||||||
@@ -176,7 +201,9 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: const Icon(Icons.language),
|
child: const Icon(Icons.language),
|
||||||
onTap: () => {
|
onTap: () => {
|
||||||
launchUrl(Uri.parse('https://liquid-dev.de')),
|
launchUrl(
|
||||||
|
Uri.parse('https://liquid-dev.de'),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
@@ -225,6 +252,8 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -285,10 +314,11 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
Duration duration = const Duration(seconds: 3),
|
Duration duration = const Duration(seconds: 3),
|
||||||
VoidCallback? action,
|
VoidCallback? action,
|
||||||
}) {
|
}) {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
final messenger = ScaffoldMessenger.of(context);
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
messenger.hideCurrentSnackBar();
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
messenger.showSnackBar(
|
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(message, style: const TextStyle(color: Colors.white)),
|
content: Text(message, style: const TextStyle(color: Colors.white)),
|
||||||
backgroundColor: CustomTheme.onBoxColor,
|
backgroundColor: CustomTheme.onBoxColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user