Last active
April 29, 2021 12:14
-
-
Save cicerohellmann/553e566a0f2b177b809ba6feabc3c07b to your computer and use it in GitHub Desktop.
Composable Custom Text with two variants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.material.Text | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.text.font.FontWeight | |
import androidx.compose.ui.unit.TextUnit | |
import com.your.project.resources.FontFamily | |
@Composable | |
fun Text( | |
text: String, | |
color: Color, | |
modifier: Modifier = Modifier, | |
fontSize: TextUnit = TextUnit.Unspecified, | |
fontWeight: FontWeight? = null, | |
letterSpacing: TextUnit = TextUnit.Unspecified, | |
lineHeight: TextUnit = TextUnit.Unspecified | |
) { | |
Text( | |
text = text, | |
color = color, | |
modifier = modifier, | |
fontSize = fontSize, | |
fontWeight = fontWeight, | |
fontFamily = FontFamily.robotoFamily, | |
letterSpacing = letterSpacing, | |
lineHeight = lineHeight, | |
) | |
} | |
@Composable | |
fun TextMedium( | |
text: String, | |
color: Color, | |
modifier: Modifier = Modifier, | |
fontSize: TextUnit = TextUnit.Unspecified, | |
letterSpacing: TextUnit = TextUnit.Unspecified, | |
lineHeight: TextUnit = TextUnit.Unspecified | |
) { | |
Text( | |
text = text, | |
color = color, | |
modifier = modifier, | |
fontSize = fontSize, | |
fontWeight = FontWeight.Medium, | |
letterSpacing = letterSpacing, | |
lineHeight = lineHeight, | |
) | |
} | |
@Composable | |
fun TextBold( | |
text: String, | |
color: Color, | |
modifier: Modifier = Modifier, | |
fontSize: TextUnit = TextUnit.Unspecified, | |
letterSpacing: TextUnit = TextUnit.Unspecified, | |
lineHeight: TextUnit = TextUnit.Unspecified | |
) { | |
Text( | |
text = text, | |
color = color, | |
modifier = modifier, | |
fontSize = fontSize, | |
fontWeight = FontWeight.Bold, | |
letterSpacing = letterSpacing, | |
lineHeight = lineHeight, | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment