small bugfi
This commit is contained in:
4
devtools_options.yaml
Normal file
4
devtools_options.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
- shared_preferences: true
|
||||
@@ -9,196 +9,253 @@ import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
class AddEntriesDialogHelper {
|
||||
// Function to show the dialog where the user has to choose if he want to safe his values as a template
|
||||
static Future<void> showTemplateDialog(BuildContext context,
|
||||
Map<String, String> saveData) async {
|
||||
static Future<void> showTemplateDialog(
|
||||
BuildContext context,
|
||||
Map<String, String> saveData,
|
||||
) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.fieldEmpty),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
saveTemplate(saveData, DatabasesEnum.place);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, '/home', (route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.template))
|
||||
],
|
||||
);
|
||||
});
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.fieldEmpty),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
saveTemplate(saveData, DatabasesEnum.place);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.template),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static Future<dynamic> showServerErrorDialog(
|
||||
BuildContext context, Map<String, String> saveData, bool isTemplate, DatabasesEnum dbType) {
|
||||
BuildContext context,
|
||||
Map<String, String> saveData,
|
||||
bool isTemplate,
|
||||
DatabasesEnum dbType,
|
||||
) {
|
||||
bool isLoading = false;
|
||||
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.servererrortitle),
|
||||
content: isLoading
|
||||
? const SizedBox(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.servererrortitle),
|
||||
content:
|
||||
isLoading
|
||||
? const SizedBox(
|
||||
height: 100,
|
||||
child: Center(child: CircularProgressIndicator()))
|
||||
: null,
|
||||
actions: [
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
int errorCode = await HttpRequest.httpRequest(
|
||||
saveDataMap: saveData);
|
||||
setState(() => isLoading = false);
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
: null,
|
||||
actions: [
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
int errorCode = await HttpRequest.httpRequest(
|
||||
saveDataMap: saveData,
|
||||
);
|
||||
setState(() => isLoading = false);
|
||||
|
||||
if (errorCode != 201 && context.mounted) {
|
||||
showServerErrorDialog(
|
||||
context, saveData, isTemplate, dbType);
|
||||
} else {
|
||||
if (context.mounted) Navigator.pop(context);
|
||||
// saveData(true);
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
||||
if (context.mounted) showSuccessDialog(context);
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.sendagain)),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel))
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
if (errorCode == 201 && context.mounted) {
|
||||
Navigator.pop(context);
|
||||
// saveData(true);
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData,
|
||||
isTemplate: isTemplate,
|
||||
dbType: dbType,
|
||||
);
|
||||
showSuccessDialog(context);
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.sendagain),
|
||||
),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> showSaveOptionsDialog(BuildContext context,
|
||||
Map<String, String> saveData, bool isTemplate, DatabasesEnum dbType) async {
|
||||
static Future<void> showSaveOptionsDialog(
|
||||
BuildContext context,
|
||||
Map<String, String> saveData,
|
||||
bool isTemplate,
|
||||
DatabasesEnum dbType,
|
||||
) async {
|
||||
bool isLoading = false;
|
||||
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible:
|
||||
false, // Verhindert das Schließen des Dialogs durch den Benutzer
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return AlertDialog(
|
||||
title: isLoading
|
||||
? Text(AppLocalizations.of(context)!.loading)
|
||||
: Text(AppLocalizations.of(context)!.savemethod),
|
||||
content: isLoading
|
||||
? const SizedBox(
|
||||
context: context,
|
||||
barrierDismissible:
|
||||
false, // Verhindert das Schließen des Dialogs durch den Benutzer
|
||||
builder: (BuildContext context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return AlertDialog(
|
||||
title:
|
||||
isLoading
|
||||
? Text(AppLocalizations.of(context)!.loading)
|
||||
: Text(AppLocalizations.of(context)!.savemethod),
|
||||
content:
|
||||
isLoading
|
||||
? const SizedBox(
|
||||
height: 100,
|
||||
child: Center(child: CircularProgressIndicator()))
|
||||
: null,
|
||||
actions: [
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
saveTemplate(
|
||||
saveData, DatabasesEnum.place);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, '/home', (route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.template)),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
int errorCode = await HttpRequest.httpRequest(
|
||||
saveDataMap: saveData);
|
||||
setState(() => isLoading = false);
|
||||
child: Center(child: CircularProgressIndicator()),
|
||||
)
|
||||
: null,
|
||||
actions: [
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
saveTemplate(saveData, DatabasesEnum.place);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.template),
|
||||
),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
int errorCode = await HttpRequest.httpRequest(
|
||||
saveDataMap: saveData,
|
||||
);
|
||||
setState(() => isLoading = false);
|
||||
|
||||
if (errorCode != 201 || !context.mounted) {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
||||
if (context.mounted) {
|
||||
AddEntriesDialogHelper.showServerErrorDialog(
|
||||
context, saveData, isTemplate, dbType);
|
||||
}
|
||||
} else {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData,
|
||||
isTemplate: isTemplate,
|
||||
dbType: dbType,
|
||||
sent: true);
|
||||
showSuccessDialog(context);
|
||||
}
|
||||
},
|
||||
child:
|
||||
Text(AppLocalizations.of(context)!.sendtoserver)),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
if (errorCode != 201 || !context.mounted) {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData,
|
||||
isTemplate: isTemplate,
|
||||
dbType: dbType,
|
||||
);
|
||||
if (context.mounted) {
|
||||
AddEntriesDialogHelper.showServerErrorDialog(
|
||||
context,
|
||||
saveData,
|
||||
isTemplate,
|
||||
dbType,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData,
|
||||
isTemplate: isTemplate,
|
||||
dbType: dbType,
|
||||
sent: true,
|
||||
);
|
||||
showSuccessDialog(context);
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.sendtoserver),
|
||||
),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
setState(() => isLoading = true);
|
||||
|
||||
try {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
||||
SaveFileMethod.saveFile(
|
||||
saveData,
|
||||
AppLocalizations.of(context)!.savefilefailed,
|
||||
saveData["CID"]!);
|
||||
setState(() => isLoading = false);
|
||||
|
||||
} catch (e) {
|
||||
SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.savefilefailed);
|
||||
}
|
||||
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, '/home', (route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.justsave)),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel)),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
try {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData,
|
||||
isTemplate: isTemplate,
|
||||
dbType: dbType,
|
||||
);
|
||||
SaveFileMethod.saveFile(
|
||||
saveData,
|
||||
AppLocalizations.of(context)!.savefilefailed,
|
||||
saveData["CID"]!,
|
||||
);
|
||||
setState(() => isLoading = false);
|
||||
} catch (e) {
|
||||
SnackBarHelper.showSnackBarMessage(
|
||||
context,
|
||||
AppLocalizations.of(context)!.savefilefailed,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.saveasfile),
|
||||
),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SaveMainEntryMethod.saveEntry(
|
||||
entryData: saveData,
|
||||
isTemplate: isTemplate,
|
||||
dbType: dbType,
|
||||
);
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.justsave),
|
||||
),
|
||||
if (!isLoading)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> showSuccessDialog(BuildContext context) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.successful),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context, '/home', (route) => false);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.continueB))
|
||||
],
|
||||
);
|
||||
});
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context)!.successful),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
'/home',
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.continueB),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user