Skip to content

Commit cbdacad

Browse files
authored
feat(tagPillIcon): adding the ability to add icon on tagPill (#38)
1 parent 1023ab9 commit cbdacad

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ ClickyButton(
160160

161161
#### TagPill
162162

163-
![TagPill Preview](xpeho_ui_android/doc/tagpill.png)
163+
![TagPill Preview](xpeho_ui_android/doc/tag_pill.png)
164164

165165
Usage:
166166

@@ -171,7 +171,8 @@ TagPill(
171171
label = String,
172172
size = TextUnit,
173173
backgroundColor = Color,
174-
labelColor = Color
174+
labelColor = Color,
175+
icon = @Composable() -> Unit? {},
175176
)
176177
```
177178

xpeho_ui_android/doc/tag_pill.png

36.9 KB
Loading

xpeho_ui_android/doc/tagpill.png

-31.4 KB
Binary file not shown.

xpeho_ui_android/src/main/java/com/xpeho/xpeho_ui_android/TagPill.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ package com.xpeho.xpeho_ui_android
33
import androidx.compose.foundation.layout.Box
44
import androidx.compose.foundation.layout.Row
55
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.foundation.layout.size
67
import androidx.compose.foundation.layout.width
78
import androidx.compose.foundation.shape.RoundedCornerShape
89
import androidx.compose.material3.Card
910
import androidx.compose.material3.CardDefaults
11+
import androidx.compose.material3.Icon
1012
import androidx.compose.material3.Surface
1113
import androidx.compose.material3.Text
1214
import androidx.compose.runtime.Composable
1315
import androidx.compose.ui.Alignment
1416
import androidx.compose.ui.Modifier
1517
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.res.painterResource
1619
import androidx.compose.ui.text.font.FontWeight
1720
import androidx.compose.ui.text.style.TextOverflow
1821
import androidx.compose.ui.tooling.preview.Preview
@@ -27,19 +30,21 @@ fun TagPill(
2730
label: String,
2831
size: TextUnit = 10.sp,
2932
backgroundColor: Color = Colors.GREEN_DARK_COLOR,
30-
labelColor: Color = Color.White
33+
labelColor: Color = Color.White,
34+
icon: @Composable () -> Unit? = {},
3135
) {
3236
return Card(
3337
shape = RoundedCornerShape(6.dp),
3438
colors = CardDefaults.cardColors(
3539
containerColor = backgroundColor,
3640
),
3741

38-
) {
39-
Box(
42+
) {
43+
Row(
4044
modifier = Modifier.padding(vertical = 1.dp, horizontal = 4.dp),
41-
contentAlignment = Alignment.Center
45+
verticalAlignment = Alignment.CenterVertically,
4246
) {
47+
icon()
4348
Text(
4449
text = label.uppercase(),
4550
fontSize = size,
@@ -67,6 +72,20 @@ fun TagPillPreview() {
6772
"stress",
6873
backgroundColor = Colors.XPEHO_COLOR,
6974
)
75+
Box(modifier = Modifier.width(4.dp))
76+
TagPill(
77+
icon = {
78+
Icon(
79+
painter = painterResource(id = R.drawable.eye),
80+
tint = Color.White,
81+
contentDescription = "Briefcase icon",
82+
modifier = Modifier
83+
.size(12.dp)
84+
.padding(end = 2.dp)
85+
)
86+
},
87+
label= "TAG PILL ICON",
88+
)
7089
}
7190
}
7291
}

0 commit comments

Comments
 (0)