-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b75af21
commit 4bd3858
Showing
4 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
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
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
51 changes: 51 additions & 0 deletions
51
core/design-system/src/main/kotlin/xyz/ksharma/krail/design/system/components/Text.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package xyz.ksharma.krail.design.system.components | ||
|
||
import androidx.compose.foundation.text.BasicText | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.compositionLocalOf | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.tooling.preview.PreviewLightDark | ||
import xyz.ksharma.krail.design.system.theme.KrailTheme | ||
|
||
val LocalTextStyle = compositionLocalOf { TextStyle.Default } | ||
val LocalTextColor = compositionLocalOf { Color.Unspecified } | ||
|
||
@Composable | ||
fun Text( | ||
text: String, | ||
modifier: Modifier = Modifier, | ||
style: TextStyle = LocalTextStyle.current, | ||
textAlign: TextAlign = TextAlign.Start, | ||
maxLines: Int = Int.MAX_VALUE, | ||
) { | ||
CompositionLocalProvider( | ||
LocalTextColor provides KrailTheme.colors.onBackground, | ||
LocalTextStyle provides KrailTheme.typography.body, | ||
) { | ||
BasicText( | ||
text = text, | ||
style = style.merge( | ||
color = LocalTextColor.current, | ||
textAlign = textAlign, | ||
|
||
), | ||
maxLines = maxLines, | ||
modifier = modifier, | ||
) | ||
} | ||
} | ||
|
||
@PreviewLightDark | ||
@Composable | ||
private fun TextPreview() { | ||
KrailTheme { | ||
Text(text = "Hello World!") | ||
Text(text = "Hello World!", style = KrailTheme.typography.displayLarge) | ||
Text(text = "Hello World!", style = KrailTheme.typography.displayMedium) | ||
Text(text = "Hello World!", style = KrailTheme.typography.displaySmall) | ||
} | ||
} |
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