Skip to content

Implement ToggleStyle protocol and bridging - #145

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

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

Conversation

@gurmeherchawla

Copy link
Copy Markdown

Summary

  • Bridges ToggleStyle following the ButtonStyle bridge pattern: an identifier for built-in styles, ToggleStyleConfiguration wrapping the bridged Java configuration with a real @Binding isOn, and toggleStyle(_:) resolving custom styles through ResolvedToggleStyle instead of returning self unchanged
  • Fixes a redundant View conformance on ToggleStyleConfiguration.Label

Dependency

This branch is stacked directly on top of feature/button-style-protocol, which adds the ButtonStyle/PrimitiveButtonStyle bridge 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 bridge 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 bridges and renders correctly on both platforms

Skip generates environment syncing for View and ViewModifier, but not for other types that declare @Environment properties such as custom styles. Adds EnvironmentSupportSyncable, Java_environmentKeys, and Java_syncEnvironment so callers can manually sync environment values into any type before use.
Wires up ButtonStyle and PrimitiveButtonStyle protocols through the Skip bridge. Built-in styles continue to use their numeric identifiers for native Compose rendering. Custom styles route through ResolvedButtonStyle, which reads the style's @Environment properties at each button's Compose position using the syncing utilities added in the previous commit. Implements ButtonStyleConfiguration and PrimitiveButtonStyleConfiguration with working Label views and trigger(), and enables Button(configuration) so custom primitive styles can delegate rendering to an outer style.
Adds ButtonStyleTestFixture with SampleButtonStyle (a ButtonStyle that reads @Environment(\.isEnabled) on the style itself) and SamplePrimitiveButtonStyle (a PrimitiveButtonStyle that wraps Button(configuration)). The UI test verifies custom style bodies render, actions fire through both style kinds, and environment values declared on the style track the button's position.
Mirrors the ButtonStyle bridge: ToggleStyle now carries an identifier
for built-in styles, ToggleStyleConfiguration wraps the bridged Java
configuration with a real @binding isOn, and toggleStyle(_:) resolves
custom styles through ResolvedToggleStyle instead of returning self
unchanged.
Label already conforms to View via the extension below; declaring
it inline too caused a "redundant conformance" compiler error and a
spurious main-actor isolation warning, matching the pattern already
used by ButtonStyleConfiguration.Label.
@cla-bot cla-bot Bot added the cla-signed label Sep 19, 2026
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.

1 participant