Skip to content

Interaction and lifecycle modifiers - #27

Merged
colemancda merged 7 commits into
masterfrom
feature/interaction
Jul 23, 2026
Merged

Interaction and lifecycle modifiers#27
colemancda merged 7 commits into
masterfrom
feature/interaction

Conversation

@colemancda

Copy link
Copy Markdown
Member

Second parity tier: gestures and lifecycle. Adds closure-carrying modifiers, which register a callback against the resolve context and embed its id in the emitted node — wired to Compose clickable/DisposableEffect/LaunchedEffect.

New modifiers

  • .onTapGesture — folds to Modifier.clickable
  • .onAppear / .onDisappear — a DisposableEffect keyed within the node's identity scope, so appear fires once on entry and disappear on exit, surviving recomposition
  • .task — launched once on appear as a Swift Task (v1 does not cancel on disappear)
  • .onChange(of:) — fires when a value token changes between evaluations (skipping the initial composition)
  • .disabled(_:) — dims content; Button also drops interactivity via its enabled parameter

Core change

Modifiers previously emitted a context-free node. Added _ContextualModifierProvider (preferred over the plain _modifierNode property when present) and _CallbackModifier, so a modifier can register a callback at resolve time. Additive — existing modifiers and conformers are untouched.

Verification

  • swift test — 4 new emission tests (incl. invoking a registered tap callback), 39 total passing
  • Emulator (new Interaction screen): tap counter increments, onAppear fires exactly once across recompositions, onChange counts slider changes during a drag, disabled button is dimmed and non-interactive then flips to enabled

Deferred

.task cancellation on disappear; gesture variants beyond tap (drag/long-press). Environment-scoped .disabled propagation (applies where set / directly on a Button for now).

@colemancda
colemancda merged commit 41683d1 into master Jul 23, 2026
6 checks passed
@colemancda
colemancda deleted the feature/interaction branch July 23, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant