Skip to content

Commit

Permalink
feat: desktop webview bridge PoC with ornament and gesture settings (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sargunv authored Dec 30, 2024
1 parent 61f93cc commit 723e692
Show file tree
Hide file tree
Showing 25 changed files with 1,086 additions and 240 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.sargunv.maplibrecompose.demoapp

actual object Platform {
actual val supportsBlending = true
actual val supportsFps = true
actual val supportsCamera = true
actual val supportsLayers = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,20 @@ import dev.sargunv.maplibrecompose.material3.controls.AttributionButton
import dev.sargunv.maplibrecompose.material3.controls.DisappearingCompassButton
import dev.sargunv.maplibrecompose.material3.controls.DisappearingScaleBar

private val DEMOS =
listOf(
MarkersDemo,
EdgeToEdgeDemo,
StyleSwitcherDemo,
ClusteredPointsDemo,
AnimatedLayerDemo,
CameraStateDemo,
CameraFollowDemo,
FrameRateDemo,
)
private val DEMOS = buildList {
add(StyleSwitcherDemo)
if (Platform.supportsBlending) add(EdgeToEdgeDemo)
if (Platform.supportsLayers) {
add(MarkersDemo)
add(ClusteredPointsDemo)
add(AnimatedLayerDemo)
}
if (Platform.supportsCamera) {
add(CameraStateDemo)
add(CameraFollowDemo)
}
if (Platform.supportsFps) add(FrameRateDemo)
}

@Composable
fun DemoApp(navController: NavHostController = rememberNavController()) {
Expand Down Expand Up @@ -121,8 +124,10 @@ fun DemoAppBar(demo: Demo, navigateUp: () -> Unit, alpha: Float = 1f) {
}
},
actions = {
IconButton(onClick = { showInfo = true }) {
Icon(imageVector = Icons.Default.Info, contentDescription = "Info")
if (Platform.supportsBlending) {
IconButton(onClick = { showInfo = true }) {
Icon(imageVector = Icons.Default.Info, contentDescription = "Info")
}
}
},
)
Expand Down Expand Up @@ -151,20 +156,24 @@ fun DemoMapControls(
modifier: Modifier = Modifier,
onCompassClick: () -> Unit = {},
) {
Box(modifier = modifier.fillMaxSize().padding(8.dp)) {
DisappearingScaleBar(cameraState, modifier = Modifier.align(Alignment.TopStart))
DisappearingCompassButton(
cameraState,
modifier = Modifier.align(Alignment.TopEnd),
onClick = onCompassClick,
)
AttributionButton(styleState, modifier = Modifier.align(Alignment.BottomEnd))
if (Platform.supportsBlending) {
Box(modifier = modifier.fillMaxSize().padding(8.dp)) {
DisappearingScaleBar(cameraState, modifier = Modifier.align(Alignment.TopStart))
DisappearingCompassButton(
cameraState,
modifier = Modifier.align(Alignment.TopEnd),
onClick = onCompassClick,
)
AttributionButton(styleState, modifier = Modifier.align(Alignment.BottomEnd))
}
}
}

fun DemoOrnamentSettings(padding: PaddingValues = PaddingValues(0.dp)) =
OrnamentSettings.AllDisabled.copy(
padding = padding,
isLogoEnabled = true,
logoAlignment = Alignment.BottomStart,
)
if (Platform.supportsBlending)
OrnamentSettings.AllDisabled.copy(
padding = padding,
isLogoEnabled = true,
logoAlignment = Alignment.BottomStart,
)
else OrnamentSettings.AllEnabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.sargunv.maplibrecompose.demoapp

expect object Platform {
val supportsBlending: Boolean
val supportsFps: Boolean
val supportsCamera: Boolean
val supportsLayers: Boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.sargunv.maplibrecompose.demoapp

actual object Platform {
actual val supportsBlending = false
actual val supportsFps = false
actual val supportsCamera = false
actual val supportsLayers = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.sargunv.maplibrecompose.demoapp

actual object Platform {
actual val supportsBlending = true
actual val supportsFps = true
actual val supportsCamera = true
actual val supportsLayers = true
}
5 changes: 3 additions & 2 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ Desktop support is implemented with [MapLibre GL JS][maplibre-js] and
| Feature | Android | iOS | Desktop | Web |
| ------------------------------------------------- | ------------------ | ------------------ | ------------------ | --- |
| Render a map | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| Overlay Compose UI over the map | :white_check_mark: | :white_check_mark: | :x: | :x: |
| Load Compose resource URIs | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| Configure ornaments (compass, logo, attribution) | :white_check_mark: | :white_check_mark: | :x: | :x: |
| Configure gestures (pan, zoom, rotate, pitch) | :white_check_mark: | :white_check_mark: | :x: | :x: |
| Configure ornaments (compass, logo, attribution) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| Configure gestures (pan, zoom, rotate, pitch) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
| Respond to a map click or long click | :white_check_mark: | :white_check_mark: | :x: | :x: |
| Query visible map features | :white_check_mark: | :white_check_mark: | :x: | :x: |
| Get, set, and animate the camera position | :white_check_mark: | :white_check_mark: | :x: | :x: |
Expand Down
Loading

0 comments on commit 723e692

Please sign in to comment.