fixed saveFile
time time this time for real
This commit is contained in:
BIN
app-release.apk
BIN
app-release.apk
Binary file not shown.
@@ -48,21 +48,21 @@ class ExcursionDBHelper implements IDb {
|
|||||||
@override
|
@override
|
||||||
Future<int> addMainEntry(Map<String, String> excursion) async {
|
Future<int> addMainEntry(Map<String, String> excursion) async {
|
||||||
var excursionDBClient = await dB;
|
var excursionDBClient = await dB;
|
||||||
final existingID = await excursionDBClient.query(
|
// final existingID = await excursionDBClient.query(
|
||||||
'excursion',
|
// 'excursion',
|
||||||
where: 'ID = ?',
|
// where: 'ID = ?',
|
||||||
whereArgs: [excursion['ID']],
|
// whereArgs: [excursion['ID']],
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (existingID.isNotEmpty) {
|
// if (existingID.isNotEmpty) {
|
||||||
updateMainEntry(excursion);
|
// updateMainEntry(excursion);
|
||||||
return existingID.first['ID'] as int; // Return existing ID
|
// return existingID.first['ID'] as int; // Return existing ID
|
||||||
}
|
// }
|
||||||
|
|
||||||
int id = await excursionDBClient.insert(
|
int id = await excursionDBClient.insert(
|
||||||
'excursion',
|
'excursion',
|
||||||
excursion,
|
excursion,
|
||||||
//conflictAlgorithm: ConflictAlgorithm.replace,
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
);
|
);
|
||||||
|
|
||||||
return id; // Return the ID of the newly inserted entry
|
return id; // Return the ID of the newly inserted entry
|
||||||
|
|||||||
@@ -620,13 +620,14 @@ class _AddCamMainState extends State<AddCamMain> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool empty = CheckRequired.checkRequired(rmap);
|
bool empty = CheckRequired.checkRequired(rmap);
|
||||||
// TODO for debugging always false
|
// for debugging always false
|
||||||
empty = false;
|
// empty = false;
|
||||||
|
|
||||||
if (empty == true) {
|
if (empty == true) {
|
||||||
AddEntriesDialogHelper.showTemplateDialog(
|
AddEntriesDialogHelper.showTemplateDialog(
|
||||||
context,
|
context,
|
||||||
getFieldsText(),
|
getFieldsText(),
|
||||||
|
DatabasesEnum.place
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else if (empty == false) {
|
} else if (empty == false) {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
class FileDialogCancelled implements Exception {}
|
||||||
@@ -462,16 +462,17 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool empty = CheckRequired.checkRequired(rmap);
|
bool empty = CheckRequired.checkRequired(rmap);
|
||||||
// TODO for debugging always false
|
// for debugging always false
|
||||||
empty = false;
|
// empty = false;
|
||||||
|
|
||||||
if (empty == true) {
|
if (empty) {
|
||||||
AddEntriesDialogHelper.showTemplateDialog(
|
AddEntriesDialogHelper.showTemplateDialog(
|
||||||
context,
|
context,
|
||||||
getFieldsText(),
|
getFieldsText(),
|
||||||
|
DatabasesEnum.excursion
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else if (empty == false) {
|
} else if (!empty) {
|
||||||
await AddEntriesDialogHelper.showSaveOptionsDialog(
|
await AddEntriesDialogHelper.showSaveOptionsDialog(
|
||||||
context,
|
context,
|
||||||
getFieldsText(),
|
getFieldsText(),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class _TrackingState extends State<Tracking> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// TODO debugging (i guess)
|
// debugging (i guess)
|
||||||
// pathList.add(
|
// pathList.add(
|
||||||
// LatLng(widget.startPosition.latitude, widget.startPosition.longitude),
|
// LatLng(widget.startPosition.latitude, widget.startPosition.longitude),
|
||||||
// );
|
// );
|
||||||
@@ -113,6 +113,7 @@ class _TrackingState extends State<Tracking> {
|
|||||||
if (position != null) {
|
if (position != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
pathList.add(LatLng(position.latitude, position.longitude));
|
pathList.add(LatLng(position.latitude, position.longitude));
|
||||||
|
// Random value for debugging
|
||||||
// pathList.add(LatLng(rand.nextInt(5) + 40, position.longitude));
|
// pathList.add(LatLng(rand.nextInt(5) + 40, position.longitude));
|
||||||
|
|
||||||
locationMarkerPosition = LocationMarkerPosition(
|
locationMarkerPosition = LocationMarkerPosition(
|
||||||
@@ -141,7 +142,9 @@ class _TrackingState extends State<Tracking> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(AppLocalizations.of(context)!.tracking),
|
title: Text(AppLocalizations.of(context)!.tracking),
|
||||||
// leading: IconButton(onPressed: () {}, icon: Icon(Icons.arrow_back_rounded)),
|
leading: IconButton(onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}, icon: Icon(Icons.arrow_back_rounded)),
|
||||||
actions: [
|
actions: [
|
||||||
if (!positionStreamRunning)
|
if (!positionStreamRunning)
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:fforte/screens/sharedMethods/http_request.dart';
|
|||||||
import 'package:fforte/screens/sharedMethods/save_file.dart';
|
import 'package:fforte/screens/sharedMethods/save_file.dart';
|
||||||
import 'package:fforte/screens/sharedMethods/save_template.dart';
|
import 'package:fforte/screens/sharedMethods/save_template.dart';
|
||||||
import 'package:fforte/screens/sharedMethods/save_main_entry.dart';
|
import 'package:fforte/screens/sharedMethods/save_main_entry.dart';
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fforte/l10n/app_localizations.dart';
|
import 'package:fforte/l10n/app_localizations.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
@@ -13,6 +14,7 @@ class AddEntriesDialogHelper {
|
|||||||
static Future<void> showTemplateDialog(
|
static Future<void> showTemplateDialog(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
Map<String, String> saveData,
|
Map<String, String> saveData,
|
||||||
|
DatabasesEnum dbType,
|
||||||
) async {
|
) async {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -29,7 +31,7 @@ class AddEntriesDialogHelper {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
saveTemplate(saveData, DatabasesEnum.place);
|
saveTemplate(saveData, dbType);
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
'/home',
|
'/home',
|
||||||
@@ -114,8 +116,7 @@ class AddEntriesDialogHelper {
|
|||||||
|
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible:
|
barrierDismissible: false,
|
||||||
false, // Verhindert das Schließen des Dialogs durch den Benutzer
|
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (context, setState) {
|
builder: (context, setState) {
|
||||||
@@ -136,7 +137,7 @@ class AddEntriesDialogHelper {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
setState(() => isLoading = true);
|
setState(() => isLoading = true);
|
||||||
saveTemplate(saveData, DatabasesEnum.place);
|
saveTemplate(saveData, dbType);
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
'/home',
|
'/home',
|
||||||
@@ -191,17 +192,29 @@ class AddEntriesDialogHelper {
|
|||||||
isTemplate: isTemplate,
|
isTemplate: isTemplate,
|
||||||
dbType: dbType,
|
dbType: dbType,
|
||||||
);
|
);
|
||||||
SaveFileMethod.saveFile(
|
try {
|
||||||
saveData,
|
if (context.mounted) {
|
||||||
AppLocalizations.of(context)!.savefilefailed,
|
await SaveFileMethod.saveFile(
|
||||||
saveData["CID"]!,
|
saveData,
|
||||||
);
|
dbType == DatabasesEnum.place
|
||||||
|
? AppLocalizations.of(context)!.justplace
|
||||||
|
: AppLocalizations.of(context)!.excursion,
|
||||||
|
dbType,
|
||||||
|
);
|
||||||
|
if (context.mounted) Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// User cancelled the dialog
|
||||||
|
}
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
SnackBarHelper.showSnackBarMessage(
|
if (context.mounted) {
|
||||||
context,
|
Navigator.pop(context);
|
||||||
AppLocalizations.of(context)!.savefilefailed,
|
SnackBarHelper.showSnackBarMessage(
|
||||||
);
|
context,
|
||||||
|
AppLocalizations.of(context)!.savefilefailed,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.saveasfile),
|
child: Text(AppLocalizations.of(context)!.saveasfile),
|
||||||
@@ -209,16 +222,20 @@ class AddEntriesDialogHelper {
|
|||||||
if (!isLoading)
|
if (!isLoading)
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
SaveMainEntryMethod.saveEntry(
|
try {
|
||||||
entryData: saveData,
|
SaveMainEntryMethod.saveEntry(
|
||||||
isTemplate: isTemplate,
|
entryData: saveData,
|
||||||
dbType: dbType,
|
isTemplate: isTemplate,
|
||||||
);
|
dbType: dbType,
|
||||||
Navigator.pushNamedAndRemoveUntil(
|
);
|
||||||
context,
|
Navigator.pushNamedAndRemoveUntil(
|
||||||
'/home',
|
context,
|
||||||
(route) => false,
|
'/home',
|
||||||
);
|
(route) => false,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(e.toString());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.justsave),
|
child: Text(AppLocalizations.of(context)!.justsave),
|
||||||
),
|
),
|
||||||
@@ -276,7 +293,9 @@ class AddEntriesDialogHelper {
|
|||||||
child: Text("Ok"),
|
child: Text("Ok"),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
child: Text(AppLocalizations.of(context)!.cancel),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -310,9 +329,7 @@ class AddEntriesDialogHelper {
|
|||||||
child: Text("Ok"),
|
child: Text("Ok"),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => {
|
onPressed: () => {Navigator.of(context).pop()},
|
||||||
Navigator.of(context).pop()
|
|
||||||
},
|
|
||||||
child: Text(AppLocalizations.of(context)!.cancel),
|
child: Text(AppLocalizations.of(context)!.cancel),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,22 +1,37 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fforte/enums/databases.dart';
|
||||||
|
import 'package:fforte/screens/excursion/exceptions/file_dialog_cancelled.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class SaveFileMethod {
|
class SaveFileMethod {
|
||||||
static Future<void> saveFile(Map<String, String> place, String fileNameLocalization, String placeID) async {
|
static Future<void> saveFile(
|
||||||
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
Map<String, String> place,
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
String fileNameLocalization,
|
||||||
String jsonPlace = jsonEncode(place);
|
DatabasesEnum dbType,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
String? selectedDirectory = await FilePicker.platform.getDirectoryPath();
|
||||||
|
|
||||||
if (selectedDirectory == null) {
|
if (selectedDirectory == null) {
|
||||||
return;
|
throw FileDialogCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
String jsonPlace = jsonEncode(place);
|
||||||
|
|
||||||
|
await prefs.setString('saveDir', selectedDirectory);
|
||||||
|
|
||||||
|
File file = File(
|
||||||
|
'$selectedDirectory/$fileNameLocalization-${dbType == DatabasesEnum.place ? place["CID"] : place["LogDat"]}.txt',
|
||||||
|
);
|
||||||
|
|
||||||
|
await file.writeAsString(jsonPlace);
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint(e.toString());
|
||||||
}
|
}
|
||||||
await prefs.setString('saveDir', selectedDirectory);
|
|
||||||
|
|
||||||
File file = File('$selectedDirectory/$fileNameLocalization-$placeID.txt');
|
|
||||||
|
|
||||||
await file.writeAsString(jsonPlace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class _ViewEntriesState extends State<ViewEntries> {
|
|||||||
Tab(text: AppLocalizations.of(context)!.map),
|
Tab(text: AppLocalizations.of(context)!.map),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
title: Text(AppLocalizations.of(context)!.viewplacesappbar),
|
title: widget.dbType == DatabasesEnum.place ? Text(AppLocalizations.of(context)!.viewplacesappbar) : Text(AppLocalizations.of(context)!.viewExcursionen) ,
|
||||||
),
|
),
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
12
pubspec.lock
12
pubspec.lock
@@ -133,10 +133,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: file_picker
|
name: file_picker
|
||||||
sha256: a222f231db4f822fc49e3b753674bda630e981873c84bf8604bceeb77fce0b24
|
sha256: "77f8e81d22d2a07d0dee2c62e1dda71dc1da73bf43bb2d45af09727406167964"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.1.7"
|
version: "10.1.9"
|
||||||
fixnum:
|
fixnum:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -174,14 +174,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.5.2"
|
version: "4.5.2"
|
||||||
flutter_file_dialog:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_file_dialog
|
|
||||||
sha256: "9344b8f07be6a1b6f9854b723fb0cf84a8094ba94761af1d213589d3cb087488"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.2"
|
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ dependencies:
|
|||||||
animations: ^2.0.11
|
animations: ^2.0.11
|
||||||
flutter_popup_card: ^0.0.5
|
flutter_popup_card: ^0.0.5
|
||||||
shared_preferences: ^2.2.2
|
shared_preferences: ^2.2.2
|
||||||
flutter_file_dialog: ^3.0.2
|
file_picker: ^10.1.9
|
||||||
file_picker: ^10.1.7
|
|
||||||
http: ^1.2.1
|
http: ^1.2.1
|
||||||
dio: ^5.4.1
|
dio: ^5.4.1
|
||||||
geocoding: ^3.0.0
|
geocoding: ^3.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user