@towsila/expo-ui-library 4.13.2 → 4.15.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.13.2",
3
+ "version": "4.15.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -15,6 +15,7 @@
15
15
  "@react-native-async-storage/async-storage": "*",
16
16
  "expo": "*",
17
17
  "expo-device": "*",
18
+ "expo-font": "*",
18
19
  "expo-haptics": "*",
19
20
  "expo-linear-gradient": "*",
20
21
  "expo-location": "*",
@@ -27,7 +28,7 @@
27
28
  "react-native-reanimated": "*",
28
29
  "react-native-safe-area-context": "*",
29
30
  "react-native-svg": "*",
30
- "expo-font": "*"
31
+ "@maplibre/maplibre-react-native": "*"
31
32
  },
32
33
  "scripts": {
33
34
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -47,7 +48,8 @@
47
48
  "devDependencies": {
48
49
  "@types/react": "^19.2.17",
49
50
  "react-native-svg": "^15.15.5",
50
- "typescript": "^6.0.3"
51
+ "typescript": "^6.0.3",
52
+ "@maplibre/maplibre-react-native": "^11.0.0"
51
53
  },
52
54
  "dependencies": {
53
55
  "@expo/vector-icons": "^15.1.1",
@@ -15,6 +15,7 @@ interface Props {
15
15
  error?: string;
16
16
  onBack: () => void;
17
17
  loading?: boolean;
18
+ footer?: React.ReactNode;
18
19
  }
19
20
 
20
21
  export default function TemplateSubPage({
@@ -26,6 +27,7 @@ export default function TemplateSubPage({
26
27
  error,
27
28
  onBack,
28
29
  loading,
30
+ footer,
29
31
  }: Props) {
30
32
  const { colors } = useAppTheme();
31
33
 
@@ -62,7 +64,7 @@ export default function TemplateSubPage({
62
64
  {children}
63
65
  </View>
64
66
  </ScrollView>
65
-
67
+ {footer ? <View style={{ marginTop: 12 }}>{footer}</View> : null}
66
68
  {buttonText && (
67
69
  <View style={{ marginTop: 16 }}>
68
70
  <SharpButton
@@ -107,6 +107,7 @@ export default function ProfileLayout({
107
107
  buttonText={showButton ? button : undefined}
108
108
  handleFunction={onSubmit}
109
109
  loading={loading}
110
+ footer={footer}
110
111
  >
111
112
  <View style={{ gap: 10 }}>
112
113
  <Text
@@ -141,8 +142,6 @@ export default function ProfileLayout({
141
142
 
142
143
  {extraCard ? <View style={cardStyle(colors)}>{extraCard}</View> : null}
143
144
  </View>
144
-
145
- {footer}
146
145
  </TemplateSubPage>
147
146
  );
148
147
  }
@@ -0,0 +1,82 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { StyleSheet } from "react-native";
3
+ import { Map as MLMap, Camera, GeoJSONSource, Layer } from "@maplibre/maplibre-react-native";
4
+ import MarkerIcon from "@/assets/images/icons/marker.svg";
5
+ import { useAppTheme } from "../../context/ThemeContext";
6
+ import CustomMarker from "./customMarker";
7
+ import PositionMarker from "./positionMarker";
8
+ import MovingMarker from "./movingMarker";
9
+
10
+ type LngLat = [number, number];
11
+
12
+ export interface MapMarker {
13
+ id: string;
14
+ lngLat: LngLat;
15
+ icon: any;
16
+ selected?: boolean;
17
+ onPress?: () => void;
18
+ shadow?:boolean;
19
+
20
+ }
21
+
22
+ interface Props {
23
+ mapStyle: any;
24
+ position: LngLat;
25
+ userVariant?: "dot" | "arrow"; // dot = blue dot, arrow = moving marker
26
+ heading?: number;
27
+ markers?: MapMarker[];
28
+ routeGeometry?: { type: "LineString"; coordinates: LngLat[] } | null;
29
+ follow?: boolean; // camera follows the user
30
+ children?: React.ReactNode; // extra layers if a screen needs them
31
+ onCenterChange?: (center: [number, number]) => void;
32
+ }
33
+
34
+ export default function AppMap({
35
+ mapStyle, position, userVariant = "dot", heading = 0,
36
+ markers = [], routeGeometry, follow = false, children, onCenterChange
37
+ }: Props) {
38
+ const { colors } = useAppTheme();
39
+ const cameraRef = useRef<any>(null);
40
+
41
+ useEffect(() => {
42
+ if (!follow) return;
43
+ cameraRef.current?.easeTo({ center: position, duration: 1000 });
44
+ }, [follow, position[0], position[1]]);
45
+
46
+ return (
47
+ <MLMap style={StyleSheet.absoluteFill} mapStyle={mapStyle} onRegionDidChange={(e: any) => onCenterChange?.(e.nativeEvent.center)}>
48
+ <Camera ref={cameraRef} initialViewState={{ center: position, zoom: 15 }} />
49
+
50
+ {routeGeometry && (
51
+ <GeoJSONSource id="route" data={{ type: "Feature", properties: {}, geometry: routeGeometry }}>
52
+ <Layer
53
+ id="route-line"
54
+ type="line"
55
+ layout={{ "line-join": "round", "line-cap": "round" }}
56
+ paint={{ "line-color": colors.text.primary, "line-width": 5, "line-opacity": 0.85 }}
57
+ />
58
+ </GeoJSONSource>
59
+ )}
60
+
61
+ {userVariant === "arrow" ? (
62
+ <MovingMarker id="me" lngLat={position} icon={MarkerIcon} rotation={heading} />
63
+ ) : (
64
+ <PositionMarker lngLat={position} color={colors.primary} />
65
+ )}
66
+
67
+ {markers.map((m) => (
68
+ <CustomMarker
69
+ key={m.id}
70
+ id={m.id}
71
+ lngLat={m.lngLat}
72
+ icon={m.icon}
73
+ selected={m.selected}
74
+ onPress={m.onPress}
75
+ shadow={m.shadow}
76
+ />
77
+ ))}
78
+
79
+ {children}
80
+ </MLMap>
81
+ );
82
+ }
@@ -0,0 +1,138 @@
1
+
2
+ import { Marker } from "@maplibre/maplibre-react-native";
3
+ import { Pressable, View } from "react-native";
4
+ import { SvgProps } from "react-native-svg";
5
+ import { useAppTheme } from "../../context/ThemeContext";
6
+
7
+ type Props = {
8
+ lngLat: [number, number]; // [longitude, latitude]
9
+ icon: React.ComponentType<SvgProps>;
10
+ id?: string;
11
+ rotation?: number;
12
+ selected?: boolean;
13
+ shadow?: boolean;
14
+ onPress?: () => void;
15
+ };
16
+
17
+ const PAD = 26; // room for the halo and shadow, so they are not clipped
18
+
19
+ export default function CustomMarker({
20
+ lngLat,
21
+ icon: Icon,
22
+ id = "me",
23
+ rotation,
24
+ selected = true,
25
+ onPress,
26
+ shadow = false,
27
+ }: Props) {
28
+ const { colors } = useAppTheme();
29
+ const badge = 38;
30
+ const box = badge + PAD * 2;
31
+
32
+ return (
33
+ <Marker id={id} lngLat={lngLat} anchor="center">
34
+ <Pressable onPress={onPress} hitSlop={10} disabled={!onPress}>
35
+ <View
36
+ style={{
37
+ width: box,
38
+ height: box,
39
+ alignItems: "center",
40
+ justifyContent: "center",
41
+ }}
42
+ >
43
+ {shadow && (
44
+ <>
45
+ {/* Wide, soft ambient shadow */}
46
+ <View
47
+ style={{
48
+ position: "absolute",
49
+ width: badge + 24,
50
+ height: badge + 24,
51
+ borderRadius: (badge + 24) / 2,
52
+ backgroundColor: colors.primary,
53
+ opacity: 0.07,
54
+ }}
55
+ />
56
+
57
+ {/* Mid-range shadow */}
58
+ <View
59
+ style={{
60
+ position: "absolute",
61
+ width: badge + 14,
62
+ height: badge + 14,
63
+ borderRadius: (badge + 14) / 2,
64
+ backgroundColor: colors.primary,
65
+ opacity: 0.10,
66
+ }}
67
+ />
68
+
69
+ {/* Soft shadow close to the badge */}
70
+ <View
71
+ style={{
72
+ position: "absolute",
73
+ width: badge + 6,
74
+ height: badge + 6,
75
+ borderRadius: (badge + 6) / 2,
76
+ backgroundColor: colors.primary,
77
+ opacity: 0.24,
78
+ }}
79
+ />
80
+
81
+ {/* Soft black ground shadow under the badge */}
82
+ {[
83
+ { w: 0.95, h: 0.34, opacity: 0.1 },
84
+ { w: 0.75, h: 0.26, opacity: 0.16 },
85
+ { w: 0.5, h: 0.18, opacity: 0.26 },
86
+ ].map(({ w, h, opacity }) => (
87
+ <View
88
+ key={w}
89
+ style={{
90
+ position: "absolute",
91
+ top: PAD + badge - badge * h * 0.5 + 2,
92
+ width: badge * w,
93
+ height: badge * h,
94
+ borderRadius: badge,
95
+ backgroundColor: colors.primary,
96
+ opacity,
97
+ }}
98
+ />
99
+ ))}
100
+ </>
101
+ )}
102
+
103
+ {/* Badge: only this part rotates */}
104
+ <View
105
+ style={{
106
+ width: badge,
107
+ height: badge,
108
+ borderRadius: badge / 2,
109
+ alignItems: "center",
110
+ justifyContent: "center",
111
+ backgroundColor: colors.primary,
112
+ borderWidth: selected ? 2 : 0,
113
+ borderColor: colors.text.primary,
114
+ transform: [{ rotate: `${rotation ?? 0}deg` }],
115
+ ...(shadow && {
116
+ shadowColor: colors.background.card,
117
+ shadowOpacity: 0.7,
118
+ shadowRadius: 10,
119
+ shadowOffset: { width: 0, height: 3 },
120
+ elevation: 8,
121
+ }),
122
+ }}
123
+ >
124
+ <Icon
125
+ color={
126
+ selected
127
+ ? colors.text.primary
128
+ : colors.background.card
129
+ }
130
+ width={22}
131
+ height={22}
132
+ />
133
+ </View>
134
+ </View>
135
+ </Pressable>
136
+ </Marker>
137
+ );
138
+ }
@@ -0,0 +1,36 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ import CustomMarker from "./customMarker";
3
+
4
+ function useAnimatedPosition(target: [number, number], duration = 1500) {
5
+ const [pos, setPos] = useState(target);
6
+ const from = useRef(target);
7
+ const raf = useRef<number | null>(null);
8
+
9
+ useEffect(() => {
10
+ const start = from.current;
11
+ const t0 = Date.now();
12
+ const step = () => {
13
+ const k = Math.min((Date.now() - t0) / duration, 1);
14
+ const cur: [number, number] = [
15
+ start[0] + (target[0] - start[0]) * k,
16
+ start[1] + (target[1] - start[1]) * k,
17
+ ];
18
+ from.current = cur;
19
+ setPos(cur);
20
+ if (k < 1) raf.current = requestAnimationFrame(step);
21
+ };
22
+ raf.current = requestAnimationFrame(step);
23
+ return () => {
24
+ if (raf.current) cancelAnimationFrame(raf.current);
25
+ };
26
+ }, [target[0], target[1]]);
27
+
28
+ return pos;
29
+ }
30
+
31
+ export default function MovingMarker({
32
+ lngLat, ...rest
33
+ }: { lngLat: [number, number] } & Omit<React.ComponentProps<typeof CustomMarker>, "lngLat">) {
34
+ const pos = useAnimatedPosition(lngLat);
35
+ return <CustomMarker lngLat={pos} {...rest} />;
36
+ }
@@ -0,0 +1,63 @@
1
+ import { Marker } from "@maplibre/maplibre-react-native";
2
+ import { useEffect, useRef } from "react";
3
+ import { Animated, Easing, View } from "react-native";
4
+ import { useAppTheme } from "../../context/ThemeContext";
5
+
6
+ type Props = {
7
+ lngLat: [number, number]; // [longitude, latitude]
8
+ id?: string;
9
+ color?: string;
10
+ };
11
+
12
+ const SIZE = 100; // fixed box, big enough to hold the full pulse without clipping
13
+ const DOT = 16;
14
+
15
+ export default function PositionMarker({ lngLat, id = "user", color = "#1a73e8" }: Props) {
16
+ const pulse = useRef(new Animated.Value(0)).current;
17
+ const {colors} = useAppTheme();
18
+ useEffect(() => {
19
+ const loop = Animated.loop(
20
+ Animated.timing(pulse, {
21
+ toValue: 1,
22
+ duration:1400,
23
+ easing: Easing.out(Easing.quad),
24
+ useNativeDriver: true,
25
+ }),
26
+ );
27
+ loop.start();
28
+ return () => loop.stop();
29
+ }, [pulse]);
30
+
31
+ const scale = pulse.interpolate({ inputRange: [0, 1], outputRange: [1, SIZE / DOT] });
32
+ const opacity = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.60, 0] });
33
+
34
+ return (
35
+ <Marker id={id} lngLat={lngLat} anchor="center">
36
+ <View style={{ width: SIZE, height: SIZE, alignItems: "center", justifyContent: "center" }}>
37
+ {/* expanding ring */}
38
+ <Animated.View
39
+ style={{
40
+ position: "absolute",
41
+ width: DOT,
42
+ height: DOT,
43
+ borderRadius: DOT / 2,
44
+ backgroundColor: color ?? colors.primary,
45
+ opacity,
46
+ transform: [{ scale }],
47
+ }}
48
+ />
49
+ {/* solid dot */}
50
+ <View
51
+ style={{
52
+ width: DOT,
53
+ height: DOT,
54
+ borderRadius: DOT / 2,
55
+ backgroundColor: color,
56
+ borderWidth: 3,
57
+ borderColor: colors.text.primary,
58
+ }}
59
+ />
60
+ </View>
61
+ </Marker>
62
+ );
63
+ }
package/src/index.ts CHANGED
@@ -85,4 +85,8 @@ export {default as TextArea} from "./components/ui/textArea";
85
85
  export {default as ConfirmDeleteScreen} from "./components/screens/confirmDeleteScreen";
86
86
  export {useConfirmDeleteForm} from "./hooks/useDeleteAccount";
87
87
  export {default as Skeleton} from "./components/ui/skeleton";
88
- export {default as RequestCardSkeleton} from "./components/ui/requestCardSkeleton";
88
+ export {default as RequestCardSkeleton} from "./components/ui/requestCardSkeleton";
89
+ export {default as AppMap} from "./components/ui/appMap";
90
+ export {default as CustomMarker} from "./components/ui/customMarker";
91
+ export {default as PositionMarker} from "./components/ui/positionMarker";
92
+ export {default as MovingMarker} from "./components/ui/movingMarker";