Support custom compose views in the desktop rig#76
Merged
Conversation
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
Brings the Custom Views screen (the
ComposableRegistryextension point) to the desktop rig, so custom compose views work on desktop as well as Android. The registry was already common code; what was missing was a desktop host registering factories and the screen being surfaced on desktop.DemoComposables.kt(desktop): registers two factories, the desktop counterpart to the Android demo'sregisterDemoComposables:RatingBar— a pure Compose-Multiplatform reimplementation (tap/drag over stars → half-step rating back to Swift;ratingprop drives the fill, so the two-way binding round-trips). The Android demo bridgesandroid.widget.RatingBar; desktop has no native widget, so this is drawn from Compose primitives (a clipped filled glyph over an empty one — no icon dependency).DashedBorder— the identical pure-Compose function the Android demo registers, wrapping SwiftUI child content in a Compose-drawn dashed border.Main.kt: callsregisterDemoComposables()before the rig starts.Package.swift: stops excludingRepresentablePlaygrounds.swiftfrom the desktop target (only Map and Video remain Android-only).Catalog.swift: the Custom Views entry is no longer gated onDESKTOP_RIG— each host registers its own factories, so the shared screen is cross-platform.Event dispatch from a registered factory (
onRatingChanged) rides the existingSwiftBridge.sink→ generatedBridgeExportpath, already live on desktop.Testing
swift build --product SwiftUIDesktopDemoand:demo-desktop:compileKotlinJvmpass.RatingBarreported taps back through Swift state (0.5 → 5.0 via the+½button and star taps, fill updating each time),DashedBorderrenders the border around its SwiftUI children, and the unregistered-name case shows the red diagnostic.#ifthat was already true on Android, andRepresentablePlaygrounds.swiftstays included there with its native-widget factory.