Implement ToggleStyle protocol and bridging - #145
Open
gurmeherchawla wants to merge 6 commits into
Open
gurmeherchawla wants to merge 6 commits into
gurmeherchawla wants to merge 6 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ToggleStylefollowing theButtonStylebridge pattern: anidentifierfor built-in styles,ToggleStyleConfigurationwrapping the bridged Java configuration with a real@Binding isOn, andtoggleStyle(_:)resolving custom styles throughResolvedToggleStyleinstead of returningselfunchangedViewconformance onToggleStyleConfiguration.LabelDependency
This branch is stacked directly on top of
feature/button-style-protocol, which adds theButtonStyle/PrimitiveButtonStylebridge that this PR'sToggleStylework 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
mainfirst. Once they do, this diff will narrow to just the toggle-style-specific commits.Test plan
ToggleStylebridges and renders correctly on both platforms