Created
April 24, 2024 20:34
-
-
Save dimahmz/c668dc9357f23f33a23845dc1cb3b46c to your computer and use it in GitHub Desktop.
text components
This file contains hidden or 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
| package com.example.academicpulse.view.components.material | |
| import androidx.compose.material3.LocalContentColor | |
| import androidx.compose.material3.Text as UIText | |
| import androidx.compose.runtime.Composable | |
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.graphics.Color | |
| import androidx.compose.ui.text.font.Font | |
| import androidx.compose.ui.text.font.FontFamily | |
| import androidx.compose.ui.text.font.FontWeight | |
| import androidx.compose.ui.text.style.TextAlign | |
| import androidx.compose.ui.unit.sp | |
| import com.example.academicpulse.R | |
| import com.example.academicpulse.theme.fontsColorText | |
| import com.example.academicpulse.theme.h1TextSize | |
| import com.example.academicpulse.theme.textSize | |
| import com.example.academicpulse.utils.Res | |
| private val font = FontFamily(Font(R.font.regular_font)) | |
| @Composable | |
| fun Text(text: String = "", color: Color = LocalContentColor.current) { | |
| UIText(text = text, fontFamily = font, color = color, fontSize = textSize) | |
| } | |
| @Composable | |
| fun Text(text: Int) { | |
| Text(Res.string(text)) | |
| } | |
| @Composable | |
| fun Title(text: String) { | |
| UIText( | |
| text = text, | |
| fontWeight = FontWeight.Bold, | |
| fontFamily = font, | |
| fontSize = textSize, | |
| ) | |
| } | |
| @Composable | |
| fun Title(text: Int) { | |
| Title(Res.string(text)) | |
| } | |
| @Composable | |
| fun Description( | |
| modifier: Modifier = Modifier, | |
| text: String, | |
| align: TextAlign = TextAlign.Start | |
| ) { | |
| UIText( | |
| modifier = modifier, | |
| text = text, | |
| fontWeight = FontWeight.Light, | |
| fontFamily = font, | |
| fontSize = textSize, | |
| lineHeight = (textSize.value * 10 / 7).sp, | |
| color = fontsColorText, | |
| textAlign = align | |
| ) | |
| } | |
| @Composable | |
| fun Description( | |
| modifier: Modifier = Modifier, | |
| text: Int, | |
| align: TextAlign = TextAlign.Start | |
| ) { | |
| Description(modifier = modifier, text = Res.string(text), align = align) | |
| } | |
| @Composable | |
| fun H1( | |
| modifier: Modifier = Modifier, | |
| text: String, | |
| align: TextAlign = TextAlign.Start, | |
| color: Color = Color.Black | |
| ) { | |
| UIText( | |
| modifier = modifier, | |
| text = text, | |
| fontWeight = FontWeight.Bold, | |
| fontFamily = font, | |
| fontSize = h1TextSize, | |
| textAlign = align, | |
| color = color | |
| ) | |
| } | |
| @Composable | |
| fun H1( | |
| modifier: Modifier = Modifier, | |
| text: Int, | |
| align: TextAlign = TextAlign.Start, | |
| color: Color = Color.Black | |
| ) { | |
| H1(modifier = modifier, text = Res.string(text), align = align, color = color) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment