Skip to content

Commit

Permalink
Fix text color in transport mode and transportmodebadge
Browse files Browse the repository at this point in the history
  • Loading branch information
ksharma-xyz committed Feb 7, 2025
1 parent 4e3b907 commit bf00e24
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.requiredHeightIn
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand All @@ -16,6 +17,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import xyz.ksharma.krail.taj.LocalTextColor
import xyz.ksharma.krail.taj.components.Text
import xyz.ksharma.krail.taj.hexToComposeColor
import xyz.ksharma.krail.taj.theme.KrailTheme
Expand All @@ -28,22 +30,26 @@ fun TransportModeBadge(
) {
val density = LocalDensity.current

Box(
modifier = modifier
.requiredHeightIn(with(density) { 22.sp.toDp() })
.clip(shape = RoundedCornerShape(percent = 20))
.background(color = backgroundColor),
contentAlignment = Alignment.Center,
CompositionLocalProvider(
LocalTextColor provides Color.White,
) {
Text(
text = badgeText,
color = Color.White,
// todo - need concrete token for style, meanwhile keep same as TransportModeIcon.
style = KrailTheme.typography.labelLarge,
modifier = Modifier
.padding(2.dp)
.wrapContentWidth(),
)
Box(
modifier = modifier
.requiredHeightIn(with(density) { 22.sp.toDp() })
.clip(shape = RoundedCornerShape(percent = 20))
.background(color = backgroundColor),
contentAlignment = Alignment.Center,
) {
Text(
text = badgeText,
color = Color.White,
// todo - need concrete token for style, meanwhile keep same as TransportModeIcon.
style = KrailTheme.typography.labelLarge,
modifier = Modifier
.padding(2.dp)
.wrapContentWidth(),
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import xyz.ksharma.krail.taj.LocalContentAlpha
import xyz.ksharma.krail.taj.LocalTextColor
import xyz.ksharma.krail.taj.components.Text
import xyz.ksharma.krail.taj.hexToComposeColor
import xyz.ksharma.krail.taj.theme.KrailTheme
Expand All @@ -35,7 +36,10 @@ fun TransportModeIcon(
val textStyle = KrailTheme.typography.labelLarge

// Content alphas should always be 100% for Transport related icons
CompositionLocalProvider(LocalContentAlpha provides 1f) {
CompositionLocalProvider(
LocalContentAlpha provides 1f,
LocalTextColor provides Color.White,
) {
Box(
modifier = modifier
.clip(shape = CircleShape)
Expand Down

0 comments on commit bf00e24

Please sign in to comment.