Repository navigation
[DON-4207] Add dimBackground option to BpkModal - #2908
Conversation
…imations when not animated #trivial The modal is shown in a Dialog window that dims the content behind it and plays its own enter/exit animation. When the modal is not animated and covers the screen, the dim only shows as a flash while it appears or disappears. Co-authored-by: OpenCode <noreply@opencode.ai>
Generated by 🚫 Danger Kotlin against df04065 |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Adds configurability to BpkModal’s dialog window behavior by introducing a dimBackground option and ensuring animated = false fully disables dialog/window animations to avoid visible flashes.
Changes:
- Add
dimBackground: Boolean = trueparameter toBpkModal/BpkModalImpl. - Clear
FLAG_DIM_BEHINDwhendimBackground = falseand disable window animations whenanimated = false. - Document the new option and extend androidTests to validate dimming and window animation behavior.
| File | Description |
|---|---|
| docs/compose/Modal/README.md | Documents the new dimBackground option and when to use it |
| backpack-compose/src/main/kotlin/net/skyscanner/backpack/compose/modal/internal/BpkModalImpl.kt | Applies dialog window flag/animation changes based on new parameters |
| backpack-compose/src/main/kotlin/net/skyscanner/backpack/compose/modal/BpkModal.kt | Exposes dimBackground in the public API and updates KDoc |
| backpack-compose/src/androidTest/kotlin/net/skyscanner/backpack/compose/modal/BpkModalAnimatedTest.kt | Adds coverage for dim-behind default/override and window animations disabled when animated = false |
Review effort: Lite
…ange back #trivial - Apply both branches of dimBackground and restore the dialog's default window animations when animated becomes true again - Read the dialog window inside runOnIdle in the tests and cover the restore cases Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
3 resolved since last review
Review effort: Lite
| private fun <T> readDialogWindow(read: Window.() -> T): T { | ||
| var result: T? = null | ||
| composeTestRule.runOnIdle { | ||
| val window = checkNotNull(dialogWindow) { "The modal's dialog window was not composed" } | ||
| result = window.read() | ||
| } | ||
| @Suppress("UNCHECKED_CAST") | ||
| return result as T | ||
| } |
| The modal is shown in its own window, which dims the content behind it. When the modal covers the whole screen the dim is | ||
| only visible as a flash while the modal appears or disappears, for example when `animated = false`. Set | ||
| `dimBackground = false` to turn it off. | ||
|
|


Summary
Adds a
dimBackground: Boolean = trueparameter toBpkModal, and makesanimated = falsealso disable the dialog window's own enter/exit animation.BpkModalis shown in aDialogwindow. That window dims the content behind it and plays its own default window animation.animated = false(#2895) only removed the slide, so when a modal that covers the whole screen is shown withanimated = false, the dim still fades in and out behind it. On dismiss this shows up as a grey frame after the modal has already disappeared.When
dimBackground = false,FLAG_DIM_BEHINDis cleared on the dialog window. Whenanimated = false, the window animations are set to0. The defaults are unchanged, so existing consumers are not affected.Why
In Skyscanner's app the Search Control GC (
BpkModal) opens on a screen that is itself pushed with a slide transition and usesanimated = false. The leftover dim and window animation are visible as a flash on open and as a grey frame on close.Changes
BpkModal/BpkModalImpl: newdimBackgroundparameter, and window animations disabled whenanimated = falsedocs/compose/Modal/README.md: documented under "Dimmed background"BpkModalAnimatedTest(androidTest): the window dims behind by default, does not dim withdimBackground = false, and has no window animations whenanimated = falseTesting
detektpassesBpkModalAnimatedTestpasses on API 35 and API 37 emulators (5/5)Remember to include the following changes:
README.md