Repository navigation
Implement ToggleStyle protocol and configuration - #529
Open
gurmeherchawla wants to merge 16 commits into
Open
gurmeherchawla wants to merge 16 commits into
gurmeherchawla wants to merge 16 commits into
Conversation
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".
Author
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
…gle-style-protocol
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
ToggleStyleprotocol,ToggleStyleConfiguration, and built-inDefaultToggleStyle/SwitchToggleStyle, mirroring the existingButtonStyle/PrimitiveButtonStylearchitectureStackedToggleStyle/BridgedToggleStyleand a_toggleStyleEnvironmentValuesentry so custom styles render throughtoggleStyle(_:)Toggle(_:)configuration initializer so it's available on non-SKIP (Darwin) buildsDependency
This branch is stacked directly on top of
feature/button-style-protocol, which adds theButtonStyle/PrimitiveButtonStyleprotocol support 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 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
ToggleStylerenders correctly on both platforms