Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected material theme issues #188

Merged
merged 3 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ enum class ArrivalViewStyle {
interface ArrivalViewTheme {
/** The text style for the step distance (or distance to step). */
@get:Composable val style: ArrivalViewStyle
/** The color for the measurement/value. */
@get:Composable val measurementColor: Color
/** The text style for the measurement/value. */
@get:Composable val measurementTextStyle: TextStyle
/** The color for the secondary content (label caption). */
@get:Composable val secondaryColor: Color
/** The text style for the secondary content (label caption). */
@get:Composable val secondaryTextStyle: TextStyle
/** The exit button icon color. */
Expand All @@ -37,17 +33,16 @@ object DefaultArrivalViewTheme : ArrivalViewTheme {
override val style: ArrivalViewStyle
@Composable get() = ArrivalViewStyle.SIMPLIFIED

override val measurementColor: Color
@Composable get() = MaterialTheme.colorScheme.onBackground

override val measurementTextStyle: TextStyle
@Composable get() = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.SemiBold)

override val secondaryColor: Color
@Composable get() = MaterialTheme.colorScheme.secondary
@Composable
get() =
MaterialTheme.typography.titleLarge.copy(
color = MaterialTheme.colorScheme.onSurface, fontWeight = FontWeight.SemiBold)

override val secondaryTextStyle: TextStyle
@Composable get() = MaterialTheme.typography.labelSmall
@Composable
get() =
MaterialTheme.typography.labelSmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant)

override val exitIconColor: Color
@Composable get() = MaterialTheme.colorScheme.onSecondary
Expand All @@ -56,5 +51,5 @@ object DefaultArrivalViewTheme : ArrivalViewTheme {
@Composable get() = MaterialTheme.colorScheme.secondary

override val backgroundColor: Color
@Composable get() = MaterialTheme.colorScheme.background
@Composable get() = MaterialTheme.colorScheme.surface
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ interface InstructionRowTheme {
@get:Composable val instructionTextStyle: TextStyle
/** The color of the icon. */
@get:Composable val iconTintColor: Color
/** The background color for the view. */
@get:Composable val backgroundColor: Color
}

/** Default theme using the material theme. */
object DefaultInstructionRowTheme : InstructionRowTheme {
override val distanceTextStyle: TextStyle
@Composable
get() = MaterialTheme.typography.titleLarge.merge(color = MaterialTheme.colorScheme.primary)
get() = MaterialTheme.typography.titleLarge.merge(color = MaterialTheme.colorScheme.onSurface)

override val instructionTextStyle: TextStyle
@Composable
get() =
MaterialTheme.typography.headlineSmall.merge(color = MaterialTheme.colorScheme.secondary)
MaterialTheme.typography.headlineSmall.merge(
color = MaterialTheme.colorScheme.onSurfaceVariant)

override val iconTintColor: Color
@Composable get() = MaterialTheme.colorScheme.primary
@Composable get() = MaterialTheme.colorScheme.onSurface

override val backgroundColor: Color
@Composable get() = MaterialTheme.colorScheme.surface
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,41 +83,29 @@ fun ArrivalView(
text =
estimatedArrivalFormatter.format(
progress.estimatedArrivalTime(fromDate, timeZone)),
style = theme.measurementTextStyle,
color = theme.measurementColor)
style = theme.measurementTextStyle)
if (theme.style == ArrivalViewStyle.INFORMATIONAL) {
Text(
text = "Arrival",
style = theme.secondaryTextStyle,
color = theme.secondaryColor)
Text(text = "Arrival", style = theme.secondaryTextStyle)
}
}

Column(
modifier = Modifier.weight(1f), horizontalAlignment = Alignment.CenterHorizontally) {
Text(
text = durationFormatter.format(progress.durationRemaining),
style = theme.measurementTextStyle,
color = theme.measurementColor)
style = theme.measurementTextStyle)
if (theme.style == ArrivalViewStyle.INFORMATIONAL) {
Text(
text = "Duration",
style = theme.secondaryTextStyle,
color = theme.secondaryColor)
Text(text = "Duration", style = theme.secondaryTextStyle)
}
}

Column(
modifier = Modifier.weight(1f), horizontalAlignment = Alignment.CenterHorizontally) {
Text(
text = distanceFormatter.format(progress.distanceRemaining),
style = theme.measurementTextStyle,
color = theme.measurementColor)
style = theme.measurementTextStyle)
if (theme.style == ArrivalViewStyle.INFORMATIONAL) {
Text(
text = "Distance",
style = theme.secondaryTextStyle,
color = theme.secondaryColor)
Text(text = "Distance", style = theme.secondaryTextStyle)
}
}

Expand All @@ -127,12 +115,13 @@ fun ArrivalView(
onClick = { onTapExit() },
modifier = Modifier.size(50.dp),
shape = CircleShape,
colors = ButtonDefaults.buttonColors(containerColor = theme.secondaryColor),
colors =
ButtonDefaults.buttonColors(containerColor = theme.exitButtonBackgroundColor),
contentPadding = PaddingValues(0.dp)) {
Icon(
imageVector = Icons.Filled.Close,
contentDescription = "Close",
tint = Color.White)
tint = theme.exitIconColor)
}
}
}
Expand Down Expand Up @@ -164,18 +153,17 @@ fun ArrivalViewInformationalPreview() {
override val style: ArrivalViewStyle
@Composable get() = ArrivalViewStyle.INFORMATIONAL

override val measurementColor: Color
@Composable get() = MaterialTheme.colorScheme.onBackground

override val measurementTextStyle: TextStyle
@Composable
get() = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.SemiBold)

override val secondaryColor: Color
@Composable get() = MaterialTheme.colorScheme.secondary
get() =
MaterialTheme.typography.titleLarge.copy(
color = MaterialTheme.colorScheme.onBackground, fontWeight = FontWeight.SemiBold)

override val secondaryTextStyle: TextStyle
@Composable get() = MaterialTheme.typography.labelSmall
@Composable
get() =
MaterialTheme.typography.labelSmall.copy(
color = MaterialTheme.colorScheme.onBackground)

override val exitIconColor: Color
@Composable get() = MaterialTheme.colorScheme.onSecondary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun InstructionsView(
modifier =
Modifier.fillMaxWidth()
.shadow(elevation = 5.dp, RoundedCornerShape(10.dp))
.background(MaterialTheme.colorScheme.background, RoundedCornerShape(10.dp))
.background(theme.backgroundColor, RoundedCornerShape(10.dp))
.padding(8.dp)) {
ManeuverInstructionView(
text = instructions.primaryContent.text,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading