Skip to content

Implement ToggleStyle protocol and configuration - #529

Open
gurmeherchawla wants to merge 16 commits into
skiptools:mainfrom
Clockworks-Solutions:feature/toggle-style-protocol
Open

gurmeherchawla wants to merge 16 commits into
skiptools:mainfrom
Clockworks-Solutions:feature/toggle-style-protocol

Conversation

@gurmeherchawla

Copy link
Copy Markdown

Summary

  • Adds a ToggleStyle protocol, ToggleStyleConfiguration, and built-in DefaultToggleStyle/SwitchToggleStyle, mirroring the existing ButtonStyle/PrimitiveButtonStyle architecture
  • Wires up StackedToggleStyle/BridgedToggleStyle and a _toggleStyle EnvironmentValues entry so custom styles render through toggleStyle(_:)
  • Fixes the Toggle(_:) configuration initializer so it's available on non-SKIP (Darwin) builds

Dependency

This branch is stacked directly on top of feature/button-style-protocol, which adds the ButtonStyle/PrimitiveButtonStyle protocol support that this PR's ToggleStyle work mirrors. That branch has not yet been opened as a PR against this upstream repo, so this diff currently includes those button-style commits as well.

Please do not merge this PR until the button-style-protocol changes have landed in this repo's main first. Once they do, this diff will narrow to just the toggle-style-specific commits.

Test plan

  • Build for the SKIP (Android/Compose) target
  • Build for the Darwin target
  • Verify a custom ToggleStyle renders correctly on both platforms

automatic, button, and switch were accidentally typed as ButtonStyle instead of ToggleStyle.
…uration types

Introduces PrimitiveButtonStyle protocol and its concrete implementations: DefaultButtonStyle, PlainButtonStyle, BorderlessButtonStyle, BorderedButtonStyle, BorderedProminentButtonStyle, and M3TextButtonStyle. Adds functional ButtonStyleConfiguration and PrimitiveButtonStyleConfiguration replacing the dead stubs in comments, and Button(configuration:) init so styles can delegate rendering via makeBody. Coexists with the existing ButtonStyle bridging struct unchanged.
Tracks the active button style chain in the environment. Each node holds the current style, its parent (the style it overrides), and the modifier that installed it. isBuiltin distinguishes built-in styles that render natively in Compose from custom styles that render via makeBody.
…p StackedButtonStyle

Replaces the raw-value ButtonStyle struct with a ButtonStyle protocol matching SwiftUI's API. Updates ButtonStyleModifier to build the StackedButtonStyle chain and EnvironmentValues._buttonStyle to store it. Updates RenderButton to dispatch on the unwrapped style using type checks (is BorderedButtonStyle etc.), and updates shouldRenderListItem/RenderListItem to use the new isListItemStyle helper. Updates Navigation and Picker call sites.
Adds RenderCustomStyleButton which invokes makeBody on custom styles and composes the body with _buttonStyle set to the parent, enabling Button(configuration) delegation. Adds BridgedButtonStyle and BridgedPrimitiveButtonStyle for natively-compiled styles that cross the Skip bridge, with per-button @Environment syncing via ButtonStyleBridgedConfiguration. Adds buttonStyle(isPrimitive:environmentKeys:bridgedMakeBody:) for the bridge entry point.
Mirrors the ButtonStyle/PrimitiveButtonStyle architecture: adds a
ToggleStyle protocol, ToggleStyleConfiguration, built-in
DefaultToggleStyle/SwitchToggleStyle, and the StackedToggleStyle/
BridgedToggleStyle infrastructure needed to render custom styles.
Stores the StackedToggleStyle set by the toggleStyle(_:) modifier,
matching the existing _buttonStyle entry.
The initializer was nested inside #if SKIP, but DefaultToggleStyle
and SwitchToggleStyle call it from outside that guard, breaking the
non-SKIP (Darwin) build with "no exact matches in call to
initializer".
@cla-bot cla-bot Bot added the cla-signed label Sep 19, 2026
@gurmeherchawla

Copy link
Copy Markdown
Author

@marcprux

Dhruv-Clockworks and others added 8 commits October 15, 2026 17:16
This fixes a bug where, after the first withAnimation, every later change kept animating on Android
Adds support for ScrollPosition, onScrollGeometryChange and onScrollPhaseChange.
Adds ScrollPosition, scroll geometry, and scroll phase support
Adds document for scroll position, geometry and phase support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants