Issues with Android tokens output
jmartinesp opened this issue · comments
I found some issues while taking a look at the design tokens generated for Android:
Package declaration
You don't need a closing ;
character after the package declaration.
Missing imports
You'll also need these missing imports:
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
TextStyles
The current TextStyles
declarations have a few issues:
- It needs a comma after each parameter.
lineHeight
andfontWeight
should usesp
instead ofdp
.fontFamily
expects aFontFamily
object. If we're using plain "Roboto" we should useFamily.Default
instead (it'll use the system font, in this case, Roboto). If we want to use a monospace, cursive or sans serif variant there areFamily.Monospace
,Family.Cursive
andFamily.SansSerif
. If we want to use a custom font we'll need to figure out how to create customFontFamily
objects.- Also, it would be great to add some indentation to the parameter lines.
The result should look something like:
val fontBodyMdRegular = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.W400,
lineHeight = 20.sp,
fontSize = 14.sp,
letterSpacing = 0.017857.em,
)
Size multipliers
I've seen that some sizes have: val space0_5X = 4.dp * 0.5
. The {number}.dp
expression generates a Dp
object containing a Float
value. In Kotlin, 1
can be used to multiply a Float, but 0.5
can't (it's recognised as a Double instead). To make these multipliers work with any number, instead of * 0.5
or * 2
, it should be * 0.5f
and * 2f
, i.e:
val space1_5X = 4.dp * 1.5f
val space20X = 4.dp * 20f