Skip to content

Commit 4eb9328

Browse files
add new properties to Label
1 parent bf81455 commit 4eb9328

File tree

1 file changed

+44
-10
lines changed
  • image/src/main/java/com/smarttoolfactory/image/beforeafter

1 file changed

+44
-10
lines changed

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

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,79 @@ import androidx.compose.ui.Alignment
1010
import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.graphics.Color
1212
import androidx.compose.ui.text.font.FontWeight
13+
import androidx.compose.ui.unit.TextUnit
1314
import androidx.compose.ui.unit.dp
1415
import androidx.compose.ui.unit.sp
1516

1617
/**
1718
* Black transparent label to display before or after text
1819
*/
1920
@Composable
20-
fun Label(modifier: Modifier = Modifier, text: String) {
21+
internal fun Label(
22+
modifier: Modifier = Modifier,
23+
textColor: Color = Color.White,
24+
fontWeight: FontWeight = FontWeight.Bold,
25+
fontSize: TextUnit = 14.sp,
26+
text: String
27+
) {
2128
Text(
2229
text = text,
23-
color = Color.White,
24-
fontSize = 14.sp,
25-
fontWeight = FontWeight.Bold,
30+
color = textColor,
31+
fontSize = fontSize,
32+
fontWeight = fontWeight,
2633
modifier = modifier
27-
.background(Color.Black.copy(alpha = .5f), RoundedCornerShape(50))
28-
.padding(horizontal = 12.dp, vertical = 8.dp)
34+
2935
)
3036
}
3137

38+
internal val labelModifier =
39+
Modifier
40+
.background(Color.Black.copy(alpha = .5f), RoundedCornerShape(50))
41+
.padding(horizontal = 12.dp, vertical = 8.dp)
42+
3243
@Composable
33-
fun BoxScope.BeforeLabel(contentOrder: ContentOrder) {
44+
fun BoxScope.BeforeLabel(
45+
text: String = "Before",
46+
textColor: Color = Color.White,
47+
fontWeight: FontWeight = FontWeight.Bold,
48+
fontSize: TextUnit = 14.sp,
49+
contentOrder: ContentOrder = ContentOrder.BeforeAfter
50+
) {
3451
Label(
35-
text = "Before", modifier = Modifier
52+
text = text,
53+
textColor = textColor,
54+
fontWeight = fontWeight,
55+
fontSize = fontSize,
56+
modifier = Modifier
3657
.padding(8.dp)
3758
.align(
3859
if (contentOrder == ContentOrder.BeforeAfter)
3960
Alignment.TopStart else Alignment.TopEnd
4061
)
62+
.then(labelModifier)
4163
)
4264
}
4365

4466
@Composable
45-
fun BoxScope.AfterLabel(contentOrder: ContentOrder) {
67+
fun BoxScope.AfterLabel(
68+
text: String = "After",
69+
textColor: Color = Color.White,
70+
fontWeight: FontWeight = FontWeight.Bold,
71+
fontSize: TextUnit = 14.sp,
72+
contentOrder: ContentOrder = ContentOrder.BeforeAfter
73+
) {
4674
Label(
47-
text = "After", modifier = Modifier
75+
text = text,
76+
textColor = textColor,
77+
fontWeight = fontWeight,
78+
fontSize = fontSize,
79+
80+
modifier = Modifier
4881
.padding(8.dp)
4982
.align(
5083
if (contentOrder == ContentOrder.BeforeAfter)
5184
Alignment.TopEnd else Alignment.TopStart
5285
)
86+
.then(labelModifier)
5387
)
5488
}

0 commit comments

Comments
 (0)