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

Progress view current road #307

Merged
merged 22 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6613912
First whack at progress view for Android with current road name
ianthetechie Oct 23, 2024
7df0fc8
Rename on web
ianthetechie Oct 23, 2024
19113af
Refactor again after discovering SwiftUI name conflict with ProgressView
ianthetechie Oct 23, 2024
55cb950
Easily expose currentRoadName to VMs; first pass Swift rename; Androi…
ianthetechie Oct 23, 2024
00f1e0b
Widen threshold for bad devices / some simulations
ianthetechie Oct 23, 2024
db63361
Apply automatic changes
ianthetechie Oct 23, 2024
f97cfa6
Remove extraneous clones
ianthetechie Oct 23, 2024
a254d7d
Fix JS formatting
ianthetechie Oct 23, 2024
22e09a1
Add iOS views
ianthetechie Oct 24, 2024
bd74fb4
Try return again? Does GH still run XC 15 or something??
ianthetechie Oct 24, 2024
e683801
Switch to white text color on iOS after trying a few options
ianthetechie Oct 24, 2024
2ec1130
Merge branch 'main' into progress-view-current-road
ianthetechie Oct 28, 2024
272d56d
Android extensibility improvements
ianthetechie Oct 29, 2024
711d020
Extract styling of border; bump target to iOS 16 for AnyShape
ianthetechie Oct 29, 2024
5e1c3a8
Swiftformat
ianthetechie Oct 29, 2024
6e63508
Merge branch 'main' into progress-view-current-road
ianthetechie Oct 29, 2024
227e5d8
Remove some extraneous init args; make theme optional
ianthetechie Oct 29, 2024
8f1e8f9
Clean things up with modifier pattern
ianthetechie Oct 30, 2024
ff0f72f
Add snapshot tests
ianthetechie Oct 30, 2024
7c501a2
Document the current road view customization
ianthetechie Oct 30, 2024
fe78c96
Rename to US style to MUTCD
ianthetechie Oct 30, 2024
40f0d07
More documentation of how the annotations work
ianthetechie Oct 30, 2024
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
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "7b0bbbae90c41f848f90ac7b4df6c4f50068256d",
"version" : "1.17.5"
"revision" : "42a086182681cf661f5c47c9b7dc3931de18c6d7",
"version" : "1.17.6"
}
},
{
Expand All @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/maplibre/swiftui-dsl",
"state" : {
"revision" : "c39688db3aac50b523ea062b286c584123022093",
"version" : "0.3.0"
"revision" : "a6e079ce382e7860bc9105a05534f967a2f9ef65",
"version" : "0.3.1"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if useLocalFramework {
path: "./common/target/ios/libferrostar-rs.xcframework"
)
} else {
let releaseTag = "0.19.0"
let releaseTag = "0.20.0"
let releaseChecksum = "b3565c57b70ac72426e10e7d3c3020900c07548d0eede8200ef4d07edb617a22"
binaryTarget = .binaryTarget(
name: "FerrostarCoreRS",
Expand All @@ -39,7 +39,7 @@ let package = Package(
name: "FerrostarCore",
defaultLocalization: "en",
platforms: [
.iOS(.v15),
.iOS(.v16),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ ext {

allprojects {
group = "com.stadiamaps.ferrostar"
version = "0.19.0"
version = "0.20.0"
}
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
ianthetechie marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight

enum class ArrivalViewStyle {
/** A simple arrival view with only values. */
enum class TripProgressViewStyle {
/** A simple progress view with only values. */
SIMPLIFIED,
/** An arrival view with label captions in addition to values. */
/** An progress view with label captions in addition to values. */
INFORMATIONAL
}

/** Themes for arrival view components */
interface ArrivalViewTheme {
/** Themes for progress view components */
interface TripProgressViewTheme {
/** The text style for the step distance (or distance to step). */
@get:Composable val style: ArrivalViewStyle
@get:Composable val style: TripProgressViewStyle
/** The text style for the measurement/value. */
@get:Composable val measurementTextStyle: TextStyle
/** The text style for the secondary content (label caption). */
Expand All @@ -29,9 +29,9 @@ interface ArrivalViewTheme {
@get:Composable val backgroundColor: Color
}

object DefaultArrivalViewTheme : ArrivalViewTheme {
override val style: ArrivalViewStyle
@Composable get() = ArrivalViewStyle.SIMPLIFIED
object DefaultTripProgressViewTheme : TripProgressViewTheme {
override val style: TripProgressViewStyle
@Composable get() = TripProgressViewStyle.SIMPLIFIED

override val measurementTextStyle: TextStyle
@Composable
Expand Down
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")
}
Loading