Skip to content

Commit

Permalink
Fix HazeNodeChild being experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes committed Nov 29, 2024
1 parent 301c1b0 commit ddb35a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion haze/api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package dev.chrisbanes.haze {
method @androidx.compose.runtime.Stable public static androidx.compose.ui.Modifier hazeChild(androidx.compose.ui.Modifier, dev.chrisbanes.haze.HazeState state, optional dev.chrisbanes.haze.HazeStyle style, optional kotlin.jvm.functions.Function1<? super dev.chrisbanes.haze.HazeChildScope,kotlin.Unit>? block);
}

@dev.chrisbanes.haze.ExperimentalHazeApi public final class HazeChildNode extends androidx.compose.ui.Modifier.Node implements androidx.compose.ui.node.CompositionLocalConsumerModifierNode androidx.compose.ui.node.DrawModifierNode androidx.compose.ui.node.GlobalPositionAwareModifierNode dev.chrisbanes.haze.HazeChildScope androidx.compose.ui.node.ObserverModifierNode {
public final class HazeChildNode extends androidx.compose.ui.Modifier.Node implements androidx.compose.ui.node.CompositionLocalConsumerModifierNode androidx.compose.ui.node.DrawModifierNode androidx.compose.ui.node.GlobalPositionAwareModifierNode dev.chrisbanes.haze.HazeChildScope androidx.compose.ui.node.ObserverModifierNode {
ctor public HazeChildNode(dev.chrisbanes.haze.HazeState state, optional dev.chrisbanes.haze.HazeStyle style, optional kotlin.jvm.functions.Function1<? super dev.chrisbanes.haze.HazeChildScope,kotlin.Unit>? block);
method public void draw(androidx.compose.ui.graphics.drawscope.ContentDrawScope);
method public float getAlpha();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import io.github.reactivecircus.cache4k.Cache
* This is public API in order to aid custom extensible modifiers, _but_ we reserve the right
* to be able to change the API in the future, hence why it is marked as experimental forever.
*/
@ExperimentalHazeApi
class HazeChildNode(
var state: HazeState,
style: HazeStyle = HazeStyle.Unspecified,
Expand Down Expand Up @@ -80,6 +79,7 @@ class HazeChildNode(
}
}

@ExperimentalHazeApi
override var inputScale: HazeInputScale = HazeInputScale.Default
set(value) {
if (value != field) {
Expand Down Expand Up @@ -298,6 +298,7 @@ class HazeChildNode(
}
}

@OptIn(ExperimentalHazeApi::class)
private fun DrawScope.drawEffectWithGraphicsLayer(contentLayer: GraphicsLayer) {
// Now we need to draw `contentNode` into each of an 'effect' graphic layers.
// The RenderEffect applied will provide the blurring effect.
Expand Down Expand Up @@ -533,11 +534,13 @@ internal data class RenderEffectParams(
val inputScale: Float = 1f,
)

@ExperimentalHazeApi
internal fun HazeChildNode.getInputScaleFactor(): Float = when (val s = inputScale) {
HazeInputScale.None -> 1f
is HazeInputScale.Fixed -> s.scale
}

@OptIn(ExperimentalHazeApi::class)
internal fun HazeChildNode.getOrCreateRenderEffect(
inputScale: Float = getInputScaleFactor(),
blurRadius: Dp = resolveBlurRadius().takeOrElse { 0.dp } * inputScale,
Expand Down

0 comments on commit ddb35a6

Please sign in to comment.