Skip to content

Commit

Permalink
Merge pull request #4 from Y0ngg4n/dev
Browse files Browse the repository at this point in the history
Add Placemarker
  • Loading branch information
Y0ngg4n authored Nov 10, 2021
2 parents 2115f16 + 292af3d commit 91c6708
Show file tree
Hide file tree
Showing 21 changed files with 919 additions and 66 deletions.
51 changes: 40 additions & 11 deletions lib/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart';
import 'package:volt_campaigner/areas/areas_manager.dart';
import 'package:volt_campaigner/auth/login.dart';
import 'package:volt_campaigner/export/export.dart';
import 'package:volt_campaigner/flyer/flyer.dart';
import 'package:volt_campaigner/map/areas/areas_manager.dart';
import 'package:volt_campaigner/map/flyer/flyer.dart';
import 'package:volt_campaigner/map/poster_map.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand All @@ -17,13 +17,14 @@ import 'package:volt_campaigner/utils/api/area.dart';
import 'package:volt_campaigner/utils/api/flyer.dart';
import 'package:volt_campaigner/utils/api/model/area.dart';
import 'package:volt_campaigner/utils/api/model/flyer.dart';
import 'package:volt_campaigner/utils/api/model/placemark.dart';
import 'package:volt_campaigner/utils/api/model/poster.dart';
import 'package:volt_campaigner/utils/api/placemark.dart';
import 'package:volt_campaigner/utils/api/poster.dart';
import 'package:volt_campaigner/utils/api/poster_tags.dart';
import 'package:volt_campaigner/utils/tag_utils.dart';
import 'package:volt_campaigner/volunteer/volunteer.dart';

import 'areas/add_area_map.dart';
import 'map/poster/add_poster.dart';
import 'map/poster/poster_tags.dart';
import 'package:latlong2/latlong.dart';
Expand Down Expand Up @@ -64,6 +65,7 @@ class _DrawerViewState extends State<DrawerView> {
DrawerSelection drawerSelection = DrawerSelection.POSTER;

PosterModels posterInDistance = new PosterModels([]);
PlacemarkModels placemarkModels = new PlacemarkModels([]);
Timer? refreshTimer;

LatLng currentPosition = LatLng(0, 0);
Expand Down Expand Up @@ -96,7 +98,7 @@ class _DrawerViewState extends State<DrawerView> {
Future.delayed(Duration(seconds: 5), () => _refresh());
}));
refreshTimer =
Timer.periodic(Duration(seconds: 30), (Timer t) => _refresh());
Timer.periodic(Duration(seconds: 60), (Timer t) => _refresh());
}

@override
Expand All @@ -107,8 +109,8 @@ class _DrawerViewState extends State<DrawerView> {

@override
Widget build(BuildContext context) {
if (drawerSelection == DrawerSelection.POSTER
|| drawerSelection == DrawerSelection.FLYER) {
if (drawerSelection == DrawerSelection.POSTER ||
drawerSelection == DrawerSelection.FLYER) {
return Scaffold(
key: scaffoldKey,
body: SafeArea(child: _getBody()),
Expand Down Expand Up @@ -268,6 +270,7 @@ class _DrawerViewState extends State<DrawerView> {
posterMapWidgetState.currentState!.setRefreshIcon(true);
await _refreshPosterTags();
await _refreshPoster();
await _refreshPlacemarks();
if (posterMapWidgetState.currentState != null) {
posterMapWidgetState.currentState!.refresh();
posterMapWidgetState.currentState!.setRefreshIcon(false);
Expand All @@ -276,15 +279,20 @@ class _DrawerViewState extends State<DrawerView> {
for (PosterModel posterModel in posterInDistance.posterModels) {
TagUtils.fillMissingTagDetails(posterModel.posterTagsLists.posterType,
posterTagsLists.posterType);
TagUtils.fillMissingTagDetails(posterModel.posterTagsLists.posterCampaign,
TagUtils.fillMissingTagDetails(
posterModel.posterTagsLists.posterCampaign,
posterTagsLists.posterCampaign);
TagUtils.fillMissingTagDetails(posterModel.posterTagsLists.posterEnvironment,
TagUtils.fillMissingTagDetails(
posterModel.posterTagsLists.posterEnvironment,
posterTagsLists.posterEnvironment);
TagUtils.fillMissingTagDetails(posterModel.posterTagsLists.posterTargetGroups,
TagUtils.fillMissingTagDetails(
posterModel.posterTagsLists.posterTargetGroups,
posterTagsLists.posterTargetGroups);
TagUtils.fillMissingTagDetails(posterModel.posterTagsLists.posterOther,
TagUtils.fillMissingTagDetails(
posterModel.posterTagsLists.posterOther,
posterTagsLists.posterOther);
TagUtils.fillMissingTagDetails(posterModel.posterTagsLists.posterMotive,
TagUtils.fillMissingTagDetails(
posterModel.posterTagsLists.posterMotive,
posterTagsLists.posterMotive);
}
});
Expand All @@ -309,6 +317,26 @@ class _DrawerViewState extends State<DrawerView> {
});
}

_refreshPlacemarks() async {
double radius =
(prefs.get(SharedPrefsSlugs.posterRadius) ?? 100.0) as double;
bool loadAll = (prefs.get(SharedPrefsSlugs.posterLoadAll) ?? false) as bool;
PlacemarkModels placemarkModels;
if (loadAll) {
placemarkModels = await PlacemarkApiUtils.getAllPlacemarks(widget.apiToken) ??
PlacemarkModels.empty();
} else {
placemarkModels = await PlacemarkApiUtils.getPlacemarksInDistance(
currentPosition,
radius,
widget.apiToken) ??
PlacemarkModels.empty();
}
setState(() {
this.placemarkModels = placemarkModels;
});
}

_refreshPoster() async {
int hanging = (prefs.get(SharedPrefsSlugs.posterHanging) ?? 0) as int;
double radius =
Expand Down Expand Up @@ -439,6 +467,7 @@ class _DrawerViewState extends State<DrawerView> {
if (scaffoldKey.currentState != null)
scaffoldKey.currentState!.openDrawer();
},
placemarkModels: placemarkModels,
);
}

Expand Down
11 changes: 11 additions & 0 deletions lib/generated/intl/messages_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"addArea": MessageLookupByLibrary.simpleMessage("Gegend speichern"),
"addPlacemark": MessageLookupByLibrary.simpleMessage("Ort hinzufügen"),
"addPoster": MessageLookupByLibrary.simpleMessage("Plakat hinzufügen"),
"appTitle": MessageLookupByLibrary.simpleMessage("Volt Campaigner"),
"areas": MessageLookupByLibrary.simpleMessage("Gegenden"),
Expand All @@ -38,6 +39,8 @@ class MessageLookup extends MessageLookupByLibrary {
"copySuccess":
MessageLookupByLibrary.simpleMessage("Text wurde kopiert"),
"date": MessageLookupByLibrary.simpleMessage("Datum"),
"deletePlacemark": MessageLookupByLibrary.simpleMessage("Ort löschen"),
"description": MessageLookupByLibrary.simpleMessage("Beschreibung"),
"drawNearestPosterLine": MessageLookupByLibrary.simpleMessage(
"Zeichne Linie zum nächsten Plakat"),
"errorAddArea": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -75,6 +78,8 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Karte verkleinern"),
"featureZoomOutDescription": MessageLookupByLibrary.simpleMessage(
"Hier kannst du den angezeigten Bereich auf der Karte verkleinern"),
"filterMarker":
MessageLookupByLibrary.simpleMessage("Filtere Marker nach"),
"flyer": MessageLookupByLibrary.simpleMessage("Flyer"),
"flyerCustomDate":
MessageLookupByLibrary.simpleMessage("Bentzerdefiniertes Datum"),
Expand Down Expand Up @@ -106,6 +111,10 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Text wurde eingefügt"),
"placeMarkerByHand": MessageLookupByLibrary.simpleMessage(
"Ermöglicht es Plakate von Hand zu plazieren"),
"placemarkType": MessageLookupByLibrary.simpleMessage("Typ"),
"placemarkTypeMeetpoint":
MessageLookupByLibrary.simpleMessage("Treffpunkt"),
"placemarkTypeStorage": MessageLookupByLibrary.simpleMessage("Lager"),
"poster": MessageLookupByLibrary.simpleMessage("Plakate"),
"posterAdd": MessageLookupByLibrary.simpleMessage("Plakat hinzufügen"),
"posterCampaign": MessageLookupByLibrary.simpleMessage("Kampagne"),
Expand Down Expand Up @@ -147,6 +156,8 @@ class MessageLookup extends MessageLookupByLibrary {
"sureDelete": MessageLookupByLibrary.simpleMessage(
"Bist du dir sicher, dass du das löschen möchtest?"),
"time": MessageLookupByLibrary.simpleMessage("Zeit"),
"title": MessageLookupByLibrary.simpleMessage("Titel"),
"updatePlacemark": MessageLookupByLibrary.simpleMessage("Ort ändern"),
"volunteer": MessageLookupByLibrary.simpleMessage("Volunteer einladen"),
"volunteerCopy": MessageLookupByLibrary.simpleMessage(
"Oder kopiere das und sende es an den Volunteer"),
Expand Down
12 changes: 12 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MessageLookup extends MessageLookupByLibrary {
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"addArea": MessageLookupByLibrary.simpleMessage("Save Area"),
"addPlacemark": MessageLookupByLibrary.simpleMessage("Add Placemark"),
"addPoster": MessageLookupByLibrary.simpleMessage("Add Poster"),
"appTitle": MessageLookupByLibrary.simpleMessage("Volt Campaigner"),
"areas": MessageLookupByLibrary.simpleMessage("Areas"),
Expand All @@ -34,6 +35,9 @@ class MessageLookup extends MessageLookupByLibrary {
"colorMarker": MessageLookupByLibrary.simpleMessage("Color marker by"),
"copySuccess": MessageLookupByLibrary.simpleMessage("Copied text"),
"date": MessageLookupByLibrary.simpleMessage("Date"),
"deletePlacemark":
MessageLookupByLibrary.simpleMessage("Delete Placemark"),
"description": MessageLookupByLibrary.simpleMessage("Description"),
"drawNearestPosterLine":
MessageLookupByLibrary.simpleMessage("Draw line to nearest Poster"),
"errorAddArea":
Expand Down Expand Up @@ -68,6 +72,7 @@ class MessageLookup extends MessageLookupByLibrary {
"featureZoomOut": MessageLookupByLibrary.simpleMessage("Zoom out"),
"featureZoomOutDescription": MessageLookupByLibrary.simpleMessage(
"Here you can make the map smaller"),
"filterMarker": MessageLookupByLibrary.simpleMessage("Fiter marker by"),
"flyer": MessageLookupByLibrary.simpleMessage("Flyer"),
"flyerCustomDate": MessageLookupByLibrary.simpleMessage("Custom Date"),
"flyerLoadAll": MessageLookupByLibrary.simpleMessage("Load all Flyers"),
Expand Down Expand Up @@ -96,6 +101,10 @@ class MessageLookup extends MessageLookupByLibrary {
"pasteSuccess": MessageLookupByLibrary.simpleMessage("Pasted text"),
"placeMarkerByHand":
MessageLookupByLibrary.simpleMessage("Place marker by hand"),
"placemarkType": MessageLookupByLibrary.simpleMessage("Type"),
"placemarkTypeMeetpoint":
MessageLookupByLibrary.simpleMessage("Meetpoint"),
"placemarkTypeStorage": MessageLookupByLibrary.simpleMessage("Storage"),
"poster": MessageLookupByLibrary.simpleMessage("Poster"),
"posterAdd": MessageLookupByLibrary.simpleMessage("Add Poster"),
"posterCampaign": MessageLookupByLibrary.simpleMessage("Kampagne"),
Expand Down Expand Up @@ -135,6 +144,9 @@ class MessageLookup extends MessageLookupByLibrary {
"sureDelete": MessageLookupByLibrary.simpleMessage(
"Bist du dir sicher, dass du das löschen möchtest?"),
"time": MessageLookupByLibrary.simpleMessage("Time"),
"title": MessageLookupByLibrary.simpleMessage("Titel"),
"updatePlacemark":
MessageLookupByLibrary.simpleMessage("Update Placemark"),
"volunteer": MessageLookupByLibrary.simpleMessage("Volunteer invite"),
"volunteerCopy": MessageLookupByLibrary.simpleMessage(
"Or copy this and send it to the Volunteer"),
Expand Down
90 changes: 90 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion lib/l10n/intl_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"max": "Maximum",
"hanging": "Hängend",
"colorMarker": "Marker einfärben nach",
"filterMarker": "Filtere Marker nach",
"featureAddPosterDescription": "Hier kannst du ein neues Plakat hinzufügen und verschiedene Tags vergeben um es uns einfacher zu machen zu wissen wo welches Plakat hängt.",
"featureSearchDescription": "Hier kannst du nach einer Stadt oder nach einem Standort suchen.",
"featureLimit": "Erlaubte Plakate",
Expand All @@ -79,5 +80,13 @@
"featureZoomOut": "Karte verkleinern",
"featureZoomOutDescription": "Hier kannst du den angezeigten Bereich auf der Karte verkleinern",
"featureRecordFlyer": "Route aufnehmen",
"featureRecordFlyerDescription": "Hier kannst du eine Route aufnehmen während du gerade am Flyer verteilen bist. Dadurch können andere sehen wo du schon warst. Achtung! Hierfür darfst du deinen Bildschirm nicht ausschalten, da wir sonst keinen Zugriff auf deine GPS Daten haben! Wir empfehlen dir den Bildschirm abzudunkeln und eine Powerbank mitzunehmen."
"featureRecordFlyerDescription": "Hier kannst du eine Route aufnehmen während du gerade am Flyer verteilen bist. Dadurch können andere sehen wo du schon warst. Achtung! Hierfür darfst du deinen Bildschirm nicht ausschalten, da wir sonst keinen Zugriff auf deine GPS Daten haben! Wir empfehlen dir den Bildschirm abzudunkeln und eine Powerbank mitzunehmen.",
"addPlacemark": "Ort hinzufügen",
"updatePlacemark": "Ort ändern",
"deletePlacemark": "Ort löschen",
"placemarkType": "Typ",
"title": "Titel",
"description": "Beschreibung",
"placemarkTypeStorage": "Lager",
"placemarkTypeMeetpoint": "Treffpunkt"
}
11 changes: 10 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"max": "Maximum",
"hanging": "Hanging",
"colorMarker": "Color marker by",
"filterMarker": "Fiter marker by",
"featureAddPosterDescription": "Here you can add posters and give them tags so we can identify what posters are hanging where",
"featureSearchDescription": "Here you can search for a city or a location",
"featureLimit": "Allowed Posters",
Expand All @@ -79,5 +80,13 @@
"featureZoomOut": "Zoom out",
"featureZoomOutDescription": "Here you can make the map smaller",
"featureRecordFlyer": "Record route",
"featureRecordFlyerDescription": "Here you can record your route while flyering. Through this others can see where you allready have been. Attention! Dont lock your Display, because then we dont have access to the GPS data! We recommend to darken your display and take a powerbank with you."
"featureRecordFlyerDescription": "Here you can record your route while flyering. Through this others can see where you allready have been. Attention! Dont lock your Display, because then we dont have access to the GPS data! We recommend to darken your display and take a powerbank with you.",
"addPlacemark": "Add Placemark",
"updatePlacemark": "Update Placemark",
"deletePlacemark": "Delete Placemark",
"placemarkType": "Type",
"title": "Titel",
"description": "Description",
"placemarkTypeStorage": "Storage",
"placemarkTypeMeetpoint": "Meetpoint"
}
2 changes: 1 addition & 1 deletion lib/areas/add_area.dart → lib/map/areas/add_area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:latlong2/latlong.dart';
import 'package:volt_campaigner/areas/add_area_map.dart';
import 'package:volt_campaigner/map/areas/add_area_map.dart';
import 'package:volt_campaigner/utils/api/model/area.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:uuid/uuid.dart';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:latlong2/latlong.dart';
import 'package:volt_campaigner/areas/add_area.dart';
import 'package:volt_campaigner/map/areas/add_area.dart';
import 'package:volt_campaigner/utils/api/area.dart';
import 'package:volt_campaigner/utils/api/model/area.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions lib/map/map_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class MapSettings {
static getMarkerClusterLayerOptions(OnMarkerTap onMarkerTap,
List<Marker> markers) {
return MarkerClusterLayerOptions(
disableClusteringAtZoom: 15,
onMarkerTap: (marker) => onMarkerTap(marker),
size: Size(40, 40),
fitBoundsOptions: FitBoundsOptions(
Expand Down
Loading

0 comments on commit 91c6708

Please sign in to comment.