added map tab in view cams

This commit is contained in:
nico
2024-05-01 19:29:32 +02:00
parent 3894d9aefe
commit de7ff75fd6
4 changed files with 62 additions and 27 deletions

View File

@@ -1,5 +1,4 @@
todo: todo:
sandorte ansehen in karte (extra tab)
Platzierung garnix als standart aber pflichtfeld Platzierung garnix als standart aber pflichtfeld
fix send file to server fix send file to server
im englischen abändern im englischen abändern
@@ -10,6 +9,7 @@ eintrg in db wenn http response (in sent column)
not to do: not to do:
sandorte ansehen in karte (extra tab)
einzelnen eintrag löschen einzelnen eintrag löschen
zurückfeld in datenansicht zurückfeld in datenansicht
maybe auch vorschläge aus templates in dropdown menüs anzeigen maybe auch vorschläge aus templates in dropdown menüs anzeigen

View File

@@ -140,11 +140,6 @@ class _VarTextFieldState extends State<VarTextField> {
], ],
); );
} }
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
value: item,
child: Text(item),
);
} }
// Karte // Karte
@@ -166,9 +161,7 @@ class Karte extends StatefulWidget {
} }
class KarteState extends State<Karte> { class KarteState extends State<Karte> {
List<Marker> markers = [ List<Marker> markers = [ ];
const Marker(point: LatLng(0, 0), child: Icon(Icons.location_on))
];
LatLng? selectedPosition; LatLng? selectedPosition;
Position? updatedPosition; Position? updatedPosition;
bool saveVisible = false; bool saveVisible = false;

View File

@@ -1,10 +1,10 @@
import 'package:fforte/addCam/add_cam_main.dart'; import 'package:fforte/addCam/add_cam_main.dart';
import 'package:fforte/other/db_helper.dart'; import 'package:fforte/other/db_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:latlong2/latlong.dart';
// * Site that shows all entries in the databases // * Site that shows all entries in the databases
class ViewCams extends StatefulWidget { class ViewCams extends StatefulWidget {
@@ -18,6 +18,7 @@ class _ViewCamsState extends State<ViewCams> {
// var declaration // var declaration
late Future<List<Map<String, dynamic>>> place; late Future<List<Map<String, dynamic>>> place;
late Future<List<Map<String, dynamic>>> templates; late Future<List<Map<String, dynamic>>> templates;
late List<Marker> markers;
// loads the entries // loads the entries
@override @override
@@ -106,14 +107,13 @@ class _ViewCamsState extends State<ViewCams> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DefaultTabController( return DefaultTabController(
length: 2, length: 3,
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
bottom: TabBar(tabs: [ bottom: TabBar(tabs: [
Tab(text: AppLocalizations.of(context)!.completed), Tab(text: AppLocalizations.of(context)!.completed),
Tab( Tab(text: AppLocalizations.of(context)!.uncompleted,),
text: AppLocalizations.of(context)!.uncompleted, Tab(text: AppLocalizations.of(context)!.map,),
)
]), ]),
title: Text(AppLocalizations.of(context)!.viewplacesappbar)), title: Text(AppLocalizations.of(context)!.viewplacesappbar)),
body: TabBarView( body: TabBarView(
@@ -137,28 +137,32 @@ class _ViewCamsState extends State<ViewCams> {
), ),
body: Column( body: Column(
children: [ children: [
const SizedBox(height: 10,), const SizedBox(
height: 10,
),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( Row(
children: [ children: [
const SizedBox(width: 10,), const SizedBox(
Text( width: 10,
style: const TextStyle(
decoration: TextDecoration.underline
), ),
AppLocalizations.of(context)!.placedata), Text(
style: const TextStyle(
decoration: TextDecoration.underline),
AppLocalizations.of(context)!.placedata),
], ],
), ),
Row( Row(
children: [ children: [
Text( Text(
style: const TextStyle( style: const TextStyle(
decoration: TextDecoration.underline decoration: TextDecoration.underline),
), AppLocalizations.of(context)!.sent),
AppLocalizations.of(context)!.sent), const SizedBox(
const SizedBox(width: 10,), width: 10,
),
], ],
), ),
], ],
@@ -260,6 +264,44 @@ class _ViewCamsState extends State<ViewCams> {
), ),
); );
} }
}),
FutureBuilder(
future: place,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
} else if (snapshot.hasError) {
return Text("Error ${snapshot.error}");
} else {
List<Map<String, dynamic>> place = snapshot.data!;
markers = snapshot.data!.map((e) {
return Marker(
width: 80.0,
height: 80.0,
point: LatLng(double.parse(e['DECLAT'].toString()), double.parse(e['DECLNG'].toString())),
child: Column(
children: [
const Icon(Icons.location_on, color: Colors.red,),
Text("ID: ${e['ID'].toString()}", style: const TextStyle(color: Colors.black),)
],
));
}).toList();
return FlutterMap(
options: MapOptions(
initialCenter: markers.isEmpty ? const LatLng(50, 10) : markers.first.point,
interactionOptions: const InteractionOptions(
flags: InteractiveFlag.pinchZoom |
InteractiveFlag.drag |
InteractiveFlag.pinchMove)),
children: [
TileLayer(
urlTemplate:
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
),
MarkerLayer(markers: markers)
]);
}
}) })
], ],
)), )),

View File

@@ -50,4 +50,4 @@
20 apr 1h 30 min 20 apr 1h 30 min
24 apr 5h 24 apr 5h
30 apr 4h 15 min 30 apr 4h 15 min
1 mai 4h 1 mai 4h