Repository navigation
Migrate ComposeActivity to edge-to-edge / NoActionBar - #25
Merged
Merged
Conversation
Replace the manual ApplySafeAreaPadding/ApplyLightStatusBar shims in ComposeActivity with EdgeToEdge.Enable(this) and a NoActionBar framework theme on the sample. The pre-AndroidX status_bar_height resource trick, the View.SetPadding hack, and the WindowInsetsController light-bars toggle all go away — Compose's WindowInsets propagation now drives inset handling end-to-end. Add Modifier.SafeDrawingPadding() and Modifier.SystemBarsPadding() to the facade (bridges to WindowInsetsPadding_androidKt) so callers can pad bare Column / Scaffold-body roots for the safe area. The sample applies SafeDrawingPadding to the Scaffold body since there's no TopBar consuming the status bar inset. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Migrates the sample and shared ComposeActivity base class to an edge-to-edge window setup, removing the legacy framework-side inset/status-bar shims and relying on Compose WindowInsets + modifier-based padding instead.
Changes:
- Enable edge-to-edge in
ComposeActivityviaEdgeToEdge.Enable(this)and delete the old manual padding + light-status-bar helpers. - Add
Modifier.SafeDrawingPadding()andModifier.SystemBarsPadding()bridges for inset-aware root/body padding under edge-to-edge. - Update the sample activity theme to
Theme.Material.Light.NoActionBarand applySafeDrawingPadding()to theScaffoldbody content; refresh README guidance/snippets accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/ComposeNet.Compose/ComposeActivity.cs | Enables edge-to-edge in OnCreate and removes manual safe-area/status-bar handling; documents the new inset strategy. |
| src/ComposeNet.Compose/Modifier.cs | Adds SafeDrawingPadding() and SystemBarsPadding() fluent modifier ops for consumer use. |
| src/ComposeNet.Compose/ComposeBridges.cs | Introduces JNI bridges to WindowInsetsPadding_androidKt modifier functions. |
| src/ComposeNet.Sample/MainActivity.cs | Switches to a NoActionBar theme and applies SafeDrawingPadding() within the Scaffold body. |
| README.md | Updates “Confirmed on device” notes and sample code to reflect edge-to-edge + modifier-based inset padding. |
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 #20.
The pre-AndroidX status-bar / action-bar shim in
ComposeActivityhad outlived its purpose:ApplySafeAreaPaddinghand-computed pixels viaResources.GetIdentifier("status_bar_height", "dimen", "android")and pushed them onto the rootComposeView, whileApplyLightStatusBartoggledWindowInsetsControllerflags imperatively. That worked for bare-Columnroots, but once #19 introducedScaffoldit 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.OnCreatenow callsEdgeToEdge.Enable(this)beforebase.OnCreate, which is the order the AndroidX API expects. System bars become transparent overlays, and Compose'sWindowInsetspropagation drives padding from there.ApplySafeAreaPadding,ApplyLightStatusBar, and theActionBarHeight/Dp/SystemBarHeighthelpers (and their calls inSetContent) are deleted.MainActivityswitches fromTheme.Material.LighttoTheme.Material.Light.NoActionBar, so no frameworkActionBaroverlays the content. (No new NuGet dependency: a frameworkNoActionBartheme is enough for our purposes sinceMaterialThemedoes the real Material 3 theming inside the composition.)Modifier.SafeDrawingPadding()andModifier.SystemBarsPadding(), bridge toWindowInsetsPadding_androidKtso callers can pad bare-Columnroots, orScaffoldbodies that don't have aTopBar. The sample appliesSafeDrawingPadding()on theScaffoldbody for exactly that reason — the bottomNavigationBarcontinues 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
dotnet test src/ComposeNet.SourceGenerators.Tests, 10/10).dotnet build src/ComposeNet.Sample -t:Run); the framework "ComposeNet.Sample" title strip is gone, status bar is transparent over the body, andNavigationBarsits flush with the bottom edge.ComposeBridges.cs. They could in principle call the boundWindowInsetsPadding_androidKt.SafeDrawingPadding(IModifier)directly, but keeping them on rawIntPtrmatches how the rest of the modifier op-chain already works.