reduce method

  1. @override
StageScene reduce(
  1. StageScene state,
  2. StageMsg msg
)

Fold a message into the value and return the NEXT value. PURE.

Implementation

@override
StageScene reduce(StageScene state, StageMsg msg) => switch (msg) {
      StageTaken() => StageScene(
          tag: msg.tag,
          widget: msg.widget,
          origin: msg.origin,
          originContainer: msg.originContainer,
          display: state.display,
          displayContainer: state.displayContainer,
          aspectRatio: msg.aspectRatio,
          displayConfig: state.displayConfig,
          config: msg.config,
          gestureBuilder: state.gestureBuilder,
          perspective: msg.perspective,
          backgroundColor: msg.backgroundColor,
          onEnd: msg.onEnd,
        ).inMode(msg.mode),
      ModeSet(:final mode) => state.inMode(mode),
      OriginPointed(:final origin) =>
        state._with(origin: origin, originPointed: true),
      OriginMeasured(:final origin) => state._with(origin: origin),
      WidgetShown(:final widget) => state._with(widget: widget),
      AspectRatioSet(:final aspectRatio) =>
        state._with(aspectRatio: aspectRatio),
      BackgroundSet(:final color) => state._with(backgroundColor: color),
      GestureBuilderSet(:final builder) =>
        state._with(gestureBuilder: builder),
      OnEndSet(:final onEnd) => state._with(onEnd: onEnd),
      FlightLanded(:final flight) => switch (flight.kind) {
          .dismissing || .effect => const StageScene(),
          .opening || .changingMode => state,
        },
      FlightTook() ||
      InteractionBegan() ||
      InteractionEnded() ||
      OriginGestureSet() ||
      HybridDrivingSet() ||
      SendDisplaced() ||
      SendArrived() ||
      SendsRecalled() ||
      SendGone() =>
        state,
    };