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

ADD - new presets #ANDROID-14321 #331

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -16,6 +16,14 @@ fun Texts() {
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = "Preset 10",
style = MisticaTheme.typography.preset10
)
Text(
text = "Preset 9",
style = MisticaTheme.typography.preset9
)
Text(
text = "Preset 8",
style = MisticaTheme.typography.preset8
Expand Down
16 changes: 15 additions & 1 deletion catalog/src/main/res/layout/text_presets_fragment_catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Preset 10"
android:textAppearance="@style/AppTheme.TextAppearance.Preset10" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="Preset 9"
android:textAppearance="@style/AppTheme.TextAppearance.Preset9" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -118,4 +132,4 @@

</LinearLayout>

</ScrollView>
</ScrollView>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ fun MisticaTheme(
}.apply {
updateWith(
fontFamily = brand.fontFamily,
preset10FontWeight = brand.preset10FontWeight,
preset9FontWeight = brand.preset9FontWeight,
preset8FontWeight = brand.preset8FontWeight,
preset7FontWeight = brand.preset7FontWeight,
preset6FontWeight = brand.preset6FontWeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ object BlauBrand : Brand {

override val preset8FontWeight = BlauBrandFontWeights.text8FontWeight

override val preset9FontWeight = BlauBrandFontWeights.text9FontWeight

override val preset10FontWeight = BlauBrandFontWeights.text10FontWeight

override val cardTitleFontWeight = BlauBrandFontWeights.cardTitleFontWeight

override val buttonFontWeight = BlauBrandFontWeights.buttonFontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface Brand {
val preset6FontWeight: FontWeight
val preset7FontWeight: FontWeight
val preset8FontWeight: FontWeight
val preset9FontWeight: FontWeight
val preset10FontWeight: FontWeight
val cardTitleFontWeight: FontWeight
val buttonFontWeight: FontWeight
val linkFontWeight: FontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ object MovistarBrand : Brand {

override val preset8FontWeight = MovistarBrandFontWeights.text8FontWeight

override val preset9FontWeight = MovistarBrandFontWeights.text9FontWeight

override val preset10FontWeight = MovistarBrandFontWeights.text10FontWeight

override val cardTitleFontWeight = MovistarBrandFontWeights.cardTitleFontWeight

override val buttonFontWeight = MovistarBrandFontWeights.buttonFontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ object O2Brand : Brand {

override val preset8FontWeight = O2BrandFontWeights.text8FontWeight

override val preset9FontWeight = O2BrandFontWeights.text9FontWeight

override val preset10FontWeight = O2BrandFontWeights.text10FontWeight

override val cardTitleFontWeight = O2BrandFontWeights.cardTitleFontWeight

override val buttonFontWeight = O2BrandFontWeights.buttonFontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ object TelefonicaBrand : Brand {

override val preset8FontWeight = TelefonicaBrandFontWeights.text8FontWeight

override val preset9FontWeight = TelefonicaBrandFontWeights.text9FontWeight

override val preset10FontWeight = TelefonicaBrandFontWeights.text10FontWeight

override val cardTitleFontWeight = TelefonicaBrandFontWeights.cardTitleFontWeight

override val buttonFontWeight = TelefonicaBrandFontWeights.buttonFontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ object VivoBrand : Brand {

override val preset8FontWeight = VivoBrandFontWeights.text8FontWeight

override val preset9FontWeight = VivoBrandFontWeights.text9FontWeight

override val preset10FontWeight = VivoBrandFontWeights.text10FontWeight

override val cardTitleFontWeight = VivoBrandFontWeights.cardTitleFontWeight

override val buttonFontWeight = VivoBrandFontWeights.buttonFontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ object VivoNewBrand : Brand {

override val preset8FontWeight = VivoNewBrandFontWeights.text8FontWeight

override val preset9FontWeight = VivoNewBrandFontWeights.text9FontWeight

override val preset10FontWeight = VivoNewBrandFontWeights.text10FontWeight

override val cardTitleFontWeight = VivoNewBrandFontWeights.cardTitleFontWeight

override val buttonFontWeight = VivoNewBrandFontWeights.buttonFontWeight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class MisticaTypography(
private var fontFamily: FontFamily = FontFamily.SansSerif,
private var defaultTextColor: Color = Color.Unspecified,
) {
var preset10 by mutableStateOf(buildPreset10(), structuralEqualityPolicy())
private set

var preset9 by mutableStateOf(buildPreset9(), structuralEqualityPolicy())
private set

var preset8 by mutableStateOf(buildPreset8(), structuralEqualityPolicy())
private set

Expand Down Expand Up @@ -89,6 +95,24 @@ class MisticaTypography(
color = defaultTextColor,
)

private fun buildPreset10(
fontWeight: FontWeight = FontWeight.Bold,
) =
buildBaseStyle().copy(
fontSize = 48.sp,
lineHeight = 56.sp,
fontWeight = fontWeight,
)

private fun buildPreset9(
fontWeight: FontWeight = FontWeight.Bold,
) =
buildBaseStyle().copy(
fontSize = 40.sp,
lineHeight = 48.sp,
fontWeight = fontWeight,
)

private fun buildPreset8(
fontWeight: FontWeight = FontWeight.Light,
) =
Expand Down Expand Up @@ -236,6 +260,8 @@ class MisticaTypography(

fun updateWith(
fontFamily: FontFamily,
preset10FontWeight: FontWeight,
preset9FontWeight: FontWeight,
preset8FontWeight: FontWeight,
preset7FontWeight: FontWeight,
preset6FontWeight: FontWeight,
Expand All @@ -250,6 +276,8 @@ class MisticaTypography(
presetTabsLabelFontSize: TextUnit,
) {
this.fontFamily = fontFamily
preset10 = buildPreset10(fontWeight = preset10FontWeight)
preset9 = buildPreset9(fontWeight = preset9FontWeight)
preset8 = buildPreset8(fontWeight = preset8FontWeight)
preset7 = buildPreset7(fontWeight = preset7FontWeight)
preset6 = buildPreset6(fontWeight = preset6FontWeight)
Expand Down
16 changes: 15 additions & 1 deletion library/src/main/res/values/styles_fonts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
<item name="android:letterSpacing">0.0</item>
</style>

<style name="AppTheme.TextAppearance.Preset10">
<item name="android:textSize">48sp</item>
<item name="lineHeight">56sp</item>
<item name="android:fontFamily">?text10Font</item>
<item name="android:textStyle">?text10TextStyle</item>
</style>

<style name="AppTheme.TextAppearance.Preset9">
<item name="android:textSize">40sp</item>
<item name="lineHeight">48sp</item>
<item name="android:fontFamily">?text9Font</item>
<item name="android:textStyle">?text9TextStyle</item>
</style>

<style name="AppTheme.TextAppearance.Preset8">
<item name="android:textSize">32sp</item>
<item name="lineHeight">40sp</item>
Expand Down Expand Up @@ -123,4 +137,4 @@
<item name="android:textStyle">?tabsLabelTextStyle</item>
</style>

</resources>
</resources>
Loading