refactor: rename titleText, subText to title and subtitle

This commit is contained in:
2024-01-10 23:06:24 +08:00
parent bd0ce99530
commit 8a4c779b63
2 changed files with 59 additions and 59 deletions

View File

@@ -65,7 +65,7 @@ import com.highcapable.flexiui.toTextStyle
@Immutable @Immutable
data class AppBarColors( data class AppBarColors(
val titleTextColor: Color, val titleTextColor: Color,
val subTextColor: Color, val subtitleTextColor: Color,
val actionContentColor: Color val actionContentColor: Color
) )
@@ -78,7 +78,7 @@ data class AppBarStyle(
val padding: ComponentPadding, val padding: ComponentPadding,
val contentSpacing: Dp, val contentSpacing: Dp,
val titleTextStyle: TextStyle, val titleTextStyle: TextStyle,
val subTextStyle: TextStyle, val subtitleTextStyle: TextStyle,
val actionIconSize: Dp, val actionIconSize: Dp,
val actionIconPadding: Dp, val actionIconPadding: Dp,
val actionContentMaxWidth: Dp val actionContentMaxWidth: Dp
@@ -90,8 +90,8 @@ data class AppBarStyle(
* @param modifier the [Modifier] to be applied to this app bar. * @param modifier the [Modifier] to be applied to this app bar.
* @param colors the colors of this app bar, default is [AppBarDefaults.colors]. * @param colors the colors of this app bar, default is [AppBarDefaults.colors].
* @param style the style of this app bar, default is [AppBarDefaults.style]. * @param style the style of this app bar, default is [AppBarDefaults.style].
* @param titleText the title text of this app bar, should typically be [Text]. * @param title the title of this app bar, should typically be [Text].
* @param subText the sub text of this app bar, should typically be [Text]. * @param subtitle the subtitle of this app bar, should typically be [Text].
* @param actions the actions displayed at the end of the app bar, should typically be [AppBarScope.ActionIconButton]. * @param actions the actions displayed at the end of the app bar, should typically be [AppBarScope.ActionIconButton].
*/ */
@Composable @Composable
@@ -99,8 +99,8 @@ fun PrimaryAppBar(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
colors: AppBarColors = AppBarDefaults.colors(), colors: AppBarColors = AppBarDefaults.colors(),
style: AppBarStyle = AppBarDefaults.style(type = AppBarType.Primary), style: AppBarStyle = AppBarDefaults.style(type = AppBarType.Primary),
titleText: @Composable () -> Unit, title: @Composable () -> Unit,
subText: @Composable (() -> Unit)? = null, subtitle: @Composable (() -> Unit)? = null,
actions: @Composable (AppBarScope.() -> Unit)? = null actions: @Composable (AppBarScope.() -> Unit)? = null
) { ) {
BasicAppBar( BasicAppBar(
@@ -108,8 +108,8 @@ fun PrimaryAppBar(
modifier = modifier, modifier = modifier,
colors = colors, colors = colors,
style = style, style = style,
titleText = titleText, title = title,
subText = subText, subtitle = subtitle,
finishIcon = null, finishIcon = null,
navigationIcon = null, navigationIcon = null,
actions = actions actions = actions
@@ -122,8 +122,8 @@ fun PrimaryAppBar(
* @param modifier the [Modifier] to be applied to this app bar. * @param modifier the [Modifier] to be applied to this app bar.
* @param colors the colors of this app bar, default is [AppBarDefaults.colors]. * @param colors the colors of this app bar, default is [AppBarDefaults.colors].
* @param style the style of this app bar, default is [AppBarDefaults.style]. * @param style the style of this app bar, default is [AppBarDefaults.style].
* @param titleText the title text of this app bar, should typically be [Text]. * @param title the title of this app bar, should typically be [Text].
* @param subText the sub text of this app bar, should typically be [Text]. * @param subtitle the subtitle of this app bar, should typically be [Text].
* @param finishIcon the finish icon displayed at the start of the app bar, should typically be [AppBarScope.FinishIconButton]. * @param finishIcon the finish icon displayed at the start of the app bar, should typically be [AppBarScope.FinishIconButton].
* @param navigationIcon the navigation icon displayed at the start of the app bar, should typically be [AppBarScope.NavigationIconButton]. * @param navigationIcon the navigation icon displayed at the start of the app bar, should typically be [AppBarScope.NavigationIconButton].
* @param actions the actions displayed at the end of the app bar, should typically be [AppBarScope.ActionIconButton]. * @param actions the actions displayed at the end of the app bar, should typically be [AppBarScope.ActionIconButton].
@@ -133,8 +133,8 @@ fun SecondaryAppBar(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
colors: AppBarColors = AppBarDefaults.colors(), colors: AppBarColors = AppBarDefaults.colors(),
style: AppBarStyle = AppBarDefaults.style(type = AppBarType.Secondary), style: AppBarStyle = AppBarDefaults.style(type = AppBarType.Secondary),
titleText: @Composable () -> Unit, title: @Composable () -> Unit,
subText: @Composable (() -> Unit)? = null, subtitle: @Composable (() -> Unit)? = null,
finishIcon: @Composable (AppBarScope.() -> Unit)? = null, finishIcon: @Composable (AppBarScope.() -> Unit)? = null,
navigationIcon: @Composable (AppBarScope.() -> Unit)? = null, navigationIcon: @Composable (AppBarScope.() -> Unit)? = null,
actions: @Composable (AppBarScope.() -> Unit)? = null actions: @Composable (AppBarScope.() -> Unit)? = null
@@ -144,8 +144,8 @@ fun SecondaryAppBar(
modifier = modifier, modifier = modifier,
colors = colors, colors = colors,
style = style, style = style,
titleText = titleText, title = title,
subText = subText, subtitle = subtitle,
finishIcon = finishIcon, finishIcon = finishIcon,
navigationIcon = navigationIcon, navigationIcon = navigationIcon,
actions = actions actions = actions
@@ -161,8 +161,8 @@ private fun BasicAppBar(
modifier: Modifier, modifier: Modifier,
colors: AppBarColors, colors: AppBarColors,
style: AppBarStyle, style: AppBarStyle,
titleText: @Composable () -> Unit, title: @Composable () -> Unit,
subText: @Composable (() -> Unit)?, subtitle: @Composable (() -> Unit)?,
finishIcon: @Composable (AppBarScope.() -> Unit)?, finishIcon: @Composable (AppBarScope.() -> Unit)?,
navigationIcon: @Composable (AppBarScope.() -> Unit)?, navigationIcon: @Composable (AppBarScope.() -> Unit)?,
actions: @Composable (AppBarScope.() -> Unit)? actions: @Composable (AppBarScope.() -> Unit)?
@@ -172,8 +172,8 @@ private fun BasicAppBar(
type = type, type = type,
colors = colors, colors = colors,
style = style, style = style,
titleText = titleText, title = title,
subText = subText, subtitle = subtitle,
finishIcon = finishIcon, finishIcon = finishIcon,
navigationIcon = navigationIcon, navigationIcon = navigationIcon,
actions = actions actions = actions
@@ -284,8 +284,8 @@ private class AppBarImpl(
val type: AppBarType, val type: AppBarType,
val colors: AppBarColors, val colors: AppBarColors,
val style: AppBarStyle, val style: AppBarStyle,
val titleText: @Composable () -> Unit, val title: @Composable () -> Unit,
val subText: @Composable (() -> Unit)?, val subtitle: @Composable (() -> Unit)?,
val finishIcon: @Composable (AppBarScope.() -> Unit)?, val finishIcon: @Composable (AppBarScope.() -> Unit)?,
val navigationIcon: @Composable (AppBarScope.() -> Unit)?, val navigationIcon: @Composable (AppBarScope.() -> Unit)?,
val actions: @Composable (AppBarScope.() -> Unit)? val actions: @Composable (AppBarScope.() -> Unit)?
@@ -341,12 +341,12 @@ private class AppBarImpl(
ContentStyle( ContentStyle(
color = colors.titleTextColor, color = colors.titleTextColor,
textStyle = style.titleTextStyle, textStyle = style.titleTextStyle,
content = titleText content = title
) )
subText?.also { content -> subtitle?.also { content ->
ContentStyle( ContentStyle(
color = colors.subTextColor, color = colors.subtitleTextColor,
textStyle = style.subTextStyle, textStyle = style.subtitleTextStyle,
content = content content = content
) )
} }
@@ -404,18 +404,18 @@ object AppBarDefaults {
/** /**
* Creates a [AppBarColors] with the default values. * Creates a [AppBarColors] with the default values.
* @param titleTextColor the title text color. * @param titleTextColor the title text color.
* @param subTextColor the sub text color. * @param subtitleTextColor the subtitle text color.
* @param actionContentColor the action content color, usually for icon tint and text color. * @param actionContentColor the action content color, usually for icon tint and text color.
* @return [AppBarColors] * @return [AppBarColors]
*/ */
@Composable @Composable
fun colors( fun colors(
titleTextColor: Color = AppBarProperties.TitleTextColor.toColor(), titleTextColor: Color = AppBarProperties.TitleTextColor.toColor(),
subTextColor: Color = AppBarProperties.SubTextColor.toColor(), subtitleTextColor: Color = AppBarProperties.SubtitleTextColor.toColor(),
actionContentColor: Color = AppBarProperties.ActionContentColor.toColor() actionContentColor: Color = AppBarProperties.ActionContentColor.toColor()
) = AppBarColors( ) = AppBarColors(
titleTextColor = titleTextColor, titleTextColor = titleTextColor,
subTextColor = subTextColor, subtitleTextColor = subtitleTextColor,
actionContentColor = actionContentColor actionContentColor = actionContentColor
) )
@@ -425,7 +425,7 @@ object AppBarDefaults {
* @param padding the padding of content. * @param padding the padding of content.
* @param contentSpacing the spacing between the components of content. * @param contentSpacing the spacing between the components of content.
* @param titleTextStyle the title text style. * @param titleTextStyle the title text style.
* @param subTextStyle the sub text style. * @param subtitleTextStyle the subtitle text style.
* @param actionIconSize the size of action icon. * @param actionIconSize the size of action icon.
* @param actionIconPadding the padding of action icon. * @param actionIconPadding the padding of action icon.
* @param actionContentMaxWidth the max width of actions content. * @param actionContentMaxWidth the max width of actions content.
@@ -444,7 +444,7 @@ object AppBarDefaults {
AppBarType.Primary -> AppBarProperties.PrimaryTitleTextStyle AppBarType.Primary -> AppBarProperties.PrimaryTitleTextStyle
AppBarType.Secondary -> AppBarProperties.SecondaryTitleTextStyle AppBarType.Secondary -> AppBarProperties.SecondaryTitleTextStyle
}.toTextStyle(), }.toTextStyle(),
subTextStyle: TextStyle = AppBarProperties.SubTextStyle.toTextStyle(), subtitleTextStyle: TextStyle = AppBarProperties.SubtitleTextStyle.toTextStyle(),
actionIconSize: Dp = when (type) { actionIconSize: Dp = when (type) {
AppBarType.Primary -> AppBarProperties.PrimaryActionIconSize AppBarType.Primary -> AppBarProperties.PrimaryActionIconSize
AppBarType.Secondary -> AppBarProperties.SecondaryActionIconSize AppBarType.Secondary -> AppBarProperties.SecondaryActionIconSize
@@ -455,7 +455,7 @@ object AppBarDefaults {
padding = padding, padding = padding,
contentSpacing = contentSpacing, contentSpacing = contentSpacing,
titleTextStyle = titleTextStyle, titleTextStyle = titleTextStyle,
subTextStyle = subTextStyle, subtitleTextStyle = subtitleTextStyle,
actionIconSize = actionIconSize, actionIconSize = actionIconSize,
actionIconPadding = actionIconPadding, actionIconPadding = actionIconPadding,
actionContentMaxWidth = actionContentMaxWidth actionContentMaxWidth = actionContentMaxWidth
@@ -465,14 +465,14 @@ object AppBarDefaults {
@Stable @Stable
internal object AppBarProperties { internal object AppBarProperties {
val TitleTextColor = ColorsDescriptor.TextPrimary val TitleTextColor = ColorsDescriptor.TextPrimary
val SubTextColor = ColorsDescriptor.TextSecondary val SubtitleTextColor = ColorsDescriptor.TextSecondary
val ActionContentColor = ColorsDescriptor.TextPrimary val ActionContentColor = ColorsDescriptor.TextPrimary
val Padding = PaddingDescriptor(SizesDescriptor.SpacingPrimary) val Padding = PaddingDescriptor(SizesDescriptor.SpacingPrimary)
val InBoxPadding = PaddingDescriptor(vertical = SizesDescriptor.SpacingPrimary) val InBoxPadding = PaddingDescriptor(vertical = SizesDescriptor.SpacingPrimary)
val ContentSpacing = SizesDescriptor.SpacingSecondary val ContentSpacing = SizesDescriptor.SpacingSecondary
val PrimaryTitleTextStyle = TypographyDescriptor.TitlePrimary val PrimaryTitleTextStyle = TypographyDescriptor.TitlePrimary
val SecondaryTitleTextStyle = TypographyDescriptor.TitleSecondary val SecondaryTitleTextStyle = TypographyDescriptor.TitleSecondary
val SubTextStyle = TypographyDescriptor.Subtitle val SubtitleTextStyle = TypographyDescriptor.Subtitle
val PrimaryActionIconSize = SizesDescriptor.IconSizePrimary val PrimaryActionIconSize = SizesDescriptor.IconSizePrimary
val SecondaryActionIconSize = SizesDescriptor.IconSizeSecondary val SecondaryActionIconSize = SizesDescriptor.IconSizeSecondary
val ActionIconPadding = SizesDescriptor.SpacingTertiary val ActionIconPadding = SizesDescriptor.SpacingTertiary

View File

@@ -61,7 +61,7 @@ import com.highcapable.flexiui.toTextStyle
data class ItemBoxColors( data class ItemBoxColors(
val backgroundColor: Color, val backgroundColor: Color,
val titleTextColor: Color, val titleTextColor: Color,
val subTextColor: Color, val subtitleTextColor: Color,
val arrowIconTint: Color, val arrowIconTint: Color,
val borderColor: Color val borderColor: Color
) )
@@ -74,7 +74,7 @@ data class ItemBoxColors(
data class ItemBoxStyle( data class ItemBoxStyle(
val contentSpacing: Dp, val contentSpacing: Dp,
val titleTextStyle: TextStyle, val titleTextStyle: TextStyle,
val subTextStyle: TextStyle, val subtitleTextStyle: TextStyle,
val shape: Shape, val shape: Shape,
val borderWidth: Dp, val borderWidth: Dp,
val shadowSize: Dp val shadowSize: Dp
@@ -91,8 +91,8 @@ data class ItemBoxStyle(
* @param showArrowIcon whether show arrow icon, default is true. * @param showArrowIcon whether show arrow icon, default is true.
* @param interactionSource the interaction source of this item box. * @param interactionSource the interaction source of this item box.
* @param logoImage the logo image of the [HorizontalItemBox], should typically be [Icon] or [Image]. * @param logoImage the logo image of the [HorizontalItemBox], should typically be [Icon] or [Image].
* @param titleText the title text of the [HorizontalItemBox], should typically be [Text]. * @param title the title of the [HorizontalItemBox], should typically be [Text].
* @param subText the sub text of the [HorizontalItemBox], should typically be [Text]. * @param subtitle the subtitle of the [HorizontalItemBox], should typically be [Text].
*/ */
@Composable @Composable
fun HorizontalItemBox( fun HorizontalItemBox(
@@ -104,8 +104,8 @@ fun HorizontalItemBox(
showArrowIcon: Boolean = true, showArrowIcon: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
logoImage: @Composable (() -> Unit)? = null, logoImage: @Composable (() -> Unit)? = null,
titleText: @Composable () -> Unit, title: @Composable () -> Unit,
subText: @Composable (() -> Unit)? = null subtitle: @Composable (() -> Unit)? = null
) { ) {
AreaBox( AreaBox(
modifier = modifier.rippleClickable( modifier = modifier.rippleClickable(
@@ -137,8 +137,8 @@ fun HorizontalItemBox(
ItemBoxContent( ItemBoxContent(
colors = colors, colors = colors,
style = style, style = style,
titleText = titleText, title = title,
subText = subText subtitle = subtitle
) )
} }
if (showArrowIcon) Icon( if (showArrowIcon) Icon(
@@ -162,8 +162,8 @@ fun HorizontalItemBox(
* @param enabled whether this item box is enabled, default is true. * @param enabled whether this item box is enabled, default is true.
* @param interactionSource the interaction source of this item box. * @param interactionSource the interaction source of this item box.
* @param logoImage the logo image of the [VerticalItemBox], should typically be [Icon] or [Image]. * @param logoImage the logo image of the [VerticalItemBox], should typically be [Icon] or [Image].
* @param titleText the title text of the [VerticalItemBox], should typically be [Text]. * @param title the title of the [VerticalItemBox], should typically be [Text].
* @param subText the sub text of the [VerticalItemBox], should typically be [Text]. * @param subtitle the subtitle of the [VerticalItemBox], should typically be [Text].
*/ */
@Composable @Composable
fun VerticalItemBox( fun VerticalItemBox(
@@ -174,8 +174,8 @@ fun VerticalItemBox(
enabled: Boolean = true, enabled: Boolean = true,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
logoImage: @Composable (() -> Unit)? = null, logoImage: @Composable (() -> Unit)? = null,
titleText: @Composable () -> Unit, title: @Composable () -> Unit,
subText: @Composable (() -> Unit)? = null subtitle: @Composable (() -> Unit)? = null
) { ) {
AreaColumn( AreaColumn(
modifier = modifier.rippleClickable( modifier = modifier.rippleClickable(
@@ -200,8 +200,8 @@ fun VerticalItemBox(
ItemBoxContent( ItemBoxContent(
colors = colors, colors = colors,
style = style, style = style,
titleText = titleText, title = title,
subText = subText subtitle = subtitle
) )
} }
} }
@@ -210,16 +210,16 @@ fun VerticalItemBox(
private fun ItemBoxContent( private fun ItemBoxContent(
colors: ItemBoxColors, colors: ItemBoxColors,
style: ItemBoxStyle, style: ItemBoxStyle,
titleText: @Composable () -> Unit, title: @Composable () -> Unit,
subText: @Composable (() -> Unit)? subtitle: @Composable (() -> Unit)?
) { ) {
CompositionLocalProvider( CompositionLocalProvider(
LocalTextStyle provides style.titleTextStyle.copy(color = colors.titleTextColor), LocalTextStyle provides style.titleTextStyle.copy(color = colors.titleTextColor),
content = titleText content = title
) )
subText?.also { content -> subtitle?.also { content ->
CompositionLocalProvider( CompositionLocalProvider(
LocalTextStyle provides style.subTextStyle.copy(color = colors.subTextColor), LocalTextStyle provides style.subtitleTextStyle.copy(color = colors.subtitleTextColor),
content = content content = content
) )
} }
@@ -234,7 +234,7 @@ object ItemBoxDefaults {
* Creates a [ItemBoxColors] with the default values. * Creates a [ItemBoxColors] with the default values.
* @param backgroundColor the background color. * @param backgroundColor the background color.
* @param titleTextColor the title text color. * @param titleTextColor the title text color.
* @param subTextColor the sub text color. * @param subtitleTextColor the subtitle text color.
* @param arrowIconTint the arrow icon tint. * @param arrowIconTint the arrow icon tint.
* @param borderColor the border color. * @param borderColor the border color.
* @return [ItemBoxColors] * @return [ItemBoxColors]
@@ -243,13 +243,13 @@ object ItemBoxDefaults {
fun colors( fun colors(
backgroundColor: Color = ItemBoxProperties.BackgroundColor.toColor(), backgroundColor: Color = ItemBoxProperties.BackgroundColor.toColor(),
titleTextColor: Color = ItemBoxProperties.TitleTextColor.toColor(), titleTextColor: Color = ItemBoxProperties.TitleTextColor.toColor(),
subTextColor: Color = ItemBoxProperties.SubTextColor.toColor(), subtitleTextColor: Color = ItemBoxProperties.SubtitleTextColor.toColor(),
arrowIconTint: Color = ItemBoxProperties.ArrowIconTint.toColor(), arrowIconTint: Color = ItemBoxProperties.ArrowIconTint.toColor(),
borderColor: Color = ItemBoxProperties.BorderColor.toColor() borderColor: Color = ItemBoxProperties.BorderColor.toColor()
) = ItemBoxColors( ) = ItemBoxColors(
backgroundColor = backgroundColor, backgroundColor = backgroundColor,
titleTextColor = titleTextColor, titleTextColor = titleTextColor,
subTextColor = subTextColor, subtitleTextColor = subtitleTextColor,
arrowIconTint = arrowIconTint, arrowIconTint = arrowIconTint,
borderColor = borderColor borderColor = borderColor
) )
@@ -258,7 +258,7 @@ object ItemBoxDefaults {
* Creates a [ItemBoxStyle] with the default values. * Creates a [ItemBoxStyle] with the default values.
* @param contentSpacing the spacing between the components of content. * @param contentSpacing the spacing between the components of content.
* @param titleTextStyle the title text style. * @param titleTextStyle the title text style.
* @param subTextStyle the sub text style. * @param subtitleTextStyle the subtitle text style.
* @param shape the shape. * @param shape the shape.
* @param borderWidth the border width. * @param borderWidth the border width.
* @param shadowSize the shadow size. * @param shadowSize the shadow size.
@@ -268,14 +268,14 @@ object ItemBoxDefaults {
fun style( fun style(
contentSpacing: Dp = ItemBoxProperties.ContentSpacing.toDp(), contentSpacing: Dp = ItemBoxProperties.ContentSpacing.toDp(),
titleTextStyle: TextStyle = ItemBoxProperties.TitleTextStyle.toTextStyle(), titleTextStyle: TextStyle = ItemBoxProperties.TitleTextStyle.toTextStyle(),
subTextStyle: TextStyle = ItemBoxProperties.SubTextStyle.toTextStyle(), subtitleTextStyle: TextStyle = ItemBoxProperties.SubtitleTextStyle.toTextStyle(),
shape: Shape = ItemBoxProperties.Shape.toShape(), shape: Shape = ItemBoxProperties.Shape.toShape(),
borderWidth: Dp = ItemBoxProperties.BorderWidth.toDp(), borderWidth: Dp = ItemBoxProperties.BorderWidth.toDp(),
shadowSize: Dp = ItemBoxProperties.ShadowSize shadowSize: Dp = ItemBoxProperties.ShadowSize
) = ItemBoxStyle( ) = ItemBoxStyle(
contentSpacing = contentSpacing, contentSpacing = contentSpacing,
titleTextStyle = titleTextStyle, titleTextStyle = titleTextStyle,
subTextStyle = subTextStyle, subtitleTextStyle = subtitleTextStyle,
shape = shape, shape = shape,
borderWidth = borderWidth, borderWidth = borderWidth,
shadowSize = shadowSize shadowSize = shadowSize
@@ -286,12 +286,12 @@ object ItemBoxDefaults {
internal object ItemBoxProperties { internal object ItemBoxProperties {
val BackgroundColor = AreaBoxProperties.BackgroundColor val BackgroundColor = AreaBoxProperties.BackgroundColor
val TitleTextColor = ColorsDescriptor.TextPrimary val TitleTextColor = ColorsDescriptor.TextPrimary
val SubTextColor = ColorsDescriptor.TextSecondary val SubtitleTextColor = ColorsDescriptor.TextSecondary
val ArrowIconTint = ColorsDescriptor.TextSecondary val ArrowIconTint = ColorsDescriptor.TextSecondary
val BorderColor = AreaBoxProperties.BorderColor val BorderColor = AreaBoxProperties.BorderColor
val ContentSpacing = SizesDescriptor.SpacingSecondary val ContentSpacing = SizesDescriptor.SpacingSecondary
val TitleTextStyle = TypographyDescriptor.Primary val TitleTextStyle = TypographyDescriptor.Primary
val SubTextStyle = TypographyDescriptor.Secondary val SubtitleTextStyle = TypographyDescriptor.Secondary
val Shape = AreaBoxProperties.Shape val Shape = AreaBoxProperties.Shape
val BorderWidth = AreaBoxProperties.BorderWidth val BorderWidth = AreaBoxProperties.BorderWidth
val ShadowSize = AreaBoxProperties.ShadowSize val ShadowSize = AreaBoxProperties.ShadowSize