From 7562b4ca97c46d57b6d25b3c892c50a40934c950 Mon Sep 17 00:00:00 2001 From: Pablo Garcia Date: Fri, 28 Jul 2023 12:50:52 +0200 Subject: [PATCH] ANDROID-13605 - Unify Ids Skeleton --- .../mistica/compose/skeleton/Skeleton.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/telefonica/mistica/compose/skeleton/Skeleton.kt b/library/src/main/java/com/telefonica/mistica/compose/skeleton/Skeleton.kt index 468b6e64a..8d34529fa 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/skeleton/Skeleton.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/skeleton/Skeleton.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.testTag import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.telefonica.mistica.compose.theme.MisticaTheme @@ -40,6 +41,7 @@ fun LineSkeleton( val skeletonColor by skeletonColorTransition(infiniteTransition, style) Box( modifier = modifier + .testTag(SkeletonTestTags.SKELETON_LINE) .fillMaxWidth() .clip(shape = RoundedCornerShape(MisticaTheme.radius.containerBorderRadius)) .background(skeletonColor) @@ -54,7 +56,9 @@ fun TextSkeleton( style: SkeletonStyle = SkeletonStyle.Default, ) { Column( - modifier = modifier.wrapContentHeight() + modifier = modifier + .testTag(SkeletonTestTags.SKELETON_TEXT) + .wrapContentHeight() ) { LineSkeleton( infiniteTransition = infiniteTransition, @@ -87,6 +91,7 @@ fun CircleSkeleton( val skeletonColor by skeletonColorTransition(infiniteTransition, style) Box( modifier = modifier + .testTag(SkeletonTestTags.SKELETON_CIRCLE) .clip(shape = CircleShape) .background(skeletonColor) .size(40.dp) @@ -102,6 +107,7 @@ fun RowSkeleton( ) { Row( modifier = modifier + .testTag(SkeletonTestTags.SKELETON_ROW) .fillMaxWidth() .wrapContentHeight(), ) { @@ -129,6 +135,7 @@ fun RectangleSkeleton( val skeletonColor by skeletonColorTransition(infiniteTransition, style) Box( modifier = modifier + .testTag(SkeletonTestTags.SKELETON_RECTANGLE) .fillMaxWidth() .clip(shape = RoundedCornerShape(MisticaTheme.radius.containerBorderRadius)) .background(skeletonColor) @@ -191,4 +198,12 @@ fun SkeletonPreview() { enum class SkeletonStyle { Default, Inverse, -} \ No newline at end of file +} + +object SkeletonTestTags { + const val SKELETON_LINE = "skeleton_line" + const val SKELETON_TEXT = "skeleton_text" + const val SKELETON_CIRCLE = "skeleton_circle" + const val SKELETON_ROW = "skeleton_row" + const val SKELETON_RECTANGLE = "skeleton_rectangle" +}