@towsila/expo-ui-library 4.17.1 → 4.18.1

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.1",
3
+ "version": "4.18.1",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -6,9 +6,12 @@ import { useAppTheme } from "../../context/ThemeContext";
6
6
  import CustomMarker from "./customMarker";
7
7
  import PositionMarker from "./positionMarker";
8
8
  import MovingMarker from "./movingMarker";
9
+ import { RouteInfo } from "../../types/route";
9
10
 
10
11
  type LngLat = [number, number];
11
12
 
13
+
14
+
12
15
  export interface MapMarker {
13
16
  id: string;
14
17
  lngLat: LngLat;
@@ -18,14 +21,20 @@ export interface MapMarker {
18
21
  shadow?:boolean;
19
22
 
20
23
  }
24
+ export interface MapRoute {
25
+ id: string;
26
+ geometry: { type: "LineString"; coordinates: LngLat[] };
27
+ color?: string;
28
+ }
21
29
 
30
+ type RouteInput = RouteInfo | RouteInfo[] | null | undefined;
22
31
  interface Props {
23
32
  mapStyle: any;
24
33
  position: LngLat;
25
34
  userVariant?: "dot" | "arrow"; // dot = blue dot, arrow = moving marker
26
35
  heading?: number;
27
36
  markers?: MapMarker[];
28
- routeGeometry?: { type: "LineString"; coordinates: LngLat[] } | null;
37
+ routeGeometry?: RouteInput;
29
38
  follow?: boolean; // camera follows the user
30
39
  children?: React.ReactNode; // extra layers if a screen needs them
31
40
  onCenterChange?: (center: [number, number]) => void;
@@ -43,20 +52,33 @@ export default function AppMap({
43
52
  cameraRef.current?.easeTo({ center: position, duration: 1000 });
44
53
  }, [follow, position[0], position[1]]);
45
54
 
55
+ const routes: RouteInfo[] = Array.isArray(routeGeometry)
56
+ ? routeGeometry
57
+ : routeGeometry
58
+ ? [routeGeometry]
59
+ : [];
46
60
  return (
47
61
  <MLMap style={StyleSheet.absoluteFill} mapStyle={mapStyle} onRegionDidChange={(e: any) => onCenterChange?.(e.nativeEvent.center)}>
48
62
  <Camera ref={cameraRef} initialViewState={{ center: position, zoom: 15 }} />
49
63
 
50
- {routeGeometry && (
51
- <GeoJSONSource id="route" data={{ type: "Feature", properties: {}, geometry: routeGeometry }}>
64
+ {routes.map((r, i) => (
65
+ <GeoJSONSource
66
+ key={i}
67
+ id={`route-${i}`}
68
+ data={{ type: "Feature", properties: {}, geometry: r.geometry }}
69
+ >
52
70
  <Layer
53
- id="route-line"
71
+ id={`route-line-${i}`}
54
72
  type="line"
55
73
  layout={{ "line-join": "round", "line-cap": "round" }}
56
- paint={{ "line-color": colors.text.primary, "line-width": 5, "line-opacity": 0.85 }}
74
+ paint={{
75
+ "line-color": i === 0 ? colors.primary : colors.text.primary,
76
+ "line-width": 5,
77
+ "line-opacity": 0.85,
78
+ }}
57
79
  />
58
80
  </GeoJSONSource>
59
- )}
81
+ ))}
60
82
 
61
83
  {userVariant === "arrow" ? (
62
84
  <MovingMarker id="me" lngLat={position} icon={MarkerIcon} rotation={heading} />