-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
90 changed files
with
914 additions
and
408 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.