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,8 +9,10 @@ import 'package:fforte/l10n/app_localizations.dart';
|
|||||||
|
|
||||||
class AddEntriesDialogHelper {
|
class AddEntriesDialogHelper {
|
||||||
// Function to show the dialog where the user has to choose if he want to safe his values as a template
|
// 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,
|
static Future<void> showTemplateDialog(
|
||||||
Map<String, String> saveData) async {
|
BuildContext context,
|
||||||
|
Map<String, String> saveData,
|
||||||
|
) async {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -22,21 +24,31 @@ class AddEntriesDialogHelper {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.cancel)),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
saveTemplate(saveData, DatabasesEnum.place);
|
saveTemplate(saveData, DatabasesEnum.place);
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
context,
|
||||||
|
'/home',
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.template))
|
child: Text(AppLocalizations.of(context)!.template),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<dynamic> showServerErrorDialog(
|
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;
|
bool isLoading = false;
|
||||||
|
|
||||||
return showDialog(
|
return showDialog(
|
||||||
@@ -46,10 +58,12 @@ class AddEntriesDialogHelper {
|
|||||||
builder: (BuildContext context, StateSetter setState) {
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(AppLocalizations.of(context)!.servererrortitle),
|
title: Text(AppLocalizations.of(context)!.servererrortitle),
|
||||||
content: isLoading
|
content:
|
||||||
|
isLoading
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
child: Center(child: CircularProgressIndicator()))
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
actions: [
|
actions: [
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
@@ -57,36 +71,44 @@ class AddEntriesDialogHelper {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
int errorCode = await HttpRequest.httpRequest(
|
int errorCode = await HttpRequest.httpRequest(
|
||||||
saveDataMap: saveData);
|
saveDataMap: saveData,
|
||||||
|
);
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
|
|
||||||
if (errorCode != 201 && context.mounted) {
|
if (errorCode == 201 && context.mounted) {
|
||||||
showServerErrorDialog(
|
Navigator.pop(context);
|
||||||
context, saveData, isTemplate, dbType);
|
|
||||||
} else {
|
|
||||||
if (context.mounted) Navigator.pop(context);
|
|
||||||
// saveData(true);
|
// saveData(true);
|
||||||
SaveMainEntryMethod.saveEntry(
|
SaveMainEntryMethod.saveEntry(
|
||||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
entryData: saveData,
|
||||||
if (context.mounted) showSuccessDialog(context);
|
isTemplate: isTemplate,
|
||||||
|
dbType: dbType,
|
||||||
|
);
|
||||||
|
showSuccessDialog(context);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.sendagain)),
|
child: Text(AppLocalizations.of(context)!.sendagain),
|
||||||
|
),
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.cancel))
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> showSaveOptionsDialog(BuildContext context,
|
static Future<void> showSaveOptionsDialog(
|
||||||
Map<String, String> saveData, bool isTemplate, DatabasesEnum dbType) async {
|
BuildContext context,
|
||||||
|
Map<String, String> saveData,
|
||||||
|
bool isTemplate,
|
||||||
|
DatabasesEnum dbType,
|
||||||
|
) async {
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
return showDialog(
|
return showDialog(
|
||||||
@@ -97,51 +119,66 @@ class AddEntriesDialogHelper {
|
|||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (context, setState) {
|
builder: (context, setState) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: isLoading
|
title:
|
||||||
|
isLoading
|
||||||
? Text(AppLocalizations.of(context)!.loading)
|
? Text(AppLocalizations.of(context)!.loading)
|
||||||
: Text(AppLocalizations.of(context)!.savemethod),
|
: Text(AppLocalizations.of(context)!.savemethod),
|
||||||
content: isLoading
|
content:
|
||||||
|
isLoading
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
child: Center(child: CircularProgressIndicator()))
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
)
|
||||||
: null,
|
: null,
|
||||||
actions: [
|
actions: [
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
saveTemplate(
|
saveTemplate(saveData, DatabasesEnum.place);
|
||||||
saveData, DatabasesEnum.place);
|
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
context,
|
||||||
|
'/home',
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.template)),
|
child: Text(AppLocalizations.of(context)!.template),
|
||||||
|
),
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
int errorCode = await HttpRequest.httpRequest(
|
int errorCode = await HttpRequest.httpRequest(
|
||||||
saveDataMap: saveData);
|
saveDataMap: saveData,
|
||||||
|
);
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
|
|
||||||
if (errorCode != 201 || !context.mounted) {
|
if (errorCode != 201 || !context.mounted) {
|
||||||
SaveMainEntryMethod.saveEntry(
|
SaveMainEntryMethod.saveEntry(
|
||||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
entryData: saveData,
|
||||||
|
isTemplate: isTemplate,
|
||||||
|
dbType: dbType,
|
||||||
|
);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
AddEntriesDialogHelper.showServerErrorDialog(
|
AddEntriesDialogHelper.showServerErrorDialog(
|
||||||
context, saveData, isTemplate, dbType);
|
context,
|
||||||
|
saveData,
|
||||||
|
isTemplate,
|
||||||
|
dbType,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SaveMainEntryMethod.saveEntry(
|
SaveMainEntryMethod.saveEntry(
|
||||||
entryData: saveData,
|
entryData: saveData,
|
||||||
isTemplate: isTemplate,
|
isTemplate: isTemplate,
|
||||||
dbType: dbType,
|
dbType: dbType,
|
||||||
sent: true);
|
sent: true,
|
||||||
|
);
|
||||||
showSuccessDialog(context);
|
showSuccessDialog(context);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child:
|
child: Text(AppLocalizations.of(context)!.sendtoserver),
|
||||||
Text(AppLocalizations.of(context)!.sendtoserver)),
|
),
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -149,39 +186,54 @@ class AddEntriesDialogHelper {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
SaveMainEntryMethod.saveEntry(
|
SaveMainEntryMethod.saveEntry(
|
||||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
entryData: saveData,
|
||||||
|
isTemplate: isTemplate,
|
||||||
|
dbType: dbType,
|
||||||
|
);
|
||||||
SaveFileMethod.saveFile(
|
SaveFileMethod.saveFile(
|
||||||
saveData,
|
saveData,
|
||||||
AppLocalizations.of(context)!.savefilefailed,
|
AppLocalizations.of(context)!.savefilefailed,
|
||||||
saveData["CID"]!);
|
saveData["CID"]!,
|
||||||
|
);
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
SnackBarHelper.showSnackBarMessage(context, AppLocalizations.of(context)!.savefilefailed);
|
SnackBarHelper.showSnackBarMessage(
|
||||||
|
context,
|
||||||
|
AppLocalizations.of(context)!.savefilefailed,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.saveasfile)),
|
child: Text(AppLocalizations.of(context)!.saveasfile),
|
||||||
|
),
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
SaveMainEntryMethod.saveEntry(
|
SaveMainEntryMethod.saveEntry(
|
||||||
entryData: saveData, isTemplate: isTemplate, dbType: dbType);
|
entryData: saveData,
|
||||||
|
isTemplate: isTemplate,
|
||||||
|
dbType: dbType,
|
||||||
|
);
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
context,
|
||||||
|
'/home',
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.justsave)),
|
child: Text(AppLocalizations.of(context)!.justsave),
|
||||||
|
),
|
||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.cancel)),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> showSuccessDialog(BuildContext context) async {
|
static Future<void> showSuccessDialog(BuildContext context) async {
|
||||||
@@ -194,11 +246,16 @@ class AddEntriesDialogHelper {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context, '/home', (route) => false);
|
context,
|
||||||
|
'/home',
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.continueB))
|
child: Text(AppLocalizations.of(context)!.continueB),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user