Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5fa7d398 authored by Ellen Poe's avatar Ellen Poe
Browse files

feat: better location puck icon

parent 8d8aeecd
Loading
Loading
Loading
Loading
+7 −47
Original line number Diff line number Diff line
@@ -20,22 +20,13 @@ package earth.maps.cardinal.ui.map

import android.location.Location
import android.util.Log
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import earth.maps.cardinal.R.drawable
import earth.maps.cardinal.ui.theme.onPuckColorDark
import earth.maps.cardinal.ui.theme.onPuckColorLight
import earth.maps.cardinal.ui.theme.puckColorDark
import earth.maps.cardinal.ui.theme.puckColorLight
import io.github.dellisd.spatialk.geojson.Point
import io.github.dellisd.spatialk.geojson.Position
import org.maplibre.compose.expressions.dsl.const
import org.maplibre.compose.expressions.dsl.image
import org.maplibre.compose.expressions.dsl.offset
import org.maplibre.compose.layers.CircleLayer
import org.maplibre.compose.layers.SymbolLayer
import org.maplibre.compose.sources.GeoJsonData
import org.maplibre.compose.sources.Source
@@ -44,47 +35,16 @@ import org.maplibre.compose.sources.rememberGeoJsonSource

@Composable
fun LocationPuckLayers(idPrefix: String, locationSource: Source, headingDegrees: Float?) {
    val puckColor = if (isSystemInDarkTheme()) {
        puckColorDark
    val puckDrawable = if (headingDegrees == null) {
        painterResource(drawable.location_puck)
    } else {
        puckColorLight
        painterResource(drawable.location_puck_with_arrow)
    }
    val puckShadowColor = if (isSystemInDarkTheme()) {
        onPuckColorDark
    } else {
        onPuckColorLight
    }
    val compassDrawable = if (isSystemInDarkTheme()) {
        painterResource(drawable.compass_dark)
    } else {
        painterResource(drawable.compass_light)
    }


    headingDegrees?.let { headingDegrees ->
    SymbolLayer(
            id = "${idPrefix}-compass",
            source = locationSource,
            iconImage = image(compassDrawable),
            iconRotate = const(headingDegrees),
            iconColor = const(puckColor),
        )
    }
    CircleLayer(
        id = "${idPrefix}-shadow",
        source = locationSource,
        radius = const(13.dp),
        color = const(puckShadowColor),
        blur = const(1f),
        translate = offset(0.dp, 1.dp),
    )
    CircleLayer(
        id = "${idPrefix}-circle",
        id = "${idPrefix}-puck",
        source = locationSource,
        radius = const(7.dp),
        color = const(puckColor),
        strokeColor = const(Color.White),
        strokeWidth = const(3.dp),
        iconImage = image(puckDrawable),
        iconRotate = const(headingDegrees ?: 0f),
    )
}

+0 −24
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    android:width="64dp"
    android:height="64dp"
    android:viewportWidth="64"
    android:viewportHeight="64">
  <path
      android:pathData="m33.323,35.492c0,0 16.03,-30.855 15.9,-30.939 -15.824,-10.264 -33.057,0 -33.057,0z"
      android:strokeAlpha="0"
      android:strokeWidth="0"
      android:strokeColor="#ffffff">
    <aapt:attr name="android:fillColor">
      <gradient
          android:startX="32.663"
          android:startY="-0.954"
          android:endX="33.38"
          android:endY="38.744"
          android:type="linear">
        <item android:offset="0" android:color="#FFA7C8FF"/>
        <item android:offset="1" android:color="#0EFFFFFF"/>
      </gradient>
    </aapt:attr>
  </path>
</vector>
+0 −24
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    android:width="64dp"
    android:height="64dp"
    android:viewportWidth="64"
    android:viewportHeight="64">
  <path
      android:pathData="m33.323,35.492c0,0 16.03,-30.855 15.9,-30.939 -15.824,-10.264 -33.057,0 -33.057,0z"
      android:strokeAlpha="0"
      android:strokeWidth="0"
      android:strokeColor="#ffffff">
    <aapt:attr name="android:fillColor">
      <gradient
          android:startX="32.663"
          android:startY="-0.954"
          android:endX="33.38"
          android:endY="38.744"
          android:type="linear">
        <item android:offset="0" android:color="#FF3E5F90"/>
        <item android:offset="1" android:color="#0EFFFFFF"/>
      </gradient>
    </aapt:attr>
  </path>
</vector>
+29 −0
Original line number Diff line number Diff line
<!--
  ~     Cardinal Maps
  ~     Copyright (C) 2025 Cardinal Maps Authors
  ~
  ~     This program is free software: you can redistribute it and/or modify
  ~     it under the terms of the GNU General Public License as published by
  ~     the Free Software Foundation, either version 3 of the License, or
  ~     (at your option) any later version.
  ~
  ~     This program is distributed in the hope that it will be useful,
  ~     but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~     GNU General Public License for more details.
  ~
  ~     You should have received a copy of the GNU General Public License
  ~     along with this program.  If not, see <https://www.gnu.org/licenses/>.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="64dp"
    android:height="64dp"
    android:viewportWidth="64"
    android:viewportHeight="64">
  <path
      android:pathData="M32,32m-7,0a7,7 0,1 1,14 0a7,7 0,1 1,-14 0"
      android:strokeWidth="2"
      android:fillColor="#4285F4"
      android:strokeColor="#FFFFFF"/>
</vector>
+37 −0
Original line number Diff line number Diff line
<!--
  ~     Cardinal Maps
  ~     Copyright (C) 2025 Cardinal Maps Authors
  ~
  ~     This program is free software: you can redistribute it and/or modify
  ~     it under the terms of the GNU General Public License as published by
  ~     the Free Software Foundation, either version 3 of the License, or
  ~     (at your option) any later version.
  ~
  ~     This program is distributed in the hope that it will be useful,
  ~     but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~     GNU General Public License for more details.
  ~
  ~     You should have received a copy of the GNU General Public License
  ~     along with this program.  If not, see <https://www.gnu.org/licenses/>.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="64dp"
    android:viewportHeight="64"
    android:viewportWidth="64"
    android:width="64dp">

    <path
        android:fillColor="#4285F4"
        android:pathData="M32,32m-7,0a7,7 0,1 1,14 0a7,7 0,1 1,-14 0"
        android:strokeColor="#FFFFFF"
        android:strokeWidth="2" />

    <path
        android:fillColor="#4285F4"
        android:strokeColor="#FFFFFF"
        android:strokeWidth="0.8"
        android:pathData="M32,15L28,21L36,21Z" />

</vector>