apply method

  1. @override
void apply(
  1. double progress,
  2. RouteNode incoming,
  3. RouteNode? outgoing
)
override

Poses both sides at progress by writing onto the routes, whose size is the region being routed. outgoing is null on a push, where nothing is leaving and the covered route is its Backdrop's to pose. Runs once when the navigation starts and once per tick after the clock moves, so rendering always sees the pose.

Implementation

@override
void apply(progress, incoming, outgoing) {
  final covering = progress < swapAt;
  incoming.opacity = covering ? 0 : 1;
  outgoing?.opacity = covering ? 1 : 0;

  final double sweep;

  if (covering) {
    sweep = progress / swapAt;
  } else if (swapAt < 1) {
    sweep = (progress - swapAt) / (1 - swapAt);
  } else {
    sweep = 1;
  }

  final size = incoming.size;
  final width = size.x;
  final height = size.y;
  final position = chrome.position;

  switch (direction) {
    case .right:
      position.setValues(covering ? (sweep - 1) * width : sweep * width, 0);

    case .left:
      position.setValues(covering ? width - sweep * width : -sweep * width, 0);

    case .down:
      position.setValues(0, covering ? (sweep - 1) * height : sweep * height);

    case .up:
      position.setValues(0, covering ? height - sweep * height : -sweep * height);
  }
}