added tracking function. Not testet on a walk yet. Also the notifiation doesnt work
time forgot to save tracking file
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:fforte/enums/databases.dart';
|
||||
import 'package:fforte/screens/addCam/exceptions/location_disabled_exception.dart';
|
||||
import 'package:fforte/screens/addCam/exceptions/location_forbidden_exception.dart';
|
||||
import 'package:fforte/screens/addCam/services/geolocator_service.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/anzahlen.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/bima_nutzer.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/hinweise.dart';
|
||||
@@ -7,13 +10,17 @@ import 'package:fforte/screens/excursion/widgets/hund_u_leine.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/letzter_niederschlag.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/spur_gefunden.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/strecke_u_spurbedingungen.dart';
|
||||
import 'package:fforte/screens/excursion/widgets/tracking.dart';
|
||||
import 'package:fforte/screens/helper/add_entries_dialog_helper.dart';
|
||||
import 'package:fforte/screens/helper/snack_bar_helper.dart';
|
||||
import 'package:fforte/screens/sharedMethods/check_required.dart';
|
||||
import 'package:fforte/screens/sharedMethods/save_template.dart';
|
||||
import 'package:fforte/screens/sharedWidgets/datum.dart';
|
||||
import 'package:fforte/screens/sharedWidgets/var_text_field.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
class ExcursionMain extends StatefulWidget {
|
||||
final bool isTemplate;
|
||||
@@ -34,6 +41,18 @@ class ExcursionMain extends StatefulWidget {
|
||||
class _ExcursionMainState extends State<ExcursionMain> {
|
||||
int currentStep = 0;
|
||||
late bool isTemplate;
|
||||
Position currentPosition = Position(
|
||||
longitude: 10.0,
|
||||
latitude: 51.0,
|
||||
timestamp: DateTime.now(),
|
||||
accuracy: 0.0,
|
||||
altitude: 0.0,
|
||||
heading: 0.0,
|
||||
speed: 0.0,
|
||||
speedAccuracy: 0.0,
|
||||
altitudeAccuracy: 0.0,
|
||||
headingAccuracy: 0.0,
|
||||
);
|
||||
|
||||
// all TextEditingController because its easier
|
||||
Map<String, Map<String, dynamic>> rmap = {
|
||||
@@ -55,6 +74,7 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
"BimaAGV": {"controller": TextEditingController(), "required": false},
|
||||
|
||||
// Step 2
|
||||
"Weg": {"controller": TextEditingController(), "required": false},
|
||||
"Wetter": {"controller": TextEditingController(), "required": false},
|
||||
"Temperat": {"controller": TextEditingController(), "required": false},
|
||||
"RegenVor": {"controller": TextEditingController(), "required": false},
|
||||
@@ -100,6 +120,27 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
GeolocatorService.deteterminePosition()
|
||||
.then((result) => currentPosition = result)
|
||||
.catchError((error) {
|
||||
if (error is LocationDisabledException) {
|
||||
if (mounted) {
|
||||
SnackBarHelper.showSnackBarMessage(
|
||||
context,
|
||||
AppLocalizations.of(context)!.locationDisabled,
|
||||
);
|
||||
}
|
||||
} else if (error is LocationForbiddenException) {
|
||||
if (mounted) {
|
||||
SnackBarHelper.showSnackBarMessage(
|
||||
context,
|
||||
AppLocalizations.of(context)!.locationForbidden,
|
||||
);
|
||||
}
|
||||
}
|
||||
return currentPosition;
|
||||
});
|
||||
|
||||
if (widget.existingData?.isNotEmpty ?? false) {
|
||||
for (var key in widget.existingData!.keys) {
|
||||
rmap[key]!["controller"]!.text =
|
||||
@@ -130,7 +171,6 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
return puff;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Step> getSteps() => [
|
||||
@@ -253,6 +293,27 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
title: Text(AppLocalizations.of(context)!.umstaendeUndAktionen),
|
||||
content: Column(
|
||||
children: [
|
||||
// ---------- Tracking
|
||||
ElevatedButton(
|
||||
onPressed:
|
||||
() => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Tracking(
|
||||
weg: rmap["Weg"]!["controller"]!,
|
||||
startPosition: LatLng(
|
||||
currentPosition.latitude,
|
||||
currentPosition.longitude,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
child: Text(AppLocalizations.of(context)!.tracking),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// ---------- Weather
|
||||
VarTextField(
|
||||
textController: rmap["Wetter"]!["controller"]!,
|
||||
@@ -390,7 +451,6 @@ class _ExcursionMainState extends State<ExcursionMain> {
|
||||
currentStep += 1;
|
||||
});
|
||||
} else {
|
||||
|
||||
if (widget.isSent) {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user