seamCall function

Node seamCall(
  1. Node root,
  2. Node call
)

The instance's root as shown at its call (root and call each as shown in their own scope): one box with the call's size and placement (its layout but for padding), visible the AND of both, opacity their product, the call's pointer reactions after the root's and the call's behaviors over the root's, key by key.

Implementation

Node seamCall(Node root, Node call) {
  // A size or a bound the root binds (`h={screen.height - 236}`, a dialog's
  // `maxHeight={screen.height - 32}`) and the call does not is the root's:
  // the call's is what the expansion copied from the root's JSON (a 0
  // standing for the bound value, or nothing), and the root's binding was
  // lost under it (a height of 0, a dialog taller than the window).
  bool binds(Node n, String key) => n.bind.keys.any((k) => k == 'layout.$key' || k.startsWith('layout.$key.'));
  bool own(String key) => binds(root, key) && !binds(call, key);
  final layout = call.layout.copyWith(
    padding: root.layout.padding,
    width: own('width') ? root.layout.width : null,
    height: own('height') ? root.layout.height : null,
    // So are its limits when the call writes none (`Column w=fill
    // maxWidth=368` at a definition's root caps every call that fills).
    constraints: own('constraints') || (call.layout.constraints.isEmpty && !root.layout.constraints.isEmpty) ? root.layout.constraints : null,
    // The root's shape (`Stack w=fill aspectRatio=1`, a sleeve's artwork)
    // when the call gives none: a call that hugs its height was 0 tall.
    aspectRatio: call.layout.aspectRatio == null && root.layout.aspectRatio != null ? () => root.layout.aspectRatio : null,
  );
  final reactions = [...root.actions, ...call.actions.where((r) => r.trigger.type.name != 'event')];
  var out = root.copyWith(
    layout: layout,
    visible: root.visible && call.visible,
    opacity: root.opacity * call.opacity,
    actions: reactions.length == root.actions.length ? root.actions : reactions,
  );
  if (call.behaviors != Behaviors.none) {
    final j = <String, Object?>{};
    root.behaviors.writeTo(j);
    call.behaviors.writeTo(j);
    out = out.copyWith(behaviors: Behaviors.fromJson(j));
  }
  return out;
}