Skip to content

Commit 7b02e5e

Browse files
add background, tint, shape and elevation options to DefaultOverlay
1 parent cec5dac commit 7b02e5e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

image/src/main/java/com/smarttoolfactory/image/beforeafter/DefaultOverlay.kt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.compose.ui.Modifier
1313
import androidx.compose.ui.draw.shadow
1414
import androidx.compose.ui.geometry.Offset
1515
import androidx.compose.ui.graphics.Color
16+
import androidx.compose.ui.graphics.Shape
1617
import androidx.compose.ui.platform.LocalDensity
1718
import androidx.compose.ui.res.painterResource
1819
import androidx.compose.ui.unit.Dp
@@ -29,11 +30,15 @@ import com.smarttoolfactory.image.R
2930
* @param height of the [BeforeAfterImage] or [BeforeAfterLayout]. You should get height from
3031
* scope of these Composables and pass to calculate bounds correctly
3132
* @param position current position or progress of before/after
32-
* @param verticalThumbMove whether thumb should move vertically
33+
* @param verticalThumbMove when true thumb can move vertically based on user touch
3334
* @param lineColor color if divider line
35+
* @param thumbBackgroundColor background color of thumb [Icon]
36+
* @param thumbTintColor tint color of thumb [Icon]
37+
* @param thumbShape shape of thumb [Icon]
38+
* @param thumbElevation elevation of thumb [Icon]
3439
* @param thumbResource drawable resource that should be used with thumb
3540
* @param thumbSize size of the thumb in dp
36-
* @param thumbPositionPercent vertical position of thumb if [verticalThumbMove] is false.
41+
* @param thumbPositionPercent vertical position of thumb if [verticalThumbMove] is false
3742
* It's between [0f-100f] to set thumb's vertical position in layout
3843
*/
3944
@Composable
@@ -43,6 +48,10 @@ internal fun DefaultOverlay(
4348
position: Offset,
4449
verticalThumbMove: Boolean = false,
4550
lineColor: Color = Color.White,
51+
thumbBackgroundColor: Color = Color.White,
52+
thumbTintColor: Color = Color.Gray,
53+
thumbShape: Shape = CircleShape,
54+
thumbElevation: Dp = 2.dp,
4655
@DrawableRes thumbResource: Int = R.drawable.baseline_swap_horiz_24,
4756
thumbSize: Dp = 36.dp,
4857
@FloatRange(from = 0.0, to = 100.0) thumbPositionPercent: Float = 85f,
@@ -94,13 +103,13 @@ internal fun DefaultOverlay(
94103
Icon(
95104
painter = painterResource(id = thumbResource),
96105
contentDescription = null,
97-
tint = Color.Gray,
106+
tint = thumbTintColor,
98107
modifier = Modifier
99108
.offset {
100109
IntOffset(thumbPosX.toInt(), thumbPosY.toInt())
101110
}
102-
.shadow(2.dp, CircleShape)
103-
.background(Color.White)
111+
.shadow(thumbElevation, thumbShape)
112+
.background(thumbBackgroundColor)
104113
.size(thumbSize)
105114
.padding(4.dp)
106115
)

0 commit comments

Comments
 (0)