Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Make Waypoints in RoutingView draggable #349

Merged
merged 45 commits into from
Dec 8, 2023
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
95a293e
create branch
kruegercharles Oct 30, 2023
c2eb66c
stash
kruegercharles Nov 3, 2023
fea7f88
basic dragging works now
kruegercharles Nov 6, 2023
fcb82c5
keep order of waypoints when dragging
kruegercharles Nov 6, 2023
c211f3e
polishing
kruegercharles Nov 10, 2023
6a1bf27
add basic functionality to drag waypoint to edge of screen
kruegercharles Nov 10, 2023
4e3efbd
Add screen edge detection and map movement when dragging waypoints
kruegercharles Nov 10, 2023
011ded7
Adjust screen edge dimensions and add dragWaypoint function
kruegercharles Nov 10, 2023
04dd319
determine waypointtype and set icon accordingly
kruegercharles Nov 10, 2023
4b122ce
remove old waypoint from search history after dragging
kruegercharles Nov 10, 2023
7fc379e
polishing
kruegercharles Nov 10, 2023
1b50e08
Remove unused variables draggedWaypointCoords
kruegercharles Nov 10, 2023
ee4e9a1
move camera continualy when at edge
adeveloper-wq Nov 10, 2023
d45aae6
improve checking if waypoint is at tapped position
kruegercharles Nov 15, 2023
54ca681
Refactor screen edge enum and update map movement
kruegercharles Nov 17, 2023
9119654
Hide dragged waypoint icon when loading
kruegercharles Nov 17, 2023
dafeae3
restore old waypoint when dragging out of city boundry
kruegercharles Nov 17, 2023
0890fdb
add resetDraggin()
kruegercharles Nov 17, 2023
e6a7341
polishing
kruegercharles Nov 17, 2023
fadb3cc
refactore moving after dragging waypoint
kruegercharles Nov 17, 2023
51cb9f4
polishing
kruegercharles Nov 17, 2023
5216f07
reset currentScreenEdge before moving dragged waypoint
kruegercharles Nov 17, 2023
863052b
polishing
kruegercharles Nov 20, 2023
2fdaebe
polishing
kruegercharles Nov 20, 2023
b0f4b9b
fix inaccuracy with many waypoints
kruegercharles Nov 20, 2023
71022f9
tweak screen edge detection
kruegercharles Nov 20, 2023
0a3a1e2
polishing
kruegercharles Nov 20, 2023
3a82530
reduce mapMoveSpeed when dragging to edge
kruegercharles Dec 1, 2023
2c13d69
remove ppi and reduce distance to trigger dragged waypoint
kruegercharles Dec 1, 2023
08e47c3
add short delay to throttle mapmovement
kruegercharles Dec 1, 2023
73cf3c1
implement easeTo with iOS
kruegercharles Dec 1, 2023
96c23af
speed up mapmovment when zoomed out
kruegercharles Dec 1, 2023
7a13a15
set lowest bound for zoomspeedup and tweak for ios
kruegercharles Dec 1, 2023
c87b907
set minimum zoomspeedup to 0.3
kruegercharles Dec 1, 2023
03325ae
add early return to getWaypointType
kruegercharles Dec 1, 2023
f879cd8
add early returns
kruegercharles Dec 1, 2023
7a7b2e1
Set icon center on drag
PaulPickhardt Dec 1, 2023
fb80fd9
Start auxiliary marker animation
PaulPickhardt Dec 4, 2023
900a003
remove animation from circles and keep the distances the same
kruegercharles Dec 4, 2023
4b582d2
add ability to cancel dragging
kruegercharles Dec 4, 2023
5d48b8f
don't move map when using cancel button and highlight cancel button w…
kruegercharles Dec 4, 2023
55397fb
fix position cancel button to work on all device sizes
kruegercharles Dec 4, 2023
66326c9
Add comment on variable
PaulPickhardt Dec 5, 2023
d8bf46c
Make cancelButtonIconSize constant
PaulPickhardt Dec 5, 2023
864c330
Center cancel button
PaulPickhardt Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Hide dragged waypoint icon when loading
kruegercharles committed Dec 1, 2023
commit 9119654de04cfd8bd29e31e78d02c1269b5a6e64
2 changes: 2 additions & 0 deletions lib/routing/models/drag_waypoint.dart
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ enum WaypointType {
waypoint,
}

/// The icon path of a waypoint type.
extension IconPath on WaypointType {
String get iconPath {
switch (this) {
@@ -20,6 +21,7 @@ extension IconPath on WaypointType {
}
}

/// Determines whether the waypoint is a start, destination or waypoint in between.
WaypointType getWaypointType(List<Waypoint> list, Waypoint waypoint) {
if (list.last == waypoint) {
return WaypointType.destination;
19 changes: 13 additions & 6 deletions lib/routing/views/map.dart
Original file line number Diff line number Diff line change
@@ -135,6 +135,9 @@ class RoutingMapViewState extends State<RoutingMapView> with TickerProviderState
/// The current screen edge the user is dragging the waypoint to, if any.
ScreenEdge currentScreenEdge = ScreenEdge.none;

/// Hide the icon of a dragged waypoint while loading when adding a new waypoint.
bool hideDragWaypoint = false;

/// The index in the list represents the layer order in z axis.
final List layerOrder = [
VeloRoutesLayer.layerId,
@@ -800,8 +803,8 @@ class RoutingMapViewState extends State<RoutingMapView> with TickerProviderState
tutorial.complete("priobike.tutorial.draw-waypoints");
final waypoint = Waypoint(latitude, longitude, address: address);
int index;
// if the wayPointTapped isn't null, the user is dragging a waypoint
// and the waypoint must be inserted at the same index
// if the draggedWaypoint isn't null, the user is dragging a waypoint
// and the waypoint must be reinserted at the same index as before the dragging
// otherwise the user is adding a waypoint by tapping on the map
// and the waypoint must be appended to end of list
if (draggedWaypoint != null && draggedWaypointIndex != null) {
@@ -1063,7 +1066,10 @@ class RoutingMapViewState extends State<RoutingMapView> with TickerProviderState
}
final point = ScreenCoordinate(x: x, y: y);

// add new waypoint at tapped position.
// hide the dragged waypoint icon while loading when adding the new waypoint
hideDragWaypoint = true;

// add new waypoint at the released position.
await addWaypoint(point);
} else {
animationController.reverse();
@@ -1076,6 +1082,7 @@ class RoutingMapViewState extends State<RoutingMapView> with TickerProviderState
draggedWaypoint = null;
draggedWaypointIndex = null;
draggedWaypointType = null;
hideDragWaypoint = false;
currentScreenEdge = ScreenEdge.none;
},
behavior: HitTestBehavior.translucent,
@@ -1164,7 +1171,7 @@ class RoutingMapViewState extends State<RoutingMapView> with TickerProviderState
),
),
// for dragging waypoints
if (dragPosition != null && draggedWaypointType != null)
if (dragPosition != null && draggedWaypointType != null && !hideDragWaypoint)
Stack(
children: [
AnimatedPositioned(
@@ -1173,8 +1180,8 @@ class RoutingMapViewState extends State<RoutingMapView> with TickerProviderState
left: dragPosition!.dx,
top: dragPosition!.dy,
child: SizedBox(
width: 24 * 1.5,
height: 24 * 1.5,
width: 24 * 1.3,
height: 24 * 1.3,
child: Image.asset(
draggedWaypointType!.iconPath,
fit: BoxFit.contain,