diff --git a/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeChildNode.kt b/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeChildNode.kt index 3ea70b3..2740acf 100644 --- a/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeChildNode.kt +++ b/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeChildNode.kt @@ -9,6 +9,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Size import androidx.compose.ui.geometry.isSpecified +import androidx.compose.ui.geometry.takeOrElse import androidx.compose.ui.geometry.toRect import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color @@ -28,7 +29,6 @@ import androidx.compose.ui.layout.positionInWindow import androidx.compose.ui.node.CompositionLocalConsumerModifierNode import androidx.compose.ui.node.DrawModifierNode import androidx.compose.ui.node.GlobalPositionAwareModifierNode -import androidx.compose.ui.node.LayoutAwareModifierNode import androidx.compose.ui.node.ObserverModifierNode import androidx.compose.ui.node.currentValueOf import androidx.compose.ui.node.invalidateDraw @@ -54,7 +54,6 @@ class HazeChildNode( var block: (HazeChildScope.() -> Unit)? = null, ) : Modifier.Node(), CompositionLocalConsumerModifierNode, - LayoutAwareModifierNode, GlobalPositionAwareModifierNode, ObserverModifierNode, DrawModifierNode, @@ -219,30 +218,14 @@ class HazeChildNode( } override fun onGloballyPositioned(coordinates: LayoutCoordinates) { - onPlaced(coordinates) - log(TAG) { "onGloballyPositioned: " + - "positionInWindow=${coordinates.positionInWindow()}, " + - "positionInContent=$positionInContent, " + - "size=$size" - } - } - - override fun onPlaced(coordinates: LayoutCoordinates) { - onPositioned(coordinates) - - log(TAG) { - "onPlaced: " + - "positionInWindow=${coordinates.positionInWindow()}, " + - "positionInContent=$positionInContent, " + - "size=$size" + "positionInWindow=${coordinates.positionInWindow()}" } - } - private fun onPositioned(coordinates: LayoutCoordinates) { positionInContent = coordinates.positionInWindow() + - calculateWindowOffset() - state.positionOnScreen + calculateWindowOffset() - state.positionOnScreen.takeOrElse { Offset.Zero } + size = coordinates.size.toSize() val blurRadiusPx = with(currentValueOf(LocalDensity)) { diff --git a/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeNode.kt b/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeNode.kt index 872cbf5..09dcc5a 100644 --- a/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeNode.kt +++ b/haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeNode.kt @@ -13,7 +13,6 @@ import androidx.compose.ui.layout.positionInWindow import androidx.compose.ui.node.CompositionLocalConsumerModifierNode import androidx.compose.ui.node.DrawModifierNode import androidx.compose.ui.node.GlobalPositionAwareModifierNode -import androidx.compose.ui.node.LayoutAwareModifierNode import androidx.compose.ui.node.currentValueOf import androidx.compose.ui.platform.LocalGraphicsContext import androidx.compose.ui.unit.Dp @@ -34,30 +33,15 @@ class HazeNode( ) : Modifier.Node(), CompositionLocalConsumerModifierNode, GlobalPositionAwareModifierNode, - LayoutAwareModifierNode, DrawModifierNode { override fun onGloballyPositioned(coordinates: LayoutCoordinates) { - onPlaced(coordinates) - log(TAG) { "onGloballyPositioned: " + "positionInWindow=${coordinates.positionInWindow()}, " + - "positionInContent=${state.positionOnScreen}" - } - } - - override fun onPlaced(coordinates: LayoutCoordinates) { - onPositioned(coordinates) - - log(TAG) { - "onPlaced: " + - "positionInWindow=${coordinates.positionInWindow()}, " + - "positionInContent=${state.positionOnScreen}" + "content positionOnScreens=${state.positionOnScreen}" } - } - private fun onPositioned(coordinates: LayoutCoordinates) { state.positionOnScreen = coordinates.positionInWindow() + calculateWindowOffset() }