mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-07 11:09:53 +08:00
refactor: merge text style in Text
This commit is contained in:
@@ -34,7 +34,13 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.TextLayoutResult
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
import com.highcapable.betterandroid.compose.extension.ui.orNull
|
||||
import com.highcapable.flexiui.ColorsDescriptor
|
||||
import com.highcapable.flexiui.DefaultTypography
|
||||
@@ -45,8 +51,16 @@ import com.highcapable.flexiui.toColor
|
||||
* @see BasicText
|
||||
* @param text the text to be displayed.
|
||||
* @param modifier the [Modifier] to be applied to this text.
|
||||
* @param color the color of the text.
|
||||
* @param color the color of the text, see [TextStyle.color].
|
||||
* @param style the style of the text.
|
||||
* @param fontSize the font size of the text, see [TextStyle.fontSize].
|
||||
* @param fontStyle the font style of the text, see [TextStyle.fontStyle].
|
||||
* @param fontWeight the font weight of the text, see [TextStyle.fontWeight].
|
||||
* @param fontFamily the font family of the text, see [TextStyle.fontFamily].
|
||||
* @param letterSpacing the letter spacing of the text, see [TextStyle.letterSpacing].
|
||||
* @param textDecoration the text decoration of the text, see [TextStyle.textDecoration].
|
||||
* @param textAlign the text alignment of the text, see [TextStyle.textAlign].
|
||||
* @param lineHeight the line height of the text, see [TextStyle.lineHeight].
|
||||
* @param singleLine whether the text should be displayed on a single line, default is false.
|
||||
* @param maxLines the maximum number of lines to display, when [singleLine] is false default is [Int.MAX_VALUE].
|
||||
* @param minLines the minimum number of lines to display, default is 1.
|
||||
@@ -60,6 +74,14 @@ fun Text(
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = Color.Unspecified,
|
||||
style: TextStyle? = null,
|
||||
fontSize: TextUnit = TextUnit.Unspecified,
|
||||
fontStyle: FontStyle? = null,
|
||||
fontWeight: FontWeight? = null,
|
||||
fontFamily: FontFamily? = null,
|
||||
letterSpacing: TextUnit = TextUnit.Unspecified,
|
||||
textDecoration: TextDecoration? = null,
|
||||
textAlign: TextAlign? = null,
|
||||
lineHeight: TextUnit = TextUnit.Unspecified,
|
||||
singleLine: Boolean = false,
|
||||
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
|
||||
minLines: Int = 1,
|
||||
@@ -72,6 +94,14 @@ fun Text(
|
||||
modifier = modifier,
|
||||
color = color,
|
||||
style = style,
|
||||
fontSize = fontSize,
|
||||
fontStyle = fontStyle,
|
||||
fontWeight = fontWeight,
|
||||
fontFamily = fontFamily,
|
||||
letterSpacing = letterSpacing,
|
||||
textDecoration = textDecoration,
|
||||
textAlign = textAlign,
|
||||
lineHeight = lineHeight,
|
||||
overflow = overflow,
|
||||
softWrap = softWrap,
|
||||
maxLines = maxLines,
|
||||
@@ -86,8 +116,16 @@ fun Text(
|
||||
* @see BasicText
|
||||
* @param text the text to be displayed.
|
||||
* @param modifier the [Modifier] to be applied to this text.
|
||||
* @param color the color of the text.
|
||||
* @param color the color of the text, see [TextStyle.color].
|
||||
* @param style the style of the text.
|
||||
* @param fontSize the font size of the text, see [TextStyle.fontSize].
|
||||
* @param fontStyle the font style of the text, see [TextStyle.fontStyle].
|
||||
* @param fontWeight the font weight of the text, see [TextStyle.fontWeight].
|
||||
* @param fontFamily the font family of the text, see [TextStyle.fontFamily].
|
||||
* @param letterSpacing the letter spacing of the text, see [TextStyle.letterSpacing].
|
||||
* @param textDecoration the text decoration of the text, see [TextStyle.textDecoration].
|
||||
* @param textAlign the text alignment of the text, see [TextStyle.textAlign].
|
||||
* @param lineHeight the line height of the text, see [TextStyle.lineHeight].
|
||||
* @param singleLine whether the text should be displayed on a single line, default is false.
|
||||
* @param maxLines the maximum number of lines to display, when [singleLine] is false default is [Int.MAX_VALUE].
|
||||
* @param minLines the minimum number of lines to display, default is 1.
|
||||
@@ -102,6 +140,14 @@ fun Text(
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = Color.Unspecified,
|
||||
style: TextStyle? = null,
|
||||
fontSize: TextUnit = TextUnit.Unspecified,
|
||||
fontStyle: FontStyle? = null,
|
||||
fontWeight: FontWeight? = null,
|
||||
fontFamily: FontFamily? = null,
|
||||
letterSpacing: TextUnit = TextUnit.Unspecified,
|
||||
textDecoration: TextDecoration? = null,
|
||||
textAlign: TextAlign? = null,
|
||||
lineHeight: TextUnit = TextUnit.Unspecified,
|
||||
singleLine: Boolean = false,
|
||||
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
|
||||
minLines: Int = 1,
|
||||
@@ -115,7 +161,16 @@ fun Text(
|
||||
BasicText(
|
||||
text = text,
|
||||
modifier = modifier,
|
||||
style = currentStyle.copy(color = currentColor),
|
||||
style = currentStyle.copy(color = currentColor).merge(
|
||||
fontSize = fontSize,
|
||||
fontStyle = fontStyle,
|
||||
fontWeight = fontWeight,
|
||||
fontFamily = fontFamily,
|
||||
letterSpacing = letterSpacing,
|
||||
textDecoration = textDecoration,
|
||||
textAlign = textAlign,
|
||||
lineHeight = lineHeight
|
||||
),
|
||||
onTextLayout = onTextLayout,
|
||||
overflow = overflow,
|
||||
softWrap = softWrap,
|
||||
|
Reference in New Issue
Block a user