Skip to content

Commit 3409755

Browse files
authored
Port #55 to :haze (#56)
1 parent 9de4677 commit 3409755

6 files changed

Lines changed: 24 additions & 12 deletions

File tree

haze-jetpack-compose/api/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package dev.chrisbanes.haze {
33

44
@androidx.compose.runtime.Stable public final class HazeArea {
5-
ctor public HazeArea();
5+
ctor public HazeArea(optional long size, optional long positionInRoot, optional androidx.compose.ui.graphics.Shape shape);
66
method public long getPositionInRoot();
77
method public androidx.compose.ui.graphics.Shape getShape();
88
method public long getSize();

haze-jetpack-compose/src/main/kotlin/dev/chrisbanes/haze/Haze.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,18 @@ internal fun Path.addOutline(outline: Outline, offset: Offset) = when (outline)
7171
}
7272

7373
@Stable
74-
class HazeArea {
75-
var size: Size by mutableStateOf(Size.Unspecified)
74+
class HazeArea(
75+
size: Size = Size.Unspecified,
76+
positionInRoot: Offset = Offset.Unspecified,
77+
shape: Shape = RectangleShape,
78+
) {
79+
var size: Size by mutableStateOf(size)
7680
internal set
7781

78-
var positionInRoot: Offset by mutableStateOf(Offset.Unspecified)
82+
var positionInRoot: Offset by mutableStateOf(positionInRoot)
7983
internal set
8084

81-
var shape: Shape by mutableStateOf(RectangleShape)
85+
var shape: Shape by mutableStateOf(shape)
8286
internal set
8387

8488
val isValid: Boolean

haze-jetpack-compose/src/main/kotlin/dev/chrisbanes/haze/HazeChild.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ private data class HazeChildNode(
4747
var shape: Shape,
4848
) : Modifier.Node(), LayoutAwareModifierNode {
4949

50-
private val area: HazeArea by lazy { HazeArea().apply { shape = this@HazeChildNode.shape } }
50+
private val area: HazeArea by lazy {
51+
HazeArea(shape = shape)
52+
}
5153

5254
private var attachedState: HazeState? = null
5355

haze/api/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package dev.chrisbanes.haze {
33

44
@androidx.compose.runtime.Stable public final class HazeArea {
5-
ctor public HazeArea();
5+
ctor public HazeArea(optional long size, optional long positionInRoot, optional androidx.compose.ui.graphics.Shape shape);
66
method public long getPositionInRoot();
77
method public androidx.compose.ui.graphics.Shape getShape();
88
method public long getSize();

haze/src/commonMain/kotlin/dev/chrisbanes/haze/Haze.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,18 @@ internal fun Path.addOutline(outline: Outline, offset: Offset) = when (outline)
7171
}
7272

7373
@Stable
74-
class HazeArea {
75-
var size: Size by mutableStateOf(Size.Unspecified)
74+
class HazeArea(
75+
size: Size = Size.Unspecified,
76+
positionInRoot: Offset = Offset.Unspecified,
77+
shape: Shape = RectangleShape,
78+
) {
79+
var size: Size by mutableStateOf(size)
7680
internal set
7781

78-
var positionInRoot: Offset by mutableStateOf(Offset.Unspecified)
82+
var positionInRoot: Offset by mutableStateOf(positionInRoot)
7983
internal set
8084

81-
var shape: Shape by mutableStateOf(RectangleShape)
85+
var shape: Shape by mutableStateOf(shape)
8286
internal set
8387

8488
val isValid: Boolean

haze/src/commonMain/kotlin/dev/chrisbanes/haze/HazeChild.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ private data class HazeChildNode(
4747
var shape: Shape,
4848
) : Modifier.Node(), LayoutAwareModifierNode {
4949

50-
private val area: HazeArea by lazy { HazeArea() }
50+
private val area: HazeArea by lazy {
51+
HazeArea(shape = shape)
52+
}
5153

5254
private var attachedState: HazeState? = null
5355

0 commit comments

Comments
 (0)