presentationFor method
The presentation for anchorKey under the active guide, or null when no
guide is active or no step targets this anchor.
Implementation
ShowcasePresentation? presentationFor(
String anchorKey,
BuildContext anchorContext,
) {
final state = _orchestrator.state;
if (state == null) return null;
final scope = state.campaign.config.scopeFor(state.payload);
final config = state.config;
// The overlay the tooltip floats over, not the anchor's MediaQuery: inside
// an app that scales its tree the two differ, and the tooltip would be
// scaled for a narrower screen than it is drawn on. Uses the anchor's own
// context: the registry key is only attached once this presentation is
// built, so on the first build its context is still null.
final designScale = campaignCanvasDesignScale(
viewportWidth: overlayViewportWidthOf(anchorContext),
designWidth: config.designWidth,
);
final disableBarrier =
config.outsideTapBehavior == OutsideTapBehavior.nothing;
if (config is TooltipGuideConfig) {
final step = _firstWhere(config.steps, (s) => s.anchorKey == anchorKey);
if (step == null) return null;
final canvas = step.canvas;
return ShowcasePresentation(
container: EngageActionContextScope(
actionContext: _actionContext(state),
child: VariableScopeProvider(
scope: scope,
child: GuideCanvasTooltipSurface(
canvas: canvas,
designWidth: config.designWidth,
cornerRadius: step.cornerRadius,
borderWidth: step.borderWidth,
borderColor: step.borderColor,
shadow: step.shadow,
showArrow: step.showArrow,
arrowSize: step.arrowSize,
side: guideCanvasTooltipSide(step.placement),
onActions: handleCanvasActions,
),
),
),
// Tooltip = no dim (RN renders the bubble over a transparent scrim).
overlayColor: const Color(0x00000000),
overlayOpacity: 0,
targetShapeBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
targetBorderRadius: BorderRadius.circular(8),
targetPadding: EdgeInsets.zero,
targetGlowColor: const Color(0x00000000),
targetGlowWidth: 0,
tooltipPosition: _tooltipPosition(step.placement),
targetTooltipGap: step.gap * designScale,
disableBarrierInteraction: disableBarrier,
);
}
if (config is SpotlightGuideConfig) {
final step = _firstWhere(config.steps, (s) => s.anchorKey == anchorKey);
if (step == null) return null;
return _spotlightPresentation(
step: step,
config: config,
scope: scope,
designScale: designScale,
disableBarrier: disableBarrier,
);
}
return null;
}