@towsila/expo-ui-library 4.17.0 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@towsila/expo-ui-library",
3
- "version": "4.17.0",
3
+ "version": "4.18.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12 2.5L19.5 20L12 15.8L4.5 20L12 2.5Z" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>
3
+ </svg>
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  import { StyleSheet } from "react-native";
3
3
  import { Map as MLMap, Camera, GeoJSONSource, Layer } from "@maplibre/maplibre-react-native";
4
- import MarkerIcon from "@/assets/images/icons/marker.svg";
4
+ import MarkerIcon from "../../assets/icons/marker.svg";
5
5
  import { useAppTheme } from "../../context/ThemeContext";
6
6
  import CustomMarker from "./customMarker";
7
7
  import PositionMarker from "./positionMarker";
@@ -9,6 +9,8 @@ import MovingMarker from "./movingMarker";
9
9
 
10
10
  type LngLat = [number, number];
11
11
 
12
+
13
+
12
14
  export interface MapMarker {
13
15
  id: string;
14
16
  lngLat: LngLat;
@@ -18,14 +20,24 @@ export interface MapMarker {
18
20
  shadow?:boolean;
19
21
 
20
22
  }
23
+ export interface MapRoute {
24
+ id: string;
25
+ geometry: { type: "LineString"; coordinates: LngLat[] };
26
+ color?: string;
27
+ }
21
28
 
29
+ type RouteInput =
30
+ | { type: "LineString"; coordinates: LngLat[] } // single route (old callers)
31
+ | MapRoute[] // array of routes (new)
32
+ | null
33
+ | undefined;
22
34
  interface Props {
23
35
  mapStyle: any;
24
36
  position: LngLat;
25
37
  userVariant?: "dot" | "arrow"; // dot = blue dot, arrow = moving marker
26
38
  heading?: number;
27
39
  markers?: MapMarker[];
28
- routeGeometry?: { type: "LineString"; coordinates: LngLat[] } | null;
40
+ routeGeometry?: RouteInput;
29
41
  follow?: boolean; // camera follows the user
30
42
  children?: React.ReactNode; // extra layers if a screen needs them
31
43
  onCenterChange?: (center: [number, number]) => void;
@@ -43,20 +55,33 @@ export default function AppMap({
43
55
  cameraRef.current?.easeTo({ center: position, duration: 1000 });
44
56
  }, [follow, position[0], position[1]]);
45
57
 
58
+ const routes: MapRoute[] = Array.isArray(routeGeometry)
59
+ ? routeGeometry
60
+ : routeGeometry
61
+ ? [{ id: "default-route", geometry: routeGeometry, color: colors.text.primary }]
62
+ : [];
46
63
  return (
47
64
  <MLMap style={StyleSheet.absoluteFill} mapStyle={mapStyle} onRegionDidChange={(e: any) => onCenterChange?.(e.nativeEvent.center)}>
48
65
  <Camera ref={cameraRef} initialViewState={{ center: position, zoom: 15 }} />
49
66
 
50
- {routeGeometry && (
51
- <GeoJSONSource id="route" data={{ type: "Feature", properties: {}, geometry: routeGeometry }}>
67
+ {routes.map((r) => (
68
+ <GeoJSONSource
69
+ key={r.id}
70
+ id={r.id}
71
+ data={{ type: "Feature", properties: {}, geometry: r.geometry }}
72
+ >
52
73
  <Layer
53
- id="route-line"
74
+ id={`${r.id}-line`}
54
75
  type="line"
55
76
  layout={{ "line-join": "round", "line-cap": "round" }}
56
- paint={{ "line-color": colors.text.primary, "line-width": 5, "line-opacity": 0.85 }}
77
+ paint={{
78
+ "line-color": r.color ?? colors.text.primary,
79
+ "line-width": 5,
80
+ "line-opacity": 0.85,
81
+ }}
57
82
  />
58
83
  </GeoJSONSource>
59
- )}
84
+ ))}
60
85
 
61
86
  {userVariant === "arrow" ? (
62
87
  <MovingMarker id="me" lngLat={position} icon={MarkerIcon} rotation={heading} />