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

Android route overview #345

Merged
merged 27 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7e77c8c
Initial checkpoint commit on Android route overview
ianthetechie Nov 4, 2024
ce94b79
Apply automatic changes
ianthetechie Nov 4, 2024
794d2de
Minor clean-up; version updates
ianthetechie Nov 5, 2024
5063fc7
Merge branch 'main' into route-overview-android
ianthetechie Nov 5, 2024
060e839
Merge branch 'main' into route-overview-android
ianthetechie Nov 6, 2024
6ab8f7e
Cleanup: by delegation
ianthetechie Nov 6, 2024
584bb74
State -> raw value
ianthetechie Nov 7, 2024
8318660
Move isNavigating into state so we don't have to pass a full viewmode…
ianthetechie Nov 7, 2024
bc096e3
Make onMapReadyCallback optional rather than a capturing default closure
ianthetechie Nov 7, 2024
3e99c47
Auto-adjust most insets
ianthetechie Nov 7, 2024
dd73e99
Support horizontal padding
ianthetechie Nov 7, 2024
8fc0ce8
Snapshots; hide mute button and move recenter to bottom leading corner
ianthetechie Nov 7, 2024
cf15dd8
Refactor; the layering makes sense now!
ianthetechie Nov 7, 2024
742a5ca
Undo experimental change
ianthetechie Nov 7, 2024
cee5ffd
Minor tweaks; update macOS CI to Sonoma
ianthetechie Nov 7, 2024
aee4461
Switch to iOS 18 simulator for snapshots; update nanopixel-perfect sn…
ianthetechie Nov 7, 2024
6819739
Ditch the view model swapping!
ianthetechie Nov 8, 2024
c12f3c8
Apply automatic changes
ianthetechie Nov 8, 2024
6545310
Remove old comments
ianthetechie Nov 8, 2024
06843fe
Fix imports
ianthetechie Nov 8, 2024
1d8d8db
Allow stopping demo VM location updates
ianthetechie Nov 10, 2024
df63897
Move view model to AppModule to better reflect a typical DI use case
ianthetechie Nov 11, 2024
5c03f41
Apply automatic changes
ianthetechie Nov 11, 2024
cc83bbd
Hide zoom controls as well when showing the recenter button
ianthetechie Nov 11, 2024
28dd2cc
Update snapshots
ianthetechie Nov 11, 2024
9cfff25
Freshen docs
ianthetechie Nov 11, 2024
98effcf
Release prep: bump version
ianthetechie Nov 11, 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
2 changes: 1 addition & 1 deletion .github/workflows/cargo-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:

jobs:
publish_crate:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Cargo Publish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build:

runs-on: macos-13
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
ios-release:
runs-on: macos-14
runs-on: macos-15

permissions:
contents: write
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
format-lint:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ios-swiftformat
cancel-in-progress: true
Expand All @@ -24,7 +24,7 @@ jobs:
run: swiftformat . --lint

build-ferrostar:
runs-on: macos-14
runs-on: macos-15
permissions:
contents: write # To auto-commit Package.swift and binding changes

Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
retention-days: 5

build-demo:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ios-build-demo
cancel-in-progress: true
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
retention-days: 5

test:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ios-test
cancel-in-progress: true
Expand All @@ -131,7 +131,7 @@ jobs:
]
destination: [
# TODO: Add more destinations
'platform=iOS Simulator,name=iPhone 15,OS=17.2'
'platform=iOS Simulator,name=iPhone 16 Pro,OS=18.1'
]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
build:
runs-on: macos-13
runs-on: macos-15

steps:
- name: Checkout code
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:

jobs:
msrv:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-rust-msrv
cancel-in-progress: true
Expand All @@ -27,7 +27,7 @@ jobs:
working-directory: common

semver-checks:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-rust-semver
cancel-in-progress: true
Expand All @@ -41,7 +41,7 @@ jobs:
feature-group: default-features

rustfmt:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-rust-rustfmt
cancel-in-progress: true
Expand All @@ -53,7 +53,7 @@ jobs:
working-directory: common

build:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-rust-build
cancel-in-progress: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
typos:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ios-swiftformat
cancel-in-progress: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wasm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:

jobs:
build:
runs-on: macos-14
runs-on: macos-15
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-wasm-build
cancel-in-progress: true
Expand Down
2 changes: 1 addition & 1 deletion 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.20.1"
let releaseTag = "0.21.0"
let releaseChecksum = "a5d8ecc5b4d4b77e2e9fd237b3c6ffd62772606a996a0e34f0fc7ecadc19fb9c"
binaryTarget = .binaryTarget(
name: "FerrostarCoreRS",
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.20.1"
version = "0.21.0"
}
2 changes: 1 addition & 1 deletion android/composeui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

android {
namespace 'com.stadiamaps.ferrostar.composeui'
compileSdk 34
compileSdk 35

defaultConfig {
minSdk 25
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.stadiamaps.ferrostar.composeui.config

import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp

sealed class CameraControlState {
data object Hidden : CameraControlState()

data class ShowRecenter(val updateCamera: () -> Unit) : CameraControlState()

data class ShowRouteOverview(val updateCamera: () -> Unit) : CameraControlState()
}

data class VisualNavigationViewConfig(
var showMute: Boolean = false,
var showZoom: Boolean = false,
var buttonSize: DpSize = DpSize(56.dp, 56.dp)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously an informal constant that was copied everywhere. This at least gives it a place to live, and opens the path for button scaling enhancements if needed.

) {
companion object {
fun Default() = VisualNavigationViewConfig(showMute = true, showZoom = true)
}
}

/** Enables the mute button in the navigation view. */
fun VisualNavigationViewConfig.useMuteButton(): VisualNavigationViewConfig {
showMute = true
return this
}

/** Enables the zoom button in the navigation view. */
fun VisualNavigationViewConfig.useZoomButton(): VisualNavigationViewConfig {
showZoom = true
return this
}

/** Changes the size of navigation buttons. */
fun VisualNavigationViewConfig.buttonSize(size: DpSize): VisualNavigationViewConfig {
buttonSize = size
return this
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import uniffi.ferrostar.VisualInstructionContent
fun InstructionsView(
instructions: VisualInstruction,
distanceToNextManeuver: Double?,
modifier: Modifier = Modifier,
distanceFormatter: DistanceFormatter = LocalizedDistanceFormatter(),
theme: InstructionRowTheme = DefaultInstructionRowTheme,
remainingSteps: List<RouteStep>? = null,
Expand All @@ -69,7 +70,8 @@ fun InstructionsView(

Box(
modifier =
Modifier.fillMaxWidth()
modifier
.fillMaxWidth()
.heightIn(max = screenHeight)
.animateContentSize(animationSpec = spring(stiffness = Spring.StiffnessHigh))
.background(theme.backgroundColor, RoundedCornerShape(10.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package com.stadiamaps.ferrostar.composeui.views.controls

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
Expand All @@ -18,6 +17,7 @@ import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.stadiamaps.ferrostar.composeui.R

Expand All @@ -32,13 +32,14 @@ import com.stadiamaps.ferrostar.composeui.R
@Composable
fun NavigationUIButton(
onClick: () -> Unit,
buttonSize: DpSize,
containerColor: Color = FloatingActionButtonDefaults.containerColor,
contentColor: Color = contentColorFor(containerColor),
content: @Composable () -> Unit
) {
FloatingActionButton(
onClick,
modifier = Modifier.width(56.dp).height(56.dp).shadow(6.dp, shape = CircleShape),
modifier = Modifier.size(buttonSize).shadow(6.dp, shape = CircleShape),
shape = CircleShape,
containerColor,
contentColor) {
Expand All @@ -50,7 +51,7 @@ fun NavigationUIButton(
@Composable
fun NavigationUIButtonPreview() {
Box(Modifier.background(Color.LightGray).padding(16.dp)) {
NavigationUIButton({}) {
NavigationUIButton({}, DpSize(56.dp, 56.dp)) {
Icon(Icons.Filled.Close, contentDescription = stringResource(id = R.string.end_navigation))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
Expand All @@ -22,11 +23,13 @@ import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import com.stadiamaps.ferrostar.composeui.R

@Composable
fun NavigationUIZoomButton(
buttonSize: DpSize,
onClickZoomIn: () -> Unit,
onClickZoomOut: () -> Unit,
containerColor: Color = FloatingActionButtonDefaults.containerColor,
Expand All @@ -38,7 +41,7 @@ fun NavigationUIZoomButton(
Column(modifier = Modifier.shadow(6.dp, shape = RoundedCornerShape(50))) {
FloatingActionButton(
onClick = onClickZoomIn,
modifier = Modifier.height(56.dp).width(56.dp),
modifier = Modifier.size(buttonSize),
shape = RoundedCornerShape(topStartPercent = 50, topEndPercent = 50),
containerColor = containerColor,
contentColor = contentColor,
Expand All @@ -48,13 +51,13 @@ fun NavigationUIZoomButton(
contentDescription = stringResource(id = R.string.zoom_in))
}

Box(modifier = Modifier.height(1.dp).width(56.dp)) {
Box(modifier = Modifier.height(1.dp).width(buttonSize.width)) {
HorizontalDivider(color = MaterialTheme.colorScheme.surfaceVariant)
}

FloatingActionButton(
onClick = onClickZoomOut,
modifier = Modifier.height(56.dp).width(56.dp),
modifier = Modifier.size(buttonSize),
shape = RoundedCornerShape(bottomStartPercent = 50, bottomEndPercent = 50),
containerColor = containerColor,
contentColor = contentColor,
Expand All @@ -69,5 +72,8 @@ fun NavigationUIZoomButton(
@Preview
@Composable
fun NavigationUIZoomButtonPreview() {
Box(Modifier.background(Color.LightGray).padding(16.dp)) { NavigationUIZoomButton({}, {}) }
Box(Modifier.background(Color.LightGray).padding(16.dp)) {
NavigationUIZoomButton(
buttonSize = DpSize(56.dp, 56.dp), onClickZoomIn = {}, onClickZoomOut = {})
}
}
Loading
Loading