Skip to content

Support custom compose views in the desktop rig#76

Merged
colemancda merged 2 commits into
masterfrom
feature/desktop-custom-views
Jul 25, 2026
Merged

Support custom compose views in the desktop rig#76
colemancda merged 2 commits into
masterfrom
feature/desktop-custom-views

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

Brings the Custom Views screen (the ComposableRegistry extension 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's registerDemoComposables:
    • RatingBar — a pure Compose-Multiplatform reimplementation (tap/drag over stars → half-step rating back to Swift; rating prop drives the fill, so the two-way binding round-trips). The Android demo bridges android.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: calls registerDemoComposables() before the rig starts.
  • Package.swift: stops excluding RepresentablePlaygrounds.swift from the desktop target (only Map and Video remain Android-only).
  • Catalog.swift: the Custom Views entry is no longer gated on DESKTOP_RIG — each host registers its own factories, so the shared screen is cross-platform.

Event dispatch from a registered factory (onRatingChanged) rides the existing SwiftBridge.sink → generated BridgeExport path, already live on desktop.

Testing

  • swift build --product SwiftUIDesktopDemo and :demo-desktop:compileKotlinJvm pass.
  • Ran the desktop rig and drove the screen: RatingBar reported taps back through Swift state (0.5 → 5.0 via the button and star taps, fill updating each time), DashedBorder renders the border around its SwiftUI children, and the unregistered-name case shows the red diagnostic.
  • Android is unaffected: the catalog change only drops a #if that was already true on Android, and RepresentablePlaygrounds.swift stays included there with its native-widget factory.

@colemancda
colemancda merged commit e12fb09 into master Jul 25, 2026
6 checks passed
@colemancda
colemancda deleted the feature/desktop-custom-views branch July 25, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant