-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First whack at progress view for Android with current road name * Rename on web * Refactor again after discovering SwiftUI name conflict with ProgressView * Easily expose currentRoadName to VMs; first pass Swift rename; Android cleanup * Widen threshold for bad devices / some simulations * Apply automatic changes * Remove extraneous clones * Fix JS formatting * Add iOS views * Try return again? Does GH still run XC 15 or something?? * Switch to white text color on iOS after trying a few options * Android extensibility improvements * Extract styling of border; bump target to iOS 16 for AnyShape * Swiftformat * Remove some extraneous init args; make theme optional * Clean things up with modifier pattern * Add snapshot tests * Document the current road view customization * Rename to US style to MUTCD * More documentation of how the annotations work --------- Co-authored-by: ianthetechie <ianthetechie@users.noreply.github.com>
- Loading branch information
1 parent
dbee23a
commit 67ad4ee
Showing
81 changed files
with
701 additions
and
286 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
35 changes: 35 additions & 0 deletions
35
...oid/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/theme/RoadNameViewTheme.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,35 @@ | ||
package com.stadiamaps.ferrostar.composeui.theme | ||
|
||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
|
||
/** Themes for progress view components */ | ||
interface RoadNameViewTheme { | ||
/** The text style for the measurement/value. */ | ||
@get:Composable val textStyle: TextStyle | ||
/** The background color for the view. */ | ||
@get:Composable val backgroundColor: Color | ||
/** The border color for the view. */ | ||
@get:Composable val borderColor: Color | ||
} | ||
|
||
/** | ||
* A default theme for the road name view. | ||
* | ||
* The text style comes from your material theme. The background properties are hard-coded based on | ||
* the default polyline styling, as this doesn't have any clear analog in the material theme. | ||
*/ | ||
object DefaultRoadNameViewTheme : RoadNameViewTheme { | ||
override val textStyle: TextStyle | ||
@Composable | ||
get() = | ||
MaterialTheme.typography.labelSmall.copy(color = MaterialTheme.colorScheme.inverseOnSurface) | ||
|
||
override val backgroundColor: Color | ||
@Composable get() = Color(0x35, 0x83, 0xdd) | ||
|
||
override val borderColor: Color | ||
@Composable get() = Color.White | ||
} |
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
57 changes: 57 additions & 0 deletions
57
android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/views/CurrentRoadView.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,57 @@ | ||
package com.stadiamaps.ferrostar.composeui.views | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.shadow | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.stadiamaps.ferrostar.composeui.theme.DefaultRoadNameViewTheme | ||
import com.stadiamaps.ferrostar.composeui.theme.RoadNameViewTheme | ||
|
||
/** | ||
* A view that displays the estimated arrival time, the remaining distance, and the remaining | ||
* duration of a trip. | ||
* | ||
* @param currentRoadName The name of the current road. | ||
* @param modifier The modifier to apply to this layout. | ||
* @param theme The theme to use for this view. | ||
* @param borderStroke The stroke to draw for the border (defaults to 1dp using the theme's | ||
* borderColor). | ||
* @param shape The shape of the view (defaults to a 50% rounded corner). | ||
* @param paddingValues Padding to apply around the name label to increase the shape size (defaults | ||
* to 12dp in all directions). | ||
*/ | ||
@Composable | ||
fun CurrentRoadNameView( | ||
currentRoadName: String, | ||
modifier: Modifier = Modifier, | ||
theme: RoadNameViewTheme = DefaultRoadNameViewTheme, | ||
borderStroke: BorderStroke = BorderStroke(1.dp, theme.borderColor), | ||
shape: Shape = RoundedCornerShape(50), | ||
paddingValues: PaddingValues = PaddingValues(12.dp), | ||
) { | ||
Box( | ||
modifier = | ||
modifier | ||
.shadow(12.dp, shape = shape) | ||
.background(color = theme.backgroundColor, shape = shape) | ||
.border(borderStroke, shape = shape) | ||
.padding(paddingValues = paddingValues)) { | ||
Text(currentRoadName, style = theme.textStyle) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun CurrentRoadNameViewPreview() { | ||
CurrentRoadNameView("Sesame Street") | ||
} |
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
Oops, something went wrong.