Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANDROID-14825 Add fonts in Mistica Catalog app #394

Merged
merged 5 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class CatalogMainActivity : AppCompatActivity() {
private fun configureThemeDropDown() {

val styles: List<ComponentStyle> = listOf(
ComponentStyle("Movistar", R.style.MisticaTheme_Movistar, MOVISTAR),
ComponentStyle("O2", R.style.MisticaTheme_O2, O2),
ComponentStyle("Vivo", R.style.MisticaTheme_Vivo, VIVO),
ComponentStyle("Vivo New", R.style.MisticaTheme_VivoNew, VIVO_NEW),
ComponentStyle("Telefonica", R.style.MisticaTheme_Telefonica, TELEFONICA),
ComponentStyle("Blau", R.style.MisticaTheme_Blau, BLAU),
ComponentStyle("Tu", R.style.MisticaTheme_Tu, TU),
ComponentStyle("O2New", R.style.MisticaTheme_O2New, O2_NEW),
ComponentStyle("Movistar", R.style.CatalogMovistar, MOVISTAR),
ComponentStyle("O2", R.style.CatalogO2, O2),
ComponentStyle("Vivo", R.style.CatalogVivo, VIVO),
ComponentStyle("Vivo New", R.style.CatalogVivoNew, VIVO_NEW),
ComponentStyle("Telefonica", R.style.CatalogTelefonica, TELEFONICA),
ComponentStyle("Blau", R.style.CatalogBlau, BLAU),
ComponentStyle("Tu", R.style.CatalogTu, TU),
ComponentStyle("O2New", R.style.CatalogO2New, O2_NEW),
)

findViewById<DropDownInput>(R.id.drop_down_themes)?.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ import com.telefonica.mistica.catalog.ui.classic.components.TabsCatalogFragment
import com.telefonica.mistica.catalog.ui.classic.components.TagsCatalogFragment
import com.telefonica.mistica.catalog.ui.classic.components.TextPresetsCatalogFragment
import com.telefonica.mistica.catalog.ui.classic.components.TitleCatalogFragment
import com.telefonica.mistica.catalog.ui.compose.common.CatalogBlauBrand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogMovistarBrand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogO2Brand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogO2NewBrand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogTelefonicaBrand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogTuBrand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogVivoBrand
import com.telefonica.mistica.catalog.ui.compose.common.CatalogVivoNewBrand
import com.telefonica.mistica.catalog.ui.compose.common.ComponentComposeFragment
import com.telefonica.mistica.catalog.ui.compose.components.Badges
import com.telefonica.mistica.catalog.ui.compose.components.Buttons
Expand All @@ -63,7 +71,6 @@ import com.telefonica.mistica.catalog.ui.compose.components.Tags
import com.telefonica.mistica.catalog.ui.compose.components.Texts
import com.telefonica.mistica.catalog.ui.compose.components.Titles
import com.telefonica.mistica.compose.theme.MisticaTheme
import com.telefonica.mistica.compose.theme.brand.BlauBrand
import com.telefonica.mistica.compose.theme.brand.Brand
import com.telefonica.mistica.compose.theme.brand.BrandType
import com.telefonica.mistica.compose.theme.brand.BrandType.BLAU
Expand All @@ -74,13 +81,6 @@ import com.telefonica.mistica.compose.theme.brand.BrandType.TELEFONICA
import com.telefonica.mistica.compose.theme.brand.BrandType.TU
import com.telefonica.mistica.compose.theme.brand.BrandType.VIVO
import com.telefonica.mistica.compose.theme.brand.BrandType.VIVO_NEW
import com.telefonica.mistica.compose.theme.brand.MovistarBrand
import com.telefonica.mistica.compose.theme.brand.O2Brand
import com.telefonica.mistica.compose.theme.brand.O2NewBrand
import com.telefonica.mistica.compose.theme.brand.TelefonicaBrand
import com.telefonica.mistica.compose.theme.brand.TuBrand
import com.telefonica.mistica.compose.theme.brand.VivoBrand
import com.telefonica.mistica.compose.theme.brand.VivoNewBrand

class ComponentCatalogActivity : AppCompatActivity() {

Expand Down Expand Up @@ -322,14 +322,14 @@ class ComponentCatalogActivity : AppCompatActivity() {
private fun setUpThemes() {
classicThemeOverride = intent.getIntExtra(EXTRA_CLASSIC_THEME, DEFAULT_CLASSIC_THEME)
composeThemeOverride = when ((intent.getSerializableExtra(EXTRA_COMPOSE_THEME) ?: DEFAULT_BRAND_TYPE) as BrandType) {
MOVISTAR -> MovistarBrand
O2 -> O2Brand
VIVO -> VivoBrand
VIVO_NEW -> VivoNewBrand
TELEFONICA -> TelefonicaBrand
BLAU -> BlauBrand
TU -> TuBrand
O2_NEW -> O2NewBrand
MOVISTAR -> CatalogMovistarBrand
O2 -> CatalogO2Brand
VIVO -> CatalogVivoBrand
VIVO_NEW -> CatalogVivoNewBrand
TELEFONICA -> CatalogTelefonicaBrand
BLAU -> CatalogBlauBrand
TU -> CatalogTuBrand
O2_NEW -> CatalogO2NewBrand
}

setTheme(classicThemeOverride)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.telefonica.mistica.catalog.ui.compose.common

import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.TextUnit
import com.telefonica.mistica.catalog.R
import com.telefonica.mistica.compose.theme.brand.Brand
import com.telefonica.mistica.compose.theme.brand.MovistarBrand
import com.telefonica.mistica.compose.theme.brand.O2Brand
import com.telefonica.mistica.compose.theme.brand.O2NewBrand
import com.telefonica.mistica.compose.theme.brand.TelefonicaBrand
import com.telefonica.mistica.compose.theme.brand.TuBrand
import com.telefonica.mistica.compose.theme.brand.VivoBrand
import com.telefonica.mistica.compose.theme.brand.VivoNewBrand
import com.telefonica.mistica.compose.theme.brushes.MisticaBrushes
import com.telefonica.mistica.compose.theme.color.MisticaColors
import com.telefonica.mistica.compose.theme.values.MisticaRadius

abstract class CatalogBrand(
baseBrand: Brand,
val theme: Int,
) : Brand {
override val compatibilityTheme: Int
get() = theme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now seeing this, it is necessary that theme is computed every time that compatibilityTheme is retrieved? cc: @yamal-alm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can use override val compatibilityTheme: Int = theme instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

override val lightColors: MisticaColors = baseBrand.lightColors
override val darkColors: MisticaColors = baseBrand.darkColors
override val lightBrushes: MisticaBrushes = baseBrand.lightBrushes
override val darkBrushes: MisticaBrushes = baseBrand.darkBrushes
override val preset5FontWeight: FontWeight = baseBrand.preset5FontWeight
override val preset6FontWeight: FontWeight = baseBrand.preset6FontWeight
override val preset7FontWeight: FontWeight = baseBrand.preset7FontWeight
override val preset8FontWeight: FontWeight = baseBrand.preset8FontWeight
override val preset9FontWeight: FontWeight = baseBrand.preset9FontWeight
override val preset10FontWeight: FontWeight = baseBrand.preset10FontWeight
override val cardTitleFontWeight: FontWeight = baseBrand.cardTitleFontWeight
override val buttonFontWeight: FontWeight = baseBrand.buttonFontWeight
override val linkFontWeight: FontWeight = baseBrand.linkFontWeight
override val title1FontWeight: FontWeight = baseBrand.title1FontWeight
override val title2FontWeight: FontWeight = baseBrand.title2FontWeight
override val title3FontWeight: FontWeight = baseBrand.title3FontWeight
override val title3FontSize: TextUnit = baseBrand.title3FontSize
override val indicatorFontWeight: FontWeight = baseBrand.indicatorFontWeight
override val tabsLabelFontWeight: FontWeight = baseBrand.tabsLabelFontWeight
override val tabsLabelFontSize: TextUnit = baseBrand.tabsLabelFontSize
override val radius: MisticaRadius = baseBrand.radius
override val fontFamily: FontFamily = baseBrand.fontFamily
}

object CatalogMovistarBrand : CatalogBrand(MovistarBrand, R.style.CatalogMovistar) {
override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.onair_light, FontWeight.Light),
Font(R.font.onair_regular, FontWeight.Normal),
Font(R.font.onair_medium, FontWeight.Medium),
)
}

object CatalogO2Brand : CatalogBrand(O2Brand, R.style.CatalogO2) {
Copy link
Member

@dagonco dagonco Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor, could we have O2 with his brother O2New together as Vivo is with its two themes?
Also, check XML too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.onair_light, FontWeight.Light),
Font(R.font.onair_regular, FontWeight.Normal),
Font(R.font.onair_medium, FontWeight.Medium),
)
}

object CatalogVivoBrand : CatalogBrand(VivoBrand, R.style.CatalogVivo) {
override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.vivo_type_light, FontWeight.Light),
Font(R.font.vivo_type_regular, FontWeight.Normal),
Font(R.font.vivo_type_medium, FontWeight.Medium),
)
}

object CatalogVivoNewBrand : CatalogBrand(VivoNewBrand, R.style.CatalogVivoNew) {
override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.vivo_type_light, FontWeight.Light),
Font(R.font.vivo_type_regular, FontWeight.Normal),
Font(R.font.vivo_type_medium, FontWeight.Medium),
)
}

object CatalogTelefonicaBrand : CatalogBrand(TelefonicaBrand, R.style.CatalogTelefonica) {
override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.telefonica_sans_light, FontWeight.Light),
Font(R.font.telefonica_sans_regular, FontWeight.Normal),
Font(R.font.telefonica_sans_medium, FontWeight.Medium),
)
}

object CatalogBlauBrand : CatalogBrand(TelefonicaBrand, R.style.CatalogBlau)

object CatalogTuBrand : CatalogBrand(TuBrand, R.style.CatalogTu) {
override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.telefonica_sans_light, FontWeight.Light),
Font(R.font.telefonica_sans_regular, FontWeight.Normal),
Font(R.font.telefonica_sans_medium, FontWeight.Medium),
)
}

object CatalogO2NewBrand : CatalogBrand(O2NewBrand, R.style.CatalogO2New) {
override val fontFamily: FontFamily
get() = FontFamily(
Font(R.font.onair_light, FontWeight.Light),
Font(R.font.onair_regular, FontWeight.Normal),
Font(R.font.onair_medium, FontWeight.Medium),
)
}
Binary file added catalog/src/main/res/font/onair_light.ttf
Binary file not shown.
Binary file added catalog/src/main/res/font/onair_medium.ttf
Binary file not shown.
Binary file added catalog/src/main/res/font/onair_regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added catalog/src/main/res/font/vivo_type_light.ttf
Binary file not shown.
Binary file added catalog/src/main/res/font/vivo_type_medium.ttf
Binary file not shown.
Binary file not shown.
48 changes: 48 additions & 0 deletions catalog/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="CatalogMovistar" parent="MisticaTheme.Movistar">
<item name="font_family_light">@font/onair_light</item>
<item name="font_family_regular">@font/onair_regular</item>
<item name="font_family_medium">@font/onair_medium</item>
</style>

<style name="CatalogO2" parent="MisticaTheme.O2">
<item name="font_family_light">@font/onair_light</item>
<item name="font_family_regular">@font/onair_regular</item>
<item name="font_family_medium">@font/onair_medium</item>
</style>

<style name="CatalogVivo" parent="MisticaTheme.Vivo">
<item name="font_family_light">@font/vivo_type_light</item>
<item name="font_family_regular">@font/vivo_type_regular</item>
<item name="font_family_medium">@font/vivo_type_medium</item>
</style>

<style name="CatalogVivoNew" parent="MisticaTheme.VivoNew">
<item name="font_family_light">@font/vivo_type_light</item>
<item name="font_family_regular">@font/vivo_type_regular</item>
<item name="font_family_medium">@font/vivo_type_medium</item>
</style>

<style name="CatalogTelefonica" parent="MisticaTheme.Telefonica">
<item name="font_family_light">@font/telefonica_sans_light</item>
<item name="font_family_regular">@font/telefonica_sans_regular</item>
<item name="font_family_medium">@font/telefonica_sans_medium</item>
</style>

<style name="CatalogBlau" parent="MisticaTheme.Blau"/>

<style name="CatalogTu" parent="MisticaTheme.Tu">
<item name="font_family_light">@font/telefonica_sans_light</item>
<item name="font_family_regular">@font/telefonica_sans_regular</item>
<item name="font_family_medium">@font/telefonica_sans_medium</item>
</style>

<style name="CatalogO2New" parent="MisticaTheme.O2New">
<item name="font_family_light">@font/onair_light</item>
<item name="font_family_regular">@font/onair_regular</item>
<item name="font_family_medium">@font/onair_medium</item>
</style>

</resources>
Loading