Skip to content

Commit

Permalink
Fix Haze not drawing any effects in previews (#470)
Browse files Browse the repository at this point in the history
Regression in 1.2.0. I have absolutely no idea why the code doesn't work
in the Android Studio Preview, but our screenshot tests work fine. Oh
well, easy fix.

Fixes #468
  • Loading branch information
chrisbanes authored Jan 13, 2025
1 parent 1499b40 commit 9a0fe05
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ androidx-test-ext-junit = { module = "androidx.test.ext:junit-ktx", version.ref
androidx-test-uiautomator = "androidx.test.uiautomator:uiautomator:2.3.0"

androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "jetpack-compose" }
androidx-compose-ui-preview = { module = "androidx.compose.ui:ui-tooling", version.ref = "jetpack-compose" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "jetpack-compose" }
androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "jetpack-compose" }

assertk = { module = "com.willowtreeapps.assertk:assertk", version.ref = "assertk" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class HazeEffectNode(
}

private fun updateRenderEffectIfDirty() {
if (dirtyTracker.any(DirtyFields.RenderEffectAffectingFlags)) {
if (renderEffect == null || dirtyTracker.any(DirtyFields.RenderEffectAffectingFlags)) {
renderEffect = getOrCreateRenderEffect()
}
}
Expand Down
3 changes: 3 additions & 0 deletions sample/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.profileinstaller)

implementation(libs.androidx.compose.ui.tooling)
implementation(libs.androidx.compose.ui.preview)

implementation(libs.androidx.media3.exoplayer)
implementation(libs.androidx.media3.ui)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025, Christopher Banes and the Haze project contributors
// SPDX-License-Identifier: Apache-2.0

package dev.chrisbanes.haze.sample.android

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import dev.chrisbanes.haze.sample.CreditCardSample
import dev.chrisbanes.haze.sample.Navigator

@Composable
@Preview
fun PreviewCardSample() {
CreditCardSample(Navigator())
}

0 comments on commit 9a0fe05

Please sign in to comment.