NTP-15317 | FontUtil Optimization (#633)

This commit is contained in:
Shivam Goyal
2024-11-26 00:25:26 +05:30
committed by GitHub
parent 6a4a206e1d
commit c19691f61f
20 changed files with 330 additions and 157 deletions

View File

@@ -10,12 +10,12 @@ package com.navi.uitron.demo
import android.content.Context
import android.view.View
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.media3.datasource.cache.SimpleCache
import com.navi.alfred.AlfredManager
import com.navi.uitron.IUiTronDependencyProvider
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.model.UiTronConfig
import com.navi.uitron.model.ui.OutlinedTextFieldValueTransformation
import com.navi.uitron.model.ui.UiTronShape
@@ -24,49 +24,34 @@ import com.navi.uitron.utils.SPACE
class UiTronDependencyProvider : IUiTronDependencyProvider {
private val ttFontFamily =
FontFamily(
Font(
getFontStyle(IUiTronDependencyProvider.FontWeightEnum.TT_MEDIUM),
FontWeight.Medium
),
Font(getFontStyle(IUiTronDependencyProvider.FontWeightEnum.TT_BOLD), FontWeight.Bold),
Font(
getFontStyle(IUiTronDependencyProvider.FontWeightEnum.TT_SEMI_BOLD),
FontWeight.SemiBold
),
Font(
getFontStyle(IUiTronDependencyProvider.FontWeightEnum.TT_REGULAR),
FontWeight.Normal
)
)
private val config by lazy { UiTronConfig(enableBuildModifier = true) }
override fun getFontFamily(fontFamily: String?): FontFamily {
return when (fontFamily) {
TT_FONT_FAMILY -> ttFontFamily
else -> ttFontFamily
return naviFontFamily
}
override fun getFontWeight(fontWeight: String?): FontWeight {
return com.navi.uitron.demo.font.getFontWeight(fontWeight)
}
override fun getIconResourceId(iconCode: String?): Int? {
return if (iconCode == "test_icon") {
R.drawable.uitron
} else {
null
}
}
private fun getFontStyle(fontWeight: IUiTronDependencyProvider.FontWeightEnum?): Int =
getFontStyle(fontWeight?.name)
private fun getFontStyle(fontWeightName: String?) =
when (fontWeightName) {
IUiTronDependencyProvider.FontWeightEnum.TT_MEDIUM.name -> R.font.tt_medium
IUiTronDependencyProvider.FontWeightEnum.TT_BOLD.name -> R.font.tt_bold
IUiTronDependencyProvider.FontWeightEnum.TT_SEMI_BOLD.name -> R.font.tt_semi_bold
IUiTronDependencyProvider.FontWeightEnum.TT_REGULAR.name -> R.font.tt_regular
else -> R.font.tt_regular
override fun getLottieResourceId(lottieCode: String?): Int? {
return if (lottieCode == "test_lottie") {
R.raw.uitron
} else {
null
}
}
override fun getFontWeight(fontWeight: String?): FontWeight {
return when (fontWeight) {
IUiTronDependencyProvider.FontWeightEnum.TT_MEDIUM.name -> FontWeight.Medium
IUiTronDependencyProvider.FontWeightEnum.TT_BOLD.name -> FontWeight.Bold
IUiTronDependencyProvider.FontWeightEnum.TT_SEMI_BOLD.name -> FontWeight.SemiBold
else -> FontWeight.Normal
}
override fun getShape(shape: UiTronShape?): Shape? {
return null
}
override fun getTransformedText(
@@ -76,6 +61,10 @@ class UiTronDependencyProvider : IUiTronDependencyProvider {
return null
}
override fun getUiTronConfig(): UiTronConfig {
return config
}
override fun numberToWords(amount: String): String {
try {
val number = amount.toDouble().toInt().toString()
@@ -149,22 +138,6 @@ class UiTronDependencyProvider : IUiTronDependencyProvider {
return EMPTY
}
override fun getIconResourceId(iconCode: String?): Int? {
return if (iconCode == "test_icon") {
R.drawable.uitron
} else {
null
}
}
override fun getLottieResourceId(lottieCode: String?): Int? {
return if (lottieCode == "test_lottie") {
R.raw.uitron
} else {
null
}
}
private fun twoDigitNumberToWords(num: Int): String {
when (num) {
0 -> return "zero"
@@ -212,18 +185,6 @@ class UiTronDependencyProvider : IUiTronDependencyProvider {
override fun logException(e: Exception) {}
override fun getUiTronConfig(): UiTronConfig {
return UiTronConfig(enableBuildModifier = true)
}
override fun getShape(shape: UiTronShape?): Shape? {
return null
}
override fun getMedia3SimpleCache(): SimpleCache {
return MainApplication.instance.media3SimpleCache
}
override fun maskSensitiveUiTronComposable(
id: String,
left: Float?,
@@ -250,7 +211,7 @@ class UiTronDependencyProvider : IUiTronDependencyProvider {
AlfredManager.sensitiveComposeRepository.blurSensitiveScreen(blur)
}
companion object {
private const val TT_FONT_FAMILY = "ttComposeFontFamily"
override fun getMedia3SimpleCache(): SimpleCache {
return MainApplication.instance.media3SimpleCache
}
}

View File

@@ -57,6 +57,7 @@ import com.navi.uitron.demo.dazzledesignsystem.db.entity.WidgetTemplate
import com.navi.uitron.demo.dazzledesignsystem.models.BottomSheetData
import com.navi.uitron.demo.dazzledesignsystem.models.BottomSheetType
import com.navi.uitron.demo.dazzledesignsystem.viewmodel.DazzleViewModel
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.theme.Black191919
import com.navi.uitron.demo.theme.Black1C1C1C
import com.navi.uitron.demo.theme.Blue0276FE
@@ -65,7 +66,6 @@ import com.navi.uitron.demo.theme.GrayE8E8E8
import com.navi.uitron.demo.theme.Purple1F002A
import com.navi.uitron.demo.theme.Purple3C0050
import com.navi.uitron.demo.theme.WhiteFCFCFD
import com.navi.uitron.demo.theme.fontFamily
@Composable
fun BottomSheetContent(
@@ -176,7 +176,7 @@ fun FilterBottomSheet(viewModel: DazzleViewModel) {
style =
TextStyle(
fontSize = 14.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight(600),
color = Purple3C0050,
textAlign = TextAlign.Center,
@@ -203,7 +203,7 @@ fun FilterBottomSheet(viewModel: DazzleViewModel) {
style =
TextStyle(
fontSize = 14.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight(600),
color = WhiteFCFCFD,
textAlign = TextAlign.Center,
@@ -287,7 +287,7 @@ fun TabItemView(
style =
TextStyle(
fontSize = 14.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight(400),
color = Black1C1C1C
),
@@ -321,7 +321,7 @@ fun FiltersList(selectedFilterType: String, viewModel: DazzleViewModel) {
style =
TextStyle(
fontSize = 16.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight(400),
color = Black191919,
)

View File

@@ -42,10 +42,10 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.navi.uitron.demo.R
import com.navi.uitron.demo.dazzledesignsystem.models.BottomSheetType
import com.navi.uitron.demo.dazzledesignsystem.viewmodel.DazzleViewModel
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.theme.GrayA8A8A8
import com.navi.uitron.demo.theme.GrayE3E5E5
import com.navi.uitron.demo.theme.WhiteF5F5F5
import com.navi.uitron.demo.theme.fontFamily
@Composable
fun Toolbar(viewModel: DazzleViewModel) {
@@ -78,7 +78,7 @@ fun Toolbar(viewModel: DazzleViewModel) {
textStyle =
TextStyle.Default.copy(
fontSize = 14.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight(400)
),
keyboardOptions =
@@ -103,7 +103,7 @@ fun Toolbar(viewModel: DazzleViewModel) {
modifier = Modifier.align(Alignment.CenterVertically),
text = stringResource(id = R.string.search),
fontSize = 14.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight(400),
color = GrayA8A8A8
)

View File

@@ -37,12 +37,12 @@ import com.navi.uitron.demo.R
import com.navi.uitron.demo.dazzledesignsystem.db.entity.WidgetTemplate
import com.navi.uitron.demo.dazzledesignsystem.models.BottomSheetType
import com.navi.uitron.demo.dazzledesignsystem.viewmodel.DazzleViewModel
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.stringToUiTronResponse
import com.navi.uitron.demo.theme.Black1C1C1C
import com.navi.uitron.demo.theme.BlueE4EEFF
import com.navi.uitron.demo.theme.GrayE8E8E8
import com.navi.uitron.demo.theme.Purple1F002A
import com.navi.uitron.demo.theme.fontFamily
import com.navi.uitron.render.UiTronRenderer
@Composable
@@ -73,7 +73,7 @@ fun WidgetItemView(widgetTemplate: WidgetTemplate?, viewModel: DazzleViewModel)
modifier =
Modifier.padding(start = 16.dp, end = 16.dp, top = 13.dp).weight(1f),
fontSize = 16.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight.Medium,
color = Black1C1C1C
)
@@ -108,7 +108,7 @@ fun WidgetItemView(widgetTemplate: WidgetTemplate?, viewModel: DazzleViewModel)
Text(
text = tag,
fontSize = 12.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight.Medium,
color = Purple1F002A,
modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp)

View File

@@ -37,7 +37,7 @@ import com.google.gson.reflect.TypeToken
import com.navi.uitron.demo.R
import com.navi.uitron.demo.designsystem.model.WidgetData
import com.navi.uitron.demo.designsystem.viewmodel.DesignSystemVM
import com.navi.uitron.demo.theme.fontFamily
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.model.UiTronResponse
import com.navi.uitron.render.UiTronRenderer
import com.navi.uitron.viewmodel.UiTronViewModel
@@ -110,7 +110,7 @@ fun SearchField(modifier: Modifier, viewModel: DesignSystemVM) {
textStyle =
TextStyle.Default.copy(
fontSize = 12.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight.SemiBold
),
keyboardOptions =
@@ -131,7 +131,7 @@ fun SearchField(modifier: Modifier, viewModel: DesignSystemVM) {
modifier = Modifier.align(Alignment.CenterVertically),
text = "Search",
fontSize = 12.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
fontWeight = FontWeight.Light,
)
}
@@ -155,7 +155,7 @@ fun UiTronWidgetView(
text = widgetData.title,
fontWeight = FontWeight(500),
fontSize = 16.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
modifier =
Modifier.constrainAs(title) {
top.linkTo(parent.top)
@@ -182,7 +182,7 @@ fun UiTronWidgetView(
text = widgetData.description,
fontWeight = FontWeight(200),
fontSize = 12.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
modifier =
Modifier.constrainAs(description) {
top.linkTo(title.bottom, 4.dp)

View File

@@ -28,8 +28,8 @@ import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.navi.uitron.demo.designsystem.model.DesignItem
import com.navi.uitron.demo.designsystem.viewmodel.DesignSystemVM
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.navigation.DESIGN_REPO
import com.navi.uitron.demo.theme.fontFamily
/**
* Copyright © 2023 by Navi Technologies Private Limited All rights reserved. Strictly confidential
@@ -45,7 +45,7 @@ fun DesignSystemScreen(
text = "Navi Design System",
fontWeight = FontWeight(800),
fontSize = 22.sp,
fontFamily = fontFamily
fontFamily = naviFontFamily
)
Spacer(modifier = Modifier.height(16.dp))
Column(
@@ -87,7 +87,7 @@ fun DesignItemView(designItem: DesignItem, navHostController: NavHostController)
text = designItem.title,
fontWeight = FontWeight(500),
fontSize = 16.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
modifier =
Modifier.constrainAs(title) {
top.linkTo(parent.top)
@@ -100,7 +100,7 @@ fun DesignItemView(designItem: DesignItem, navHostController: NavHostController)
text = designItem.description,
fontWeight = FontWeight(200),
fontSize = 12.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
modifier =
Modifier.constrainAs(description) {
top.linkTo(title.bottom, 2.dp)

View File

@@ -0,0 +1,120 @@
/*
*
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.uitron.demo.font
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import com.navi.uitron.demo.R
fun getFontStyle(fontWeight: FontWeightEnum?): Int = getFontStyle(fontWeight?.name)
fun getFontStyle(fontWeightName: String?): Int =
when (fontWeightName) {
/** Navi Headline - Regular (400) */
FontWeightEnum.NAVI_HEADLINE_REGULAR.name,
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.ROBOTO_MEDIUM.name,
FontWeightEnum.BOLD.name,
FontWeightEnum.NAVI_BOLD.name -> R.font.navi_headline_regular
/** Navi Headline - Bold (700) */
FontWeightEnum.NAVI_HEADLINE_BOLD.name,
FontWeightEnum.TT_BOLD.name -> R.font.navi_headline_bold
/** Navi Body - Regular (400) */
FontWeightEnum.NAVI_BODY_REGULAR.name,
FontWeightEnum.TT_REGULAR.name,
FontWeightEnum.ROBOTO_REGULAR.name,
FontWeightEnum.REGULAR.name,
FontWeightEnum.SEMI_BOLD.name,
FontWeightEnum.NAVI_REGULAR.name,
FontWeightEnum.NAVI_SEMI_BOLD.name -> R.font.navi_body_regular
/** Navi Body - Demi Bold (600) */
FontWeightEnum.NAVI_BODY_DEMI_BOLD.name,
FontWeightEnum.TT_SEMI_BOLD.name,
FontWeightEnum.ROBOTO_BOLD.name,
FontWeightEnum.EXTRA_BOLD.name,
FontWeightEnum.NAVI_EXTRA_BOLD.name,
FontWeightEnum.NAVI_BLACK.name -> R.font.navi_body_demi_bold
/** Fallback */
else -> R.font.navi_body_regular
}
val naviFontFamily: FontFamily =
FontFamily(
/** Navi Headline - Regular (400) */
Font(getFontStyle(FontWeightEnum.NAVI_HEADLINE_REGULAR), FontWeight.Medium),
/** Navi Headline - Bold (700) */
Font(getFontStyle(FontWeightEnum.NAVI_HEADLINE_BOLD), FontWeight.Bold),
/** Navi Body - Regular (400) */
Font(getFontStyle(FontWeightEnum.NAVI_BODY_REGULAR), FontWeight.Normal),
/** Navi Body - Demi Bold (600) */
Font(getFontStyle(FontWeightEnum.NAVI_BODY_DEMI_BOLD), FontWeight.SemiBold),
)
fun getFontWeight(fontWeight: FontWeightEnum?): FontWeight = getFontWeight(fontWeight?.name)
fun getFontWeight(fontWeightName: String?): FontWeight =
when (fontWeightName) {
/** Navi Headline - Regular (400) */
FontWeightEnum.NAVI_HEADLINE_REGULAR.name,
FontWeightEnum.TT_MEDIUM.name,
FontWeightEnum.ROBOTO_MEDIUM.name,
FontWeightEnum.BOLD.name,
FontWeightEnum.NAVI_BOLD.name -> FontWeight.Medium
/** Navi Headline - Bold (700) */
FontWeightEnum.NAVI_HEADLINE_BOLD.name,
FontWeightEnum.TT_BOLD.name -> FontWeight.Bold
/** Navi Body - Regular (400) */
FontWeightEnum.NAVI_BODY_REGULAR.name,
FontWeightEnum.TT_REGULAR.name,
FontWeightEnum.ROBOTO_REGULAR.name,
FontWeightEnum.REGULAR.name,
FontWeightEnum.SEMI_BOLD.name,
FontWeightEnum.NAVI_REGULAR.name,
FontWeightEnum.NAVI_SEMI_BOLD.name -> FontWeight.Normal
/** Navi Body - Demi Bold (600) */
FontWeightEnum.NAVI_BODY_DEMI_BOLD.name,
FontWeightEnum.TT_SEMI_BOLD.name,
FontWeightEnum.ROBOTO_BOLD.name,
FontWeightEnum.EXTRA_BOLD.name,
FontWeightEnum.NAVI_EXTRA_BOLD.name,
FontWeightEnum.NAVI_BLACK.name -> FontWeight.SemiBold
/** Fallback */
else -> FontWeight.Normal
}
fun FontWeight?.getFont(): Int = getFontStyle(this?.toEnum())
fun FontWeight?.toEnum(): FontWeightEnum =
when (this) {
/** Navi Headline - Regular (400) */
FontWeight.Medium -> FontWeightEnum.NAVI_HEADLINE_REGULAR
/** Navi Headline - Bold (700) */
FontWeight.Bold -> FontWeightEnum.NAVI_HEADLINE_BOLD
/** Navi Body - Regular (400) */
FontWeight.Normal -> FontWeightEnum.NAVI_BODY_REGULAR
/** Navi Body - Demi Bold (600) */
FontWeight.SemiBold -> FontWeightEnum.NAVI_BODY_DEMI_BOLD
/** Fallback */
else -> FontWeightEnum.NAVI_BODY_REGULAR
}

View File

@@ -0,0 +1,127 @@
/*
*
* * Copyright © 2022-2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.uitron.demo.font
enum class FontWeightEnum {
/** ================================================================================= */
/** -------------------------- Navi Headline - Regular (400) ------------------------ */
/** ================================================================================= */
NAVI_HEADLINE_REGULAR,
@Deprecated(
message = "Use 'NAVI_HEADLINE_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_HEADLINE_REGULAR"),
level = DeprecationLevel.WARNING,
)
TT_MEDIUM,
@Deprecated(
message = "Use 'NAVI_HEADLINE_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_HEADLINE_REGULAR"),
level = DeprecationLevel.WARNING,
)
ROBOTO_MEDIUM,
@Deprecated(
message = "Use 'NAVI_HEADLINE_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_HEADLINE_REGULAR"),
level = DeprecationLevel.WARNING,
)
BOLD,
@Deprecated(
message = "Use 'NAVI_HEADLINE_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_HEADLINE_REGULAR"),
level = DeprecationLevel.WARNING,
)
NAVI_BOLD,
/** ================================================================================= */
/** -------------------------- Navi Headline - Bold (700) --------------------------- */
/** ================================================================================= */
NAVI_HEADLINE_BOLD,
@Deprecated(
message = "Use 'NAVI_HEADLINE_BOLD' instead.",
replaceWith = ReplaceWith(expression = "NAVI_HEADLINE_BOLD"),
level = DeprecationLevel.WARNING,
)
TT_BOLD,
/** ================================================================================= */
/** -------------------------- Navi Body - Regular (400) ---------------------------- */
/** ================================================================================= */
NAVI_BODY_REGULAR,
@Deprecated(
message = "Use 'NAVI_BODY_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_REGULAR"),
level = DeprecationLevel.WARNING,
)
TT_REGULAR,
@Deprecated(
message = "Use 'NAVI_BODY_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_REGULAR"),
level = DeprecationLevel.WARNING,
)
ROBOTO_REGULAR,
@Deprecated(
message = "Use 'NAVI_BODY_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_REGULAR"),
level = DeprecationLevel.WARNING,
)
REGULAR,
@Deprecated(
message = "Use 'NAVI_BODY_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_REGULAR"),
level = DeprecationLevel.WARNING,
)
SEMI_BOLD,
@Deprecated(
message = "Use 'NAVI_BODY_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_REGULAR"),
level = DeprecationLevel.WARNING,
)
NAVI_REGULAR,
@Deprecated(
message = "Use 'NAVI_BODY_REGULAR' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_REGULAR"),
level = DeprecationLevel.WARNING,
)
NAVI_SEMI_BOLD,
/** ================================================================================= */
/** -------------------------- Navi Body - Demi Bold (600) -------------------------- */
/** ================================================================================= */
NAVI_BODY_DEMI_BOLD,
@Deprecated(
message = "Use 'NAVI_BODY_DEMI_BOLD' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_DEMI_BOLD"),
level = DeprecationLevel.WARNING,
)
TT_SEMI_BOLD,
@Deprecated(
message = "Use 'NAVI_BODY_DEMI_BOLD' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_DEMI_BOLD"),
level = DeprecationLevel.WARNING,
)
ROBOTO_BOLD,
@Deprecated(
message = "Use 'NAVI_BODY_DEMI_BOLD' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_DEMI_BOLD"),
level = DeprecationLevel.WARNING,
)
EXTRA_BOLD,
@Deprecated(
message = "Use 'NAVI_BODY_DEMI_BOLD' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_DEMI_BOLD"),
level = DeprecationLevel.WARNING,
)
NAVI_EXTRA_BOLD,
@Deprecated(
message = "Use 'NAVI_BODY_DEMI_BOLD' instead.",
replaceWith = ReplaceWith(expression = "NAVI_BODY_DEMI_BOLD"),
level = DeprecationLevel.WARNING,
)
NAVI_BLACK,
}

View File

@@ -38,6 +38,7 @@ import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import androidx.navigation.NavHostController
import com.navi.uitron.demo.R
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.navigation.DAZZLE_DESIGN_SYSTEM
import com.navi.uitron.demo.navigation.DESIGN_SYSTEM
import com.navi.uitron.demo.navigation.LINK_INFLATOR
@@ -48,7 +49,6 @@ import com.navi.uitron.demo.theme.OrangeFF9000
import com.navi.uitron.demo.theme.PinkCC2FD5
import com.navi.uitron.demo.theme.Purple5A43E3
import com.navi.uitron.demo.theme.TomatoFC5130
import com.navi.uitron.demo.theme.fontFamily
@Composable
fun HomeScreen(navHostController: NavHostController) {
@@ -72,7 +72,7 @@ fun HomeScreen(navHostController: NavHostController) {
text = "UiTron",
fontWeight = FontWeight(800),
fontSize = 32.sp,
fontFamily = fontFamily,
fontFamily = naviFontFamily,
color = Color.Black
)
}
@@ -80,7 +80,7 @@ fun HomeScreen(navHostController: NavHostController) {
text = "I had hard-codings, but now I'm free.\nThere are no hard-codings on me.",
fontWeight = FontWeight(600),
modifier = Modifier.padding(20.dp),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
textAlign = TextAlign.Center,
lineHeight = 24.sp,
)
@@ -244,7 +244,7 @@ fun Bubble(
text = title,
fontSize = 22.sp,
fontWeight = FontWeight(700),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
textAlign = TextAlign.Center,
color = Color.White
)

View File

@@ -40,8 +40,8 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.theme.TomatoFC5130
import com.navi.uitron.demo.theme.fontFamily
import com.navi.uitron.render.UiTronRenderer
import com.navi.uitron.viewmodel.UiTronViewModel
@@ -65,7 +65,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Start,
fontSize = 20.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
Box(
@@ -82,7 +82,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
@@ -102,7 +102,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
@@ -122,7 +122,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}
@@ -147,7 +147,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
color = Color.Black,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
),
shape = MaterialTheme.shapes.large,
)
@@ -177,7 +177,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}
@@ -189,7 +189,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
else -> Unit
@@ -202,7 +202,7 @@ fun LinkInflator(viewModel: LinkInflatorViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}

View File

@@ -39,9 +39,9 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.google.gson.reflect.TypeToken
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.mockApiResponse
import com.navi.uitron.demo.theme.Purple5A43E3
import com.navi.uitron.demo.theme.fontFamily
import com.navi.uitron.model.UiTronResponse
import com.navi.uitron.render.UiTronRenderer
import com.navi.uitron.viewmodel.UiTronViewModel
@@ -65,7 +65,7 @@ fun MockScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Start,
fontSize = 20.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
Box(
@@ -82,7 +82,7 @@ fun MockScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
@@ -102,7 +102,7 @@ fun MockScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}
@@ -127,7 +127,7 @@ fun MockScreen(viewModel: UiTronViewModel = hiltViewModel()) {
color = Color.Black,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
),
shape = MaterialTheme.shapes.large,
)
@@ -156,7 +156,7 @@ fun MockScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
} else {
@@ -167,7 +167,7 @@ fun MockScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}

View File

@@ -38,10 +38,10 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.navi.uitron.demo.font.naviFontFamily
import com.navi.uitron.demo.stringToUiTronResponse
import com.navi.uitron.demo.theme.PinkCC2FD5
import com.navi.uitron.demo.theme.UiTronTheme
import com.navi.uitron.demo.theme.fontFamily
import com.navi.uitron.model.UiTronResponse
import com.navi.uitron.render.UiTronRenderer
import com.navi.uitron.viewmodel.UiTronViewModel
@@ -64,7 +64,7 @@ fun PlaygroundScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Start,
fontSize = 20.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
Box(
@@ -81,7 +81,7 @@ fun PlaygroundScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
@@ -101,7 +101,7 @@ fun PlaygroundScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 12.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}
@@ -126,7 +126,7 @@ fun PlaygroundScreen(viewModel: UiTronViewModel = hiltViewModel()) {
color = Color.Black,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
),
shape = MaterialTheme.shapes.large,
)
@@ -153,7 +153,7 @@ fun PlaygroundScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
} else {
@@ -164,7 +164,7 @@ fun PlaygroundScreen(viewModel: UiTronViewModel = hiltViewModel()) {
textAlign = TextAlign.Center,
fontSize = 14.sp,
fontWeight = FontWeight(weight = 500),
fontFamily = fontFamily,
fontFamily = naviFontFamily,
)
}
}

View File

@@ -38,7 +38,6 @@ fun UiTronTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable
MaterialTheme(
colors = colors,
typography = Typography,
shapes = Shapes,
content = content,
)

View File

@@ -1,27 +0,0 @@
/*
*
* * Copyright © 2024 by Navi Technologies Limited
* * All rights reserved. Strictly confidential
*
*/
package com.navi.uitron.demo.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
import com.navi.uitron.UiTronSdkManager
val fontFamily = UiTronSdkManager.getDependencyProvider().getFontFamily(null)
// Set of Material typography styles to start with
val Typography =
Typography(
body1 =
TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
fontSize = 16.sp
)
)

View File

@@ -23,24 +23,21 @@ interface IUiTronDependencyProvider {
fun getFontWeight(fontWeight: String?): FontWeight
fun getIconResourceId(iconCode: String?): Int?
fun getLottieResourceId(lottieCode: String?): Int?
fun getShape(shape: UiTronShape?): Shape?
fun getTransformedText(
value: String? = null,
data: OutlinedTextFieldValueTransformation? = null,
): String?
enum class FontWeightEnum {
TT_MEDIUM,
TT_BOLD,
TT_SEMI_BOLD,
TT_REGULAR
}
fun getUiTronConfig(): UiTronConfig
fun numberToWords(amount: String): String
fun getIconResourceId(iconCode: String?): Int?
fun getLottieResourceId(lottieCode: String?): Int?
fun getContext(): Context
fun logException(e: Exception)
@@ -58,9 +55,5 @@ interface IUiTronDependencyProvider {
fun blurSensitiveScreen(blur: Boolean) {}
fun getUiTronConfig(): UiTronConfig
fun getShape(shape: UiTronShape?): Shape?
fun getMedia3SimpleCache(): SimpleCache? = null
}

View File

@@ -225,7 +225,7 @@ enum class TextFontStyle {
ITALIC
}
fun getFontStyle(fontStyle: String?): FontStyle {
private fun getFontStyle(fontStyle: String?): FontStyle {
return when (fontStyle) {
TextFontStyle.NORMAL.name -> FontStyle.Normal
TextFontStyle.ITALIC.name -> FontStyle.Italic