Android/TiTi Side Project
TiTi Side Project | TdsText 컴포넌트 구현하기
si8ae
2023. 10. 4. 00:11
TdsText 컴포넌트
@Composable
fun TdsText(
modifier: Modifier = Modifier,
text: String? = null,
textStyle: TdsTextStyle,
fontSize: TextUnit,
textDecoration: TextDecoration? = null,
color: TdsColor,
textAlign: TextAlign? = null,
overflow: TextOverflow = TextOverflow.Clip,
maxLines: Int = Int.MAX_VALUE,
minLines: Int = 1,
onTextLayout: (TextLayoutResult) -> Unit = {},
) {
Text(
text = text ?: "",
modifier = modifier,
color = color.getColor(),
textAlign = textAlign,
overflow = overflow,
maxLines = maxLines,
minLines = minLines,
onTextLayout = onTextLayout,
style = textStyle.getTextStyle(fontSize),
textDecoration = textDecoration
)
}
enum class인 TdsColor와 TdsTextStyle을 parameter로 입력받아 Text 컴포넌트를 구현하고 있습니다. 이렇게 하면 텍스트 스타일, 색상 등을 일관되게 관리하고, 코드를 보다 간결하게 유지할 수 있습니다.