From 88e6a3596c00a17656276d3ad6eb2a958e28f3c5 Mon Sep 17 00:00:00 2001 From: Eric Ampire Date: Sat, 4 Sep 2021 16:14:49 +0200 Subject: [PATCH] Customize the font --- .../presentation/theme/Font.kt | 65 ++++++++++++++++++ .../presentation/theme/Theme.kt | 15 ++++- .../presentation/theme/Type.kt | 67 +++++++++++++++---- 3 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Font.kt diff --git a/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Font.kt b/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Font.kt new file mode 100644 index 0000000..6b73a0e --- /dev/null +++ b/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Font.kt @@ -0,0 +1,65 @@ +package com.ericampire.android.androidstudycase.presentation.theme + +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight +import com.ericampire.android.androidstudycase.R + + +val Roboto = FontFamily( + Font( + resId = R.font.roboto_black, + weight = FontWeight.Black + ), + Font( + resId = R.font.roboto_bold, + weight = FontWeight.Bold + ), + Font( + resId = R.font.roboto_black_italic, + weight = FontWeight.Black, + style = FontStyle.Italic + ), + Font( + resId = R.font.roboto_italic, + style = FontStyle.Italic + ), + Font( + resId = R.font.roboto_light, + weight = FontWeight.Light + ), + Font( + resId = R.font.roboto_light_italic, + weight = FontWeight.Light, + style = FontStyle.Italic + ), + Font( + resId = R.font.roboto_bold_italic, + weight = FontWeight.Bold, + style = FontStyle.Italic, + ), + Font( + resId = R.font.roboto_medium_italic, + weight = FontWeight.Medium, + style = FontStyle.Italic, + ), + Font( + resId = R.font.roboto_medium, + weight = FontWeight.Medium, + ), + Font( + resId = R.font.roboto_thin, + weight = FontWeight.Thin, + ), + Font( + resId = R.font.roboto_thin_italic, + weight = FontWeight.Thin, + style = FontStyle.Italic, + ), + Font( + resId = R.font.roboto_regular, + weight = FontWeight.Normal, + style = FontStyle.Normal, + ), +) \ No newline at end of file diff --git a/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Theme.kt b/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Theme.kt index d5eb658..39b8c7e 100644 --- a/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Theme.kt +++ b/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Theme.kt @@ -6,11 +6,18 @@ import androidx.compose.material.darkColors import androidx.compose.material.lightColors import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color +import com.google.accompanist.insets.ProvideWindowInsets private val DarkColorPalette = darkColors( primary = AppColor.Purple200, primaryVariant = AppColor.Purple700, - secondary = AppColor.Teal200 + secondary = AppColor.Teal200, + background = Color.Black, + surface = Color.Black, + onPrimary = Color.Black, + onSecondary = Color.White, + onBackground = Color.White, + onSurface = Color.White, ) private val LightColorPalette = lightColors( @@ -40,6 +47,10 @@ fun AndroidStudyCaseTheme( colors = colors, typography = Typography, shapes = Shapes, - content = content + content = { + ProvideWindowInsets { + content() + } + } ) } \ No newline at end of file diff --git a/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Type.kt b/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Type.kt index 1d632b7..f798ef7 100644 --- a/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Type.kt +++ b/app/src/main/java/com/ericampire/android/androidstudycase/presentation/theme/Type.kt @@ -2,26 +2,65 @@ package com.ericampire.android.androidstudycase.presentation.theme import androidx.compose.material.Typography import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp val Typography = Typography( - body1 = TextStyle( - fontFamily = FontFamily.Default, + subtitle1 = TextStyle( + fontFamily = Roboto, fontWeight = FontWeight.Normal, - fontSize = 16.sp - ) - /* Other default text styles to override + fontSize = 14.sp, + letterSpacing = 0.15.sp + ), + subtitle2 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.Medium, + fontSize = 14.sp, + letterSpacing = 0.1.sp + ), + body1 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.Normal, + fontSize = 14.sp + ), button = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.W500, - fontSize = 14.sp + fontFamily = Roboto, + fontWeight = FontWeight.W500, + fontSize = 12.sp ), caption = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 12.sp - ) - */ + fontFamily = Roboto, + fontWeight = FontWeight.Normal, + fontSize = 10.sp + ), + h1 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.Bold, + fontSize = 26.sp + ), + h2 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.Bold, + fontSize = 24.sp + ), + h3 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.ExtraBold, + fontSize = 20.sp + ), + h4 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.Bold, + fontSize = 18.sp + ), + h5 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.Medium, + fontSize = 16.sp + ), + h6 = TextStyle( + fontFamily = Roboto, + fontWeight = FontWeight.SemiBold, + fontSize = 14.sp + ), ) \ No newline at end of file