@towsila/expo-ui-library 4.18.0 → 4.18.2

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