Repository navigation
Bind Scaffold and use it in the sample - #19
Merged
Merged
Conversation
Adds a Material 3 Scaffold composable using the same slot-property facade pattern as AlertDialog. The Kotlin overload is stripped from the binding because FabPosition / containerColor / contentColor are @JvmInline value class params, so we call it via JNI against Scaffold-TvnljyQ. Updates the sample to wrap per-tab content in a Scaffold with NavigationBar moved to the BottomBar slot, so the bottom bar is pinned to the bottom of the screen instead of flowing inline. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR adds a C# facade for Material 3 Scaffold (following the slot-property pattern used elsewhere in ComposeNet.Compose) and updates the sample app layout to use it so the bottom navigation is pinned correctly.
Changes:
- Introduces a new
Scaffoldcomposable facade with named slot properties (TopBar,BottomBar,SnackbarHost,FloatingActionButton,Body). - Adds a raw JNI bridge for the mangled
Scaffoldoverload and a declarative$defaultbitmask definition. - Updates the sample
MainActivityto wrap per-tab content inScaffoldand move theNavigationBarinto theBottomBarslot.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ComposeNet.Sample/MainActivity.cs | Switches the sample layout to use Scaffold so the bottom navigation is pinned via BottomBar. |
| src/ComposeNet.Compose/Scaffold.cs | Adds the new Scaffold facade type using the slot-property pattern and $default toggling. |
| src/ComposeNet.Compose/ComposeDefaults.cs | Registers ScaffoldDefault via declarative ComposeDefaults for $default bitmask generation. |
| src/ComposeNet.Compose/ComposeBridges.cs | Adds a raw JNI bridge for the stripped Scaffold overload. |
…een edges Refs #20 for the long-term edge-to-edge plan. Co-authored-by: Copilot <[email protected]>
jonathanpeppers
added a commit
that referenced
this pull request
Jun 3, 2026
Implements Phase 1 of #21. ## What Introduces a C# `Modifier` builder that mirrors Kotlin's chained `Modifier.foo().bar()` API and threads through every public composable in the facade. With this PR users can finally style layout — starting with the padding/fill ops needed to fix the regression from #19 (tab content flush against the screen edges). ```csharp new Column { Modifier.Companion.Padding(16), // <-- new in this PR new Text("Hello"), } ``` ## API - New `ComposeNet.Modifier` type with `Companion`, `Padding(int)`, `Padding(int h, int v)`, `Padding(int l, int t, int r, int b)`, `FillMaxWidth(float = 1f)`, `FillMaxHeight(float = 1f)`, `FillMaxSize(float = 1f)`. Each op returns a new immutable `Modifier` so the chain is reusable. - `internal IModifier? Build()` materializes the chain at `Render` time via JNI: `Modifier.Companion.$$INSTANCE` resolved via `JNIEnv.GetStaticFieldID`, then each op invokes the matching Kotlin static (`PaddingKt.padding-3ABfNKs/-VpY3zN4/-qDBjuR0`, `SizeKt.fillMaxWidth/Height/Size`). - `ComposableNode.Modifier { get; set; }` — every composable accepts an optional modifier. ## Setting `Modifier` on containers vs. leaves C# disallows mixing object-init assignments with collection-init items in the same `{ }`. Leaves (Text, Button, …) keep object-init syntax: ```csharp new Text("Hi") { Modifier = Modifier.Companion.Padding(8) } ``` For containers that derive from `ComposableContainer` (Column, Card, Surface, Scaffold, …) I added an `Add(Modifier)` overload so the modifier is set inline alongside children — the canonical C# trick for this situation: ```csharp new Column { Modifier.Companion.Padding(16), child1, child2 } ``` ## Wiring - `ComposeBridges.cs`: added `ModifierHandle` / `ModifierCompanionInstance` / `ModifierPadding{All,HV,LTRB}` / `ModifierFillMax{Width,Height,Size}` JNI helpers, and threaded an `IModifier? modifier` parameter through every existing bridge (Text, Button, IconButton, FAB, Surface, Card, TextField/OutlinedTextField, AlertDialog, ModalBottomSheet, BottomSheetScaffold, Scaffold, DatePicker(Dialog), TimePicker(Dialog), Tooltip, *Chip, NavigationBar(Item), NavigationRail(Item)). - Each composable's `Render` now calls `BuildModifier()` and clears the `Modifier` bit in its `$default` mask when the user supplied one. - `Column` uses the bound `ColumnKt.Column` directly (no JNI bridge), so it just passes the modifier through. ## Sample `MainActivity.cs` adds `Modifier.Companion.Padding(16)` to the Scaffold body's root `Column`, restoring the horizontal gutter that was dropped in #19 while leaving the BottomBar flush against the edges. ## Phase 2+ (out of scope) `Background`, `Border`, `Clip`, `Clickable`, gestures, size constraints, window-insets — to follow as separate issues / PRs. ## Verification - `dotnet test src/ComposeNet.SourceGenerators.Tests` — 10/10 passing. - `dotnet build src/ComposeNet.Compose` — clean. - `dotnet build src/ComposeNet.Sample` — clean. Closes #21 (Phase 1). Co-authored-by: Copilot <[email protected]>
jonathanpeppers
added a commit
that referenced
this pull request
Jun 3, 2026
Closes #20. The pre-AndroidX status-bar / action-bar shim in `ComposeActivity` had outlived its purpose: `ApplySafeAreaPadding` hand-computed pixels via `Resources.GetIdentifier("status_bar_height", "dimen", "android")` and pushed them onto the root `ComposeView`, while `ApplyLightStatusBar` toggled `WindowInsetsController` flags imperatively. That worked for bare-`Column` roots, but once #19 introduced `Scaffold` it started fighting Compose's own inset handling, and the resource trick never accounted for foldables, cutouts, or gesture nav anyway. This PR moves to the canonical Compose edge-to-edge setup: - `ComposeActivity.OnCreate` now calls `EdgeToEdge.Enable(this)` before `base.OnCreate`, which is the order the AndroidX API expects. System bars become transparent overlays, and Compose's `WindowInsets` propagation drives padding from there. - `ApplySafeAreaPadding`, `ApplyLightStatusBar`, and the `ActionBarHeight` / `Dp` / `SystemBarHeight` helpers (and their calls in `SetContent`) are deleted. - The sample's `MainActivity` switches from `Theme.Material.Light` to `Theme.Material.Light.NoActionBar`, so no framework `ActionBar` overlays the content. (No new NuGet dependency: a framework `NoActionBar` theme is enough for our purposes since `MaterialTheme` does the real Material 3 theming inside the composition.) - Two new modifiers, `Modifier.SafeDrawingPadding()` and `Modifier.SystemBarsPadding()`, bridge to `WindowInsetsPadding_androidKt` so callers can pad bare-`Column` roots, or `Scaffold` bodies that don't have a `TopBar`. The sample applies `SafeDrawingPadding()` on the `Scaffold` body for exactly that reason — the bottom `NavigationBar` continues to handle its own gesture-bar inset via the Material 3 default. README is updated with the new sample snippet and the "Confirmed on device" bullet describing the edge-to-edge setup. ### Notes for reviewers - Generator unit tests still pass (`dotnet test src/ComposeNet.SourceGenerators.Tests`, 10/10). - Sample builds and deploys (`dotnet build src/ComposeNet.Sample -t:Run`); the framework "ComposeNet.Sample" title strip is gone, status bar is transparent over the body, and `NavigationBar` sits flush with the bottom edge. - The two new modifier bridges follow the existing JNI pattern in `ComposeBridges.cs`. They could in principle call the bound `WindowInsetsPadding_androidKt.SafeDrawingPadding(IModifier)` directly, but keeping them on raw `IntPtr` matches how the rest of the modifier op-chain already works. Co-authored-by: Copilot <[email protected]>
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.
Closes #12.
What
Binds
androidx.compose.material3.ScaffoldKt.Scaffoldusing the slot-property facade pattern established byAlertDialog(#6).The Kotlin overload is stripped from the binding because
floatingActionButtonPosition(FabPosition),containerColor, andcontentColor(Color) are@JvmInline value classparameters, so we call it via a JNI bridge inComposeBridges.cs. Verified the mangled name againstandroidx.compose.material3.material3-android1.4.0.3 withjavap— it'sScaffold-TvnljyQ(10 user params, single$changed, then$default).New API
Sample fix
MainActivity.csnow wraps the per-tab content + overlays in aScaffold, moving theNavigationBarfrom the bottom of an inlineColumninto theBottomBarslot so it pins to the bottom edge of the screen (above the system nav bar) instead of floating mid-screen.Files
src/ComposeNet.Compose/Scaffold.cs— new facade.src/ComposeNet.Compose/ComposeBridges.cs—Scaffold-TvnljyQJNI bridge withGC.KeepAliveon every managed param.src/ComposeNet.Compose/ComposeDefaults.cs— declarative[ComposeDefaults("ScaffoldDefault", ...)]attribute (10 bits, onlycontentmarked!).src/ComposeNet.Sample/MainActivity.cs— usesScaffoldinstead of a tail-positionedNavigationBar.Verification
dotnet build src/ComposeNet.Compose✅ (no new warnings)dotnet build src/ComposeNet.Sample✅dotnet test src/ComposeNet.SourceGenerators.Tests✅ (10/10 pass —ScaffoldDefaultis generated from the declarative attribute)