Skip to content

Commit

Permalink
SMARTWIFI-10829 tags update (#404)
Browse files Browse the repository at this point in the history
* update tag tokens SMARTWIFI-10829

* remove Tag Inverse (breaking change, use Active instead) SMARTWIFI-10829
  • Loading branch information
jeprubio authored Jan 14, 2025
1 parent df121ea commit 6aa7e8c
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.telefonica.mistica.tag.TagStyle
import com.telefonica.mistica.tag.TagView.Companion.TYPE_ACTIVE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_ERROR
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INACTIVE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INVERSE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_PROMO
import com.telefonica.mistica.tag.TagView.Companion.TYPE_SUCCESS
import com.telefonica.mistica.tag.TagView.Companion.TYPE_WARNING
Expand Down Expand Up @@ -132,7 +131,6 @@ class DataCardFragment : Fragment() {
SUCCESS(TYPE_SUCCESS),
WARNING(TYPE_WARNING),
ERROR(TYPE_ERROR),
INVERSE(TYPE_INVERSE),
}

private enum class IconTypes(@AttrRes val iconType: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.telefonica.mistica.list.MisticaRecyclerView
import com.telefonica.mistica.list.model.ImageDimensions
import com.telefonica.mistica.tag.TagStyle
import com.telefonica.mistica.tag.TagView
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INVERSE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_PROMO
import com.telefonica.mistica.util.convertDpToPx

Expand Down Expand Up @@ -194,7 +193,7 @@ class ListsCatalogFragment : Fragment() {
val headlineText = "Headline"
setHeadlineLayout(layoutRes = R.layout.list_row_tag_headline, contentDescription = headlineText)
(getHeadline()!! as TagView).apply {
setTagStyle(if (withInverseBackground) TYPE_INVERSE else withHeadlineStyle)
setTagStyle(withHeadlineStyle)
text = headlineText
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class TagsCatalogFragment : Fragment() {
val tagViews = listOf<TagView>(
view.findViewById(R.id.regular_tag),
view.findViewById(R.id.regular_with_icon_tag),
view.findViewById(R.id.inverse_tag),
view.findViewById(R.id.inverse_with_icon_tag),
)

textInput.addTextChangedListener(object : TextWatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ private enum class TagColors(@AttrRes val tagStyle: Int) {
SUCCESS(TagView.TYPE_SUCCESS),
WARNING(TagView.TYPE_WARNING),
ERROR(TagView.TYPE_ERROR),
INVERSE(TagView.TYPE_INVERSE),
}

private enum class IconTypes(@AttrRes val iconType: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ private enum class TagColorsValues(@AttrRes val tagStyle: Int) {
SUCCESS(TagView.TYPE_SUCCESS),
WARNING(TagView.TYPE_WARNING),
ERROR(TagView.TYPE_ERROR),
INVERSE(TagView.TYPE_INVERSE),
}

private val aspectRatioLabelsMaps = mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.material.Divider
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
Expand All @@ -34,19 +32,11 @@ fun Tags() {
Column(
modifier = Modifier.padding(vertical = 32.dp, horizontal = 16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
verticalArrangement = Arrangement.Top,
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Surface(
color = MisticaTheme.colors.brand,
modifier = Modifier
.fillMaxWidth()
.height(60.dp)
) {
Tag(text = "Inverse", style = TagView.TYPE_INVERSE, modifier = Modifier.padding(8.dp))
}
LazyVerticalGrid(
columns = GridCells.Fixed(3),
modifier = Modifier.padding(16.dp)
Expand All @@ -58,15 +48,6 @@ fun Tags() {
item { Tag(text = "Warning", style = TagView.TYPE_WARNING, modifier = Modifier.padding(4.dp)) }
item { Tag(text = "Error", style = TagView.TYPE_ERROR, modifier = Modifier.padding(4.dp)) }
}
Surface(
color = MisticaTheme.colors.brand,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp)
.height(60.dp)
) {
Tag(text = "Inverse", style = TagView.TYPE_INVERSE, modifier = Modifier.padding(8.dp), icon = R.drawable.icn_cross)
}
LazyVerticalGrid(
columns = GridCells.Fixed(3),
modifier = Modifier.padding(16.dp)
Expand All @@ -85,22 +66,6 @@ fun Tags() {
Tag(text = customText.value.text, style = TagView.TYPE_PROMO, modifier = Modifier.padding(top = 16.dp))
Tag(text = customText.value.text, style = TagView.TYPE_PROMO, modifier = Modifier.padding(top = 8.dp), icon = R.drawable.icn_cross)

Surface(
color = MisticaTheme.colors.brand,
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp)
.height(96.dp)
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Tag(text = customText.value.text, style = TagView.TYPE_INVERSE)
Tag(text = customText.value.text, style = TagView.TYPE_INVERSE, modifier = Modifier.padding(top = 8.dp), icon = R.drawable.icn_cross)
}
}

TextField(
value = customText.value,
onValueChange = { customText.value = it },
Expand Down
75 changes: 0 additions & 75 deletions catalog/src/main/res/layout/screen_tags_catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@
android:padding="16dp"
>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorBrand"
android:layout_marginTop="16dp"
android:padding="16dp"
android:gravity="center"
>

<com.telefonica.mistica.tag.TagView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_gravity="center"
android:text="Inverse"
app:tagStyle="inverse"
tools:text="@tools:sample/full_names"
/>

</FrameLayout>

<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -98,28 +77,6 @@
/>
</GridLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorBrand"
android:layout_marginTop="16dp"
android:padding="16dp"
android:gravity="center"
>

<com.telefonica.mistica.tag.TagView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnWeight="1"
android:layout_gravity="center"
android:text="Inverse"
app:tagStyle="inverse"
app:tagIcon="@drawable/icn_cross"
tools:text="@tools:sample/full_names"
/>

</FrameLayout>

<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -222,38 +179,6 @@
tools:text="@tools:sample/full_names"
/>

<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:layout_height="wrap_content"
android:padding="16dp"
android:background="?attr/colorBrand"
android:orientation="vertical"
>

<com.telefonica.mistica.tag.TagView
android:id="@+id/inverse_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Promotion"
app:tagStyle="inverse"
tools:text="@tools:sample/full_names"
/>

<com.telefonica.mistica.tag.TagView
android:id="@+id/inverse_with_icon_tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Promotion"
app:tagStyle="inverse"
app:tagIcon="@drawable/icn_cross"
tools:text="@tools:sample/full_names"
/>

</LinearLayout>

<com.telefonica.mistica.input.TextInput
android:id="@+id/textInput"
android:layout_width="match_parent"
Expand Down
25 changes: 7 additions & 18 deletions library/src/main/java/com/telefonica/mistica/compose/tag/Tag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand All @@ -33,7 +32,6 @@ import com.telefonica.mistica.tag.TagStyle
import com.telefonica.mistica.tag.TagView.Companion.TYPE_ACTIVE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_ERROR
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INACTIVE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INVERSE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_PROMO
import com.telefonica.mistica.tag.TagView.Companion.TYPE_SUCCESS
import com.telefonica.mistica.tag.TagView.Companion.TYPE_WARNING
Expand Down Expand Up @@ -122,14 +120,6 @@ internal fun TagPreview() {
.padding(vertical = 32.dp, horizontal = 16.dp)
.background(MisticaTheme.colors.backgroundContainer),
) {
Surface(
color = MisticaTheme.colors.brand,
modifier = Modifier
.fillMaxWidth()
.height(60.dp)
) {
Tag(text = "Inverse", style = TYPE_INVERSE, modifier = Modifier.padding(8.dp), icon = android.R.drawable.ic_lock_power_off)
}
LazyVerticalGrid(
columns = GridCells.Fixed(3),
modifier = Modifier.padding(16.dp)
Expand All @@ -148,12 +138,11 @@ internal fun TagPreview() {
@Composable
@Suppress("CyclomaticComplexMethod")
private fun Int.getStyle() = when (this) {
TYPE_PROMO -> with(MisticaTheme.colors) { promoLow to promoHigh }
TYPE_ACTIVE -> with(MisticaTheme.colors) { brandLow to brand }
TYPE_INACTIVE -> with(MisticaTheme.colors) { neutralLow to neutralMedium }
TYPE_SUCCESS -> with(MisticaTheme.colors) { successLow to successHigh }
TYPE_WARNING -> with(MisticaTheme.colors) { warningLow to warningHigh }
TYPE_ERROR -> with(MisticaTheme.colors) { errorLow to errorHigh }
TYPE_INVERSE -> with(MisticaTheme.colors) { inverse to brand }
else -> with(MisticaTheme.colors) { promoLow to promoHigh }
TYPE_PROMO -> with(MisticaTheme.colors) { tagBackgroundPromo to tagTextPromo }
TYPE_ACTIVE -> with(MisticaTheme.colors) { tagBackgroundActive to tagTextActive }
TYPE_INACTIVE -> with(MisticaTheme.colors) { tagBackgroundInactive to tagTextInactive }
TYPE_SUCCESS -> with(MisticaTheme.colors) { tagBackgroundSuccess to tagTextSuccess }
TYPE_WARNING -> with(MisticaTheme.colors) { tagBackgroundWarning to tagTextWarning }
TYPE_ERROR -> with(MisticaTheme.colors) { tagBackgroundError to tagTextError }
else -> with(MisticaTheme.colors) { tagBackgroundPromo to tagTextPromo }
}
18 changes: 7 additions & 11 deletions library/src/main/java/com/telefonica/mistica/tag/TagView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.telefonica.mistica.R
import com.telefonica.mistica.tag.TagView.Companion.TYPE_ACTIVE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_ERROR
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INACTIVE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_INVERSE
import com.telefonica.mistica.tag.TagView.Companion.TYPE_PROMO
import com.telefonica.mistica.tag.TagView.Companion.TYPE_SUCCESS
import com.telefonica.mistica.tag.TagView.Companion.TYPE_WARNING
Expand All @@ -28,7 +27,6 @@ import com.telefonica.mistica.util.getThemeColor
TYPE_SUCCESS,
TYPE_WARNING,
TYPE_ERROR,
TYPE_INVERSE,
)
annotation class TagStyle

Expand Down Expand Up @@ -88,14 +86,13 @@ class TagView @JvmOverloads constructor(
}

private fun Int.getStyle() = when (this) {
TYPE_PROMO -> R.attr.colorPromoLow to R.attr.colorPromoHigh
TYPE_ACTIVE -> R.attr.colorBrandLow to R.attr.colorBrand
TYPE_INACTIVE -> R.attr.colorNeutralLow to R.attr.colorNeutralMedium
TYPE_SUCCESS -> R.attr.colorSuccessLow to R.attr.colorSuccessHigh
TYPE_WARNING -> R.attr.colorWarningLow to R.attr.colorWarningHigh
TYPE_ERROR -> R.attr.colorErrorLow to R.attr.colorErrorHigh
TYPE_INVERSE -> R.attr.colorInverse to R.attr.colorBrand
else -> R.attr.colorPromoLow to R.attr.colorPromoHigh
TYPE_PROMO -> R.attr.colorTagBackgroundPromo to R.attr.colorTagTextPromo
TYPE_ACTIVE -> R.attr.colorTagBackgroundActive to R.attr.colorTagTextActive
TYPE_INACTIVE -> R.attr.colorTagBackgroundInactive to R.attr.colorTagTextInactive
TYPE_SUCCESS -> R.attr.colorTagBackgroundSuccess to R.attr.colorTagTextSuccess
TYPE_WARNING -> R.attr.colorTagBackgroundWarning to R.attr.colorTagTextWarning
TYPE_ERROR -> R.attr.colorTagBackgroundError to R.attr.colorTagTextError
else -> R.attr.colorTagBackgroundPromo to R.attr.colorTagTextPromo
}

companion object {
Expand All @@ -105,6 +102,5 @@ class TagView @JvmOverloads constructor(
const val TYPE_SUCCESS = 3
const val TYPE_WARNING = 4
const val TYPE_ERROR = 5
const val TYPE_INVERSE = 6
}
}
1 change: 0 additions & 1 deletion library/src/main/res/values/attrs_components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<enum name="success" value="3" />
<enum name="warning" value="4" />
<enum name="error" value="5" />
<enum name="inverse" value="6" />
</attr>

<declare-styleable name="FeedbackScreen">
Expand Down

0 comments on commit 6aa7e8c

Please sign in to comment.