Skip to content

Commit

Permalink
add rotateAnimatedRaw, isAnimating
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed Dec 12, 2023
1 parent 12a3684 commit af9bb8d
Showing 1 changed file with 54 additions and 15 deletions.
69 changes: 54 additions & 15 deletions lib/src/map/controller/map_controller_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,39 @@ class MapControllerImpl extends ValueNotifier<_MapControllerState>
_animationController.forward(from: 0);

Check warning on line 584 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L584

Added line #L584 was not covered by tests
}

void rotateAnimatedRaw(

Check warning on line 587 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L587

Added line #L587 was not covered by tests
double newRotation, {
required Offset offset,
required Duration duration,
required Curve curve,
required bool hasGesture,
required MapEventSource source,
}) {
// cancel all ongoing animation
_animationController.stop();
_resetAnimations();

Check warning on line 597 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L596-L597

Added lines #L596 - L597 were not covered by tests

if (newRotation == camera.rotation) return;

Check warning on line 599 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L599

Added line #L599 was not covered by tests

// create the new animation
_rotationAnimation = Tween<double>(begin: camera.rotation, end: newRotation)
.chain(CurveTween(curve: curve))
.animate(_animationController);

Check warning on line 604 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L602-L604

Added lines #L602 - L604 were not covered by tests

_animationController.duration = duration;
_animationHasGesture = hasGesture;
_animationOffset = offset;

Check warning on line 608 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L606-L608

Added lines #L606 - L608 were not covered by tests

// start the animation from its start
_animationController.forward(from: 0);

Check warning on line 611 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L611

Added line #L611 was not covered by tests
}

void stopAnimationRaw({bool canceled = true}) {
if (_animationController.isAnimating) {
_animationController.stop(canceled: canceled);
}
if (isAnimating) _animationController.stop(canceled: canceled);

Check warning on line 615 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L614-L615

Added lines #L614 - L615 were not covered by tests
}

bool get isAnimating => _animationController.isAnimating;

Check warning on line 618 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L618

Added line #L618 was not covered by tests

void _resetAnimations() {
_moveAnimation = null;
_rotationAnimation = null;
Expand Down Expand Up @@ -692,22 +719,34 @@ class MapControllerImpl extends ValueNotifier<_MapControllerState>
}

// animated movement
if (_moveAnimation != null) {
if (_rotationAnimation != null) {
moveAndRotateRaw(
_moveAnimation?.value ?? camera.center,
_zoomAnimation?.value ?? camera.zoom,
_rotationAnimation!.value,
hasGesture: _animationHasGesture,

Check warning on line 728 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L722-L728

Added lines #L722 - L728 were not covered by tests
source: MapEventSource.mapController,
offset: _animationOffset,

Check warning on line 730 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L730

Added line #L730 was not covered by tests
);
} else {
moveRaw(
_moveAnimation!.value,
_zoomAnimation?.value ?? camera.zoom,
hasGesture: _animationHasGesture,

Check warning on line 736 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L733-L736

Added lines #L733 - L736 were not covered by tests
source: MapEventSource.mapController,
offset: _animationOffset,

Check warning on line 738 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L738

Added line #L738 was not covered by tests
);
}
return;
}

// animated rotation
if (_rotationAnimation != null) {
moveAndRotateRaw(
_moveAnimation?.value ?? camera.center,
_zoomAnimation?.value ?? camera.zoom,
rotateRaw(
_rotationAnimation!.value,
hasGesture: _animationHasGesture,

Check warning on line 748 in lib/src/map/controller/map_controller_impl.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/map/controller/map_controller_impl.dart#L745-L748

Added lines #L745 - L748 were not covered by tests
source: MapEventSource.mapController,
offset: _animationOffset,
);
} else {
moveRaw(
_moveAnimation?.value ?? camera.center,
_zoomAnimation?.value ?? camera.zoom,
hasGesture: _animationHasGesture,
source: MapEventSource.mapController,
offset: _animationOffset,
);
}
}
Expand Down

0 comments on commit af9bb8d

Please sign in to comment.