Skip to content

Commit a67745a

Browse files
Fixed more tag animation bug.
1 parent f973ede commit a67745a

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

core/ui/src/main/java/co/yml/coreui/core/ui/ytag/model/TagViewData.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ data class TagViewData(
2323
val overFlowText: (Int) -> String = { _ -> "" }
2424
)
2525

26-
data class AlphaAnimation(var enabled: Boolean = true, val durationMillis: Int = 650)
26+
data class AlphaAnimation(var enabled: Boolean = false, val durationMillis: Int = 650)

feature/ytag/src/main/java/co/yml/coreui/feature/ytag/ui/YTagActivity.kt

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package co.yml.coreui.feature.ytag.ui
22

33
import android.content.Context
44
import android.os.Bundle
5-
import android.util.Log
65
import android.widget.Toast
76
import androidx.activity.ComponentActivity
87
import androidx.activity.compose.setContent
@@ -34,6 +33,7 @@ import androidx.compose.ui.unit.sp
3433
import co.yml.coreui.core.ui.templates.AppBarWithBackButton
3534
import co.yml.coreui.core.ui.theme.CoreUICatalogTheme
3635
import co.yml.coreui.core.ui.ytag.TagViewContainer
36+
import co.yml.coreui.core.ui.ytag.model.AlphaAnimation
3737
import co.yml.coreui.core.ui.ytag.model.TagViewContainerModifiers
3838
import co.yml.coreui.core.ui.ytag.model.TagViewData
3939
import co.yml.coreui.core.ui.ytag.model.TagViewModifiers
@@ -48,12 +48,15 @@ class YTagActivity : ComponentActivity() {
4848
super.onCreate(savedInstanceState)
4949
setContent {
5050
CoreUICatalogTheme {
51-
Scaffold(modifier = Modifier.fillMaxSize(), containerColor = CoreUICatalogTheme.colors.background, topBar = {
52-
AppBarWithBackButton(stringResource(id = R.string.title_y_tag),
53-
onBackPressed = {
54-
onBackPressed()
55-
})
56-
}) {
51+
Scaffold(
52+
modifier = Modifier.fillMaxSize(),
53+
containerColor = CoreUICatalogTheme.colors.background,
54+
topBar = {
55+
AppBarWithBackButton(stringResource(id = R.string.title_y_tag),
56+
onBackPressed = {
57+
onBackPressed()
58+
})
59+
}) {
5760
Column(
5861
modifier = Modifier
5962
.fillMaxSize()
@@ -289,7 +292,9 @@ fun capsuleTagData(context: Context, backgroundColor: Color, textColor: Color):
289292
return TagViewData(
290293
text = context.getString(co.yml.coreui.feature.ytag.R.string.tag_capsule),
291294
tagViewModifiers = TagViewModifiers.Builder().width(90.dp).shape(CircleShape)
292-
.backgroundColor(backgroundColor).textColor(textColor).style(textStyle).build()
295+
.backgroundColor(backgroundColor).textColor(textColor).style(textStyle).alphaAnimation(
296+
AlphaAnimation(enabled = true)
297+
).build()
293298
)
294299
}
295300

@@ -302,7 +307,9 @@ fun rectangleTagData(context: Context, backgroundColor: Color, textColor: Color)
302307
return TagViewData(
303308
text = context.getString(co.yml.coreui.feature.ytag.R.string.tag_rectangle),
304309
tagViewModifiers = TagViewModifiers.Builder().width(90.dp).shape(RectangleShape)
305-
.backgroundColor(backgroundColor).textColor(textColor).style(textStyle).build()
310+
.backgroundColor(backgroundColor).textColor(textColor).style(textStyle).alphaAnimation(
311+
AlphaAnimation(enabled = true)
312+
).build()
306313
)
307314
}
308315

@@ -317,6 +324,9 @@ fun roundRectTagData(context: Context, backgroundColor: Color, textColor: Color)
317324
tagViewModifiers = TagViewModifiers.Builder()
318325
.shape(RoundedCornerShape(context.resources.getDimension(R.dimen.padding_small)))
319326
.width(140.dp).backgroundColor(backgroundColor).textColor(textColor).style(textStyle)
327+
.alphaAnimation(
328+
AlphaAnimation(enabled = true)
329+
)
320330
.build()
321331
)
322332
}
@@ -332,7 +342,9 @@ fun leadingIconTagData(
332342
return TagViewData(text = context.getString(co.yml.coreui.feature.ytag.R.string.tag_leading_icon),
333343
tagViewModifiers = TagViewModifiers.Builder().width(120.dp).maxLines(1)
334344
.overFlow(TextOverflow.Ellipsis).shape(CircleShape).backgroundColor(backgroundColor)
335-
.textColor(textColor).fontStyle(FontStyle.Italic).build(),
345+
.textColor(textColor).fontStyle(FontStyle.Italic).alphaAnimation(
346+
AlphaAnimation(enabled = true)
347+
).build(),
336348
leadingIcon = { tagViewData ->
337349
IconButton(modifier = Modifier.size(dimensionResource(id = R.dimen.padding_normal_medium)),
338350
onClick = {
@@ -363,7 +375,9 @@ fun trailingIconData(
363375
return TagViewData(text = context.getString(co.yml.coreui.feature.ytag.R.string.tag_trailing_icon),
364376
tagViewModifiers = TagViewModifiers.Builder().width(150.dp).maxLines(1)
365377
.textAlign(TextAlign.Start).overFlow(TextOverflow.Ellipsis).shape(CircleShape)
366-
.backgroundColor(backgroundColor).textColor(textColor).fontSize(15.sp).build(),
378+
.backgroundColor(backgroundColor).textColor(textColor).fontSize(15.sp).alphaAnimation(
379+
AlphaAnimation(enabled = true)
380+
).build(),
367381
trailingIcon = { tagViewData ->
368382
IconButton(modifier = Modifier
369383
.padding(end = dimensionResource(id = R.dimen.padding_medium))
@@ -394,7 +408,10 @@ fun leadingIconTrailingIconData(
394408
return TagViewData(text = context.getString(co.yml.coreui.feature.ytag.R.string.tag_leading_trailing_icon),
395409
tagViewModifiers = TagViewModifiers.Builder().width(140.dp).maxLines(1)
396410
.overFlow(TextOverflow.Ellipsis).shape(CircleShape).backgroundColor(backgroundColor)
397-
.maxLines(1).overFlow(TextOverflow.Ellipsis).textColor(textColor).onCLick {}.build(),
411+
.maxLines(1).overFlow(TextOverflow.Ellipsis).textColor(textColor).onCLick {}
412+
.alphaAnimation(
413+
AlphaAnimation(enabled = true)
414+
).build(),
398415
leadingIcon = { tagViewData ->
399416
IconButton(modifier = Modifier.size(dimensionResource(id = R.dimen.padding_normal_medium)),
400417
onClick = {
@@ -438,7 +455,9 @@ fun borderTagData(
438455
.borderColor(Color.Red)
439456
.borderWidth(dimensionResource(id = R.dimen.padding_very_tiny))
440457
.style(textStyle).maxLines(1)
441-
.overFlow(TextOverflow.Ellipsis).build()
458+
.overFlow(TextOverflow.Ellipsis).alphaAnimation(
459+
AlphaAnimation(enabled = true)
460+
).build()
442461

443462
return TagViewData(
444463
text = context.getString(co.yml.coreui.feature.ytag.R.string.tag_border),
@@ -456,7 +475,9 @@ fun shadowTagData(
456475
.textColor(textColor)
457476
.backgroundColor(backgroundColor)
458477
.shape(CircleShape).shadowElevation(dimensionResource(id = R.dimen.padding_tiny))
459-
.style(textStyle).maxLines(1).overFlow(TextOverflow.Ellipsis).build()
478+
.style(textStyle).maxLines(1).overFlow(TextOverflow.Ellipsis).alphaAnimation(
479+
AlphaAnimation(enabled = true)
480+
).build()
460481

461482
return TagViewData(
462483
text = stringResource(id = co.yml.coreui.feature.ytag.R.string.tag_shadow),

0 commit comments

Comments
 (0)