react-native-map4d-map-dtqg 0.1.5 → 0.1.6

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.
Files changed (32) hide show
  1. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  2. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  3. package/android/build.gradle +21 -0
  4. package/lib/commonjs/components/MFBanDoSo/constants.js +4 -1
  5. package/lib/commonjs/components/MFBanDoSo/constants.js.map +1 -1
  6. package/lib/commonjs/components/MFBanDoSo/styles.js +19 -13
  7. package/lib/commonjs/components/MFBanDoSo/styles.js.map +1 -1
  8. package/lib/commonjs/components/MFBanDoSo/ui.js +52 -41
  9. package/lib/commonjs/components/MFBanDoSo/ui.js.map +1 -1
  10. package/lib/commonjs/components/MFBanDoSo.js +11 -0
  11. package/lib/commonjs/components/MFBanDoSo.js.map +1 -1
  12. package/lib/module/components/MFBanDoSo/constants.js +4 -1
  13. package/lib/module/components/MFBanDoSo/constants.js.map +1 -1
  14. package/lib/module/components/MFBanDoSo/styles.js +20 -13
  15. package/lib/module/components/MFBanDoSo/styles.js.map +1 -1
  16. package/lib/module/components/MFBanDoSo/ui.js +52 -41
  17. package/lib/module/components/MFBanDoSo/ui.js.map +1 -1
  18. package/lib/module/components/MFBanDoSo.js +11 -0
  19. package/lib/module/components/MFBanDoSo.js.map +1 -1
  20. package/lib/typescript/components/MFBanDoSo/constants.d.ts +3 -0
  21. package/lib/typescript/components/MFBanDoSo/constants.d.ts.map +1 -1
  22. package/lib/typescript/components/MFBanDoSo/styles.d.ts +323 -449
  23. package/lib/typescript/components/MFBanDoSo/styles.d.ts.map +1 -1
  24. package/lib/typescript/components/MFBanDoSo/ui.d.ts +5 -3
  25. package/lib/typescript/components/MFBanDoSo/ui.d.ts.map +1 -1
  26. package/lib/typescript/components/MFBanDoSo.d.ts +1 -0
  27. package/lib/typescript/components/MFBanDoSo.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/components/MFBanDoSo/constants.js +6 -0
  30. package/src/components/MFBanDoSo/styles.js +20 -13
  31. package/src/components/MFBanDoSo/ui.js +72 -41
  32. package/src/components/MFBanDoSo.js +12 -0
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/MFBanDoSo/styles.js"],"names":[],"mappings":""}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/MFBanDoSo/styles.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiTG;2BAhUwB,cAAc"}
@@ -2,26 +2,28 @@ export function LayerButton({ show, isActive, onPress }: {
2
2
  show: any;
3
3
  isActive: any;
4
4
  onPress: any;
5
- }): React.JSX.Element | null;
5
+ }): React.JSX.Element;
6
6
  export function LegendButton({ show, isActive, onPress }: {
7
7
  show: any;
8
8
  isActive: any;
9
9
  onPress: any;
10
- }): React.JSX.Element | null;
10
+ }): React.JSX.Element;
11
11
  export function LegendPanel({ show, title, items, getItemColor }: {
12
12
  show: any;
13
13
  title: any;
14
14
  items: any;
15
15
  getItemColor: any;
16
16
  }): React.JSX.Element | null;
17
- export function SelectorDrawer({ show, title, groupSections, expandedGroupKeys, backdropAnimatedStyle, panelAnimatedStyle, onClose, onToggleGroup, onToggleGroupChecked, onToggleItem, }: {
17
+ export function SelectorDrawer({ show, title, groupSections, expandedGroupKeys, dragAnim, backdropAnimatedStyle, panelAnimatedStyle, onClose, onDragCancel, onToggleGroup, onToggleGroupChecked, onToggleItem, }: {
18
18
  show: any;
19
19
  title: any;
20
20
  groupSections: any;
21
21
  expandedGroupKeys: any;
22
+ dragAnim: any;
22
23
  backdropAnimatedStyle: any;
23
24
  panelAnimatedStyle: any;
24
25
  onClose: any;
26
+ onDragCancel: any;
25
27
  onToggleGroup: any;
26
28
  onToggleGroupChecked: any;
27
29
  onToggleItem: any;
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../src/components/MFBanDoSo/ui.js"],"names":[],"mappings":"AAUA;;;;6BAmBC;AAED;;;;6BA0BC;AA6HD;;;;;6BA6CC;AAxKD;;;;;;;;;;;6BAyHC;kBApLiB,OAAO"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../src/components/MFBanDoSo/ui.js"],"names":[],"mappings":"AAiBA;;;;sBAeC;AAED;;;;sBAsBC;AA6JD;;;;;6BA6CC;AAxMD;;;;;;;;;;;;;6BAyJC;kBAnN6B,OAAO"}
@@ -21,6 +21,7 @@ export class MFBanDoSo extends MFMapView {
21
21
  _toggleLegendVisibility(): void;
22
22
  _openSelector(): void;
23
23
  _closeSelector(): void;
24
+ _snapSelectorOpen(): void;
24
25
  componentDidMount(): void;
25
26
  componentDidUpdate(prevProps: any, prevState: any): void;
26
27
  componentWillUnmount(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"MFBanDoSo.d.ts","sourceRoot":"","sources":["../../../src/components/MFBanDoSo.js"],"names":[],"mappings":"AAwCA;IAGI,0BAAgC;IAChC,oBAAuB;IACvB,2BAA2B;IAC3B,8BAA0C;IAC1C;;;;;;;;;;MASC;IAmFH,oDAQC;IAeD,4DAQC;IArBD,kCAWC;IAYD,kCAOC;IAED,gCAIC;IAED,sBAYC;IAED,uBAgBC;IAtJD,0BAIC;IAED,yDAgBC;IAED,6BAEC;IAED,oCA0CC;IAkFD,0BAmBC;CAmEF;;;;;0BApRyB,aAAa;yBAzBhC,cAAc;iCAwBd,uBAAuB"}
1
+ {"version":3,"file":"MFBanDoSo.d.ts","sourceRoot":"","sources":["../../../src/components/MFBanDoSo.js"],"names":[],"mappings":"AAwCA;IAGI,0BAAgC;IAChC,oBAAuB;IACvB,2BAA2B;IAC3B,8BAA0C;IAC1C;;;;;;;;;;MASC;IAoFH,oDAQC;IAeD,4DAQC;IArBD,kCAWC;IAYD,kCAOC;IAED,gCAIC;IAED,sBAYC;IAED,uBAgBC;IAED,0BAOC;IA/JD,0BAIC;IAED,yDAgBC;IAED,6BAEC;IAED,oCA0CC;IA2FD,0BAmBC;CAqEF;;;;;0BAhSyB,aAAa;yBAzBhC,cAAc;iCAwBd,uBAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-map4d-map-dtqg",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Map4dMap SDK for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,6 +1,9 @@
1
1
  const SELECTOR_DRAWER_TRANSLATE_X = -320;
2
2
  const SELECTOR_OPEN_DURATION_MS = 240;
3
3
  const SELECTOR_CLOSE_DURATION_MS = 210;
4
+ const SELECTOR_SWIPE_ACTIVATION_DISTANCE = 10;
5
+ const SELECTOR_SWIPE_CLOSE_DISTANCE = 80;
6
+ const SELECTOR_SWIPE_CLOSE_VELOCITY = 0.5;
4
7
  const SELECTOR_TITLE = 'Chọn lớp dữ liệu trên bản đồ';
5
8
  const LEGEND_TITLE = 'Chú giải';
6
9
 
@@ -25,6 +28,9 @@ export {
25
28
  SELECTOR_DRAWER_TRANSLATE_X,
26
29
  SELECTOR_OPEN_DURATION_MS,
27
30
  SELECTOR_CLOSE_DURATION_MS,
31
+ SELECTOR_SWIPE_ACTIVATION_DISTANCE,
32
+ SELECTOR_SWIPE_CLOSE_DISTANCE,
33
+ SELECTOR_SWIPE_CLOSE_VELOCITY,
28
34
  SELECTOR_TITLE,
29
35
  LEGEND_TITLE,
30
36
  getSourceUrl,
@@ -1,10 +1,21 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
+ // Workaround for a React Native Fabric/Android Yoga bug: an absolutely-positioned
4
+ // view stretched via top+bottom (e.g. StyleSheet.absoluteFillObject) can have its
5
+ // top offset silently dropped, collapsing the view to zero height pinned at the
6
+ // parent's bottom edge. Anchoring with top + height: '100%' instead avoids that
7
+ // code path. Do not replace this with absoluteFillObject/bottom-based stretching.
8
+ const fullFill = {
9
+ position: 'absolute',
10
+ top: 0,
11
+ left: 0,
12
+ right: 0,
13
+ height: '100%',
14
+ };
15
+
3
16
  const styles = StyleSheet.create({
4
- layerButtonContainer: {
5
- ...StyleSheet.absoluteFillObject,
6
- zIndex: 20,
7
- elevation: 20,
17
+ hiddenButton: {
18
+ display: 'none',
8
19
  },
9
20
  layerButton: {
10
21
  position: 'absolute',
@@ -73,22 +84,20 @@ const styles = StyleSheet.create({
73
84
  backgroundColor: '#6b7280',
74
85
  },
75
86
  selectorContainer: {
76
- ...StyleSheet.absoluteFillObject,
77
- zIndex: 18,
78
- elevation: 18,
87
+ ...fullFill,
79
88
  },
80
89
  selectorBackdrop: {
81
- ...StyleSheet.absoluteFillObject,
90
+ ...fullFill,
82
91
  backgroundColor: '#11182740',
83
92
  },
84
93
  selectorBackdropPressable: {
85
- ...StyleSheet.absoluteFillObject,
94
+ ...fullFill,
86
95
  },
87
96
  selectorPanel: {
88
97
  position: 'absolute',
89
98
  top: 0,
90
99
  left: 0,
91
- bottom: 0,
100
+ height: '100%',
92
101
  width: '76%',
93
102
  maxWidth: 320,
94
103
  minWidth: 260,
@@ -243,9 +252,7 @@ const styles = StyleSheet.create({
243
252
  backgroundColor: '#2563eb',
244
253
  },
245
254
  legendContainer: {
246
- ...StyleSheet.absoluteFillObject,
247
- zIndex: 10,
248
- elevation: 10,
255
+ ...fullFill,
249
256
  },
250
257
  legendPanel: {
251
258
  position: 'absolute',
@@ -1,59 +1,58 @@
1
- import React from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import {
3
3
  Animated,
4
+ PanResponder,
4
5
  Pressable,
5
6
  ScrollView,
6
7
  Text,
7
8
  View,
8
9
  } from 'react-native';
10
+ import {
11
+ SELECTOR_DRAWER_TRANSLATE_X,
12
+ SELECTOR_SWIPE_ACTIVATION_DISTANCE,
13
+ SELECTOR_SWIPE_CLOSE_DISTANCE,
14
+ SELECTOR_SWIPE_CLOSE_VELOCITY,
15
+ } from './constants';
9
16
  import { styles } from './styles';
10
17
 
11
18
  function LayerButton({ show, isActive, onPress }) {
12
- if (!show) {
13
- return null;
14
- }
15
-
16
19
  return (
17
- <View style={styles.layerButtonContainer} pointerEvents="box-none">
18
- <Pressable
19
- style={[
20
- styles.layerButton,
21
- isActive && styles.layerButtonActive,
22
- ]}
23
- onPress={onPress}
24
- >
25
- <View style={styles.layerIconBoxPrimary} />
26
- <View style={styles.layerIconBoxSecondary} />
27
- </Pressable>
28
- </View>
20
+ <Pressable
21
+ style={[
22
+ styles.layerButton,
23
+ isActive && styles.layerButtonActive,
24
+ !show && styles.hiddenButton,
25
+ ]}
26
+ onPress={onPress}
27
+ pointerEvents={show ? 'auto' : 'none'}
28
+ >
29
+ <View style={styles.layerIconBoxPrimary} />
30
+ <View style={styles.layerIconBoxSecondary} />
31
+ </Pressable>
29
32
  );
30
33
  }
31
34
 
32
35
  function LegendButton({ show, isActive, onPress }) {
33
- if (!show) {
34
- return null;
35
- }
36
-
37
36
  return (
38
- <View style={styles.layerButtonContainer} pointerEvents="box-none">
39
- <Pressable
40
- style={[
41
- styles.layerButton,
42
- styles.legendButton,
43
- isActive && styles.layerButtonActive,
44
- ]}
45
- onPress={onPress}
46
- >
47
- <View style={styles.legendToggleIconRow}>
48
- <View style={styles.legendToggleIconDot} />
49
- <View style={styles.legendToggleIconLine} />
50
- </View>
51
- <View style={styles.legendToggleIconRow}>
52
- <View style={styles.legendToggleIconDot} />
53
- <View style={styles.legendToggleIconLine} />
54
- </View>
55
- </Pressable>
56
- </View>
37
+ <Pressable
38
+ style={[
39
+ styles.layerButton,
40
+ styles.legendButton,
41
+ isActive && styles.layerButtonActive,
42
+ !show && styles.hiddenButton,
43
+ ]}
44
+ onPress={onPress}
45
+ pointerEvents={show ? 'auto' : 'none'}
46
+ >
47
+ <View style={styles.legendToggleIconRow}>
48
+ <View style={styles.legendToggleIconDot} />
49
+ <View style={styles.legendToggleIconLine} />
50
+ </View>
51
+ <View style={styles.legendToggleIconRow}>
52
+ <View style={styles.legendToggleIconDot} />
53
+ <View style={styles.legendToggleIconLine} />
54
+ </View>
55
+ </Pressable>
57
56
  );
58
57
  }
59
58
 
@@ -62,13 +61,42 @@ function SelectorDrawer({
62
61
  title,
63
62
  groupSections,
64
63
  expandedGroupKeys,
64
+ dragAnim,
65
65
  backdropAnimatedStyle,
66
66
  panelAnimatedStyle,
67
67
  onClose,
68
+ onDragCancel,
68
69
  onToggleGroup,
69
70
  onToggleGroupChecked,
70
71
  onToggleItem,
71
72
  }) {
73
+ const panResponder = useRef(
74
+ PanResponder.create({
75
+ onMoveShouldSetPanResponder: (evt, gestureState) =>
76
+ Math.abs(gestureState.dx) > SELECTOR_SWIPE_ACTIVATION_DISTANCE &&
77
+ Math.abs(gestureState.dx) > Math.abs(gestureState.dy),
78
+ onPanResponderMove: (evt, gestureState) => {
79
+ const clampedDx = Math.min(0, gestureState.dx);
80
+ const nextValue = 1 + clampedDx / Math.abs(SELECTOR_DRAWER_TRANSLATE_X);
81
+ dragAnim.setValue(Math.max(0, Math.min(1, nextValue)));
82
+ },
83
+ onPanResponderRelease: (evt, gestureState) => {
84
+ const shouldClose =
85
+ gestureState.dx < -SELECTOR_SWIPE_CLOSE_DISTANCE ||
86
+ gestureState.vx < -SELECTOR_SWIPE_CLOSE_VELOCITY;
87
+
88
+ if (shouldClose) {
89
+ onClose();
90
+ } else {
91
+ onDragCancel();
92
+ }
93
+ },
94
+ onPanResponderTerminate: () => {
95
+ onDragCancel();
96
+ },
97
+ })
98
+ ).current;
99
+
72
100
  if (!show) {
73
101
  return null;
74
102
  }
@@ -81,7 +109,10 @@ function SelectorDrawer({
81
109
  onPress={onClose}
82
110
  />
83
111
  </Animated.View>
84
- <Animated.View style={[styles.selectorPanel, panelAnimatedStyle]}>
112
+ <Animated.View
113
+ style={[styles.selectorPanel, panelAnimatedStyle]}
114
+ {...panResponder.panHandlers}
115
+ >
85
116
  <View style={styles.selectorHeader}>
86
117
  <Text style={styles.selectorTitle}>{title}</Text>
87
118
  </View>
@@ -63,6 +63,7 @@ class MFBanDoSo extends MFMapView {
63
63
  this._toggleLegendVisibility = this._toggleLegendVisibility.bind(this);
64
64
  this._openSelector = this._openSelector.bind(this);
65
65
  this._closeSelector = this._closeSelector.bind(this);
66
+ this._snapSelectorOpen = this._snapSelectorOpen.bind(this);
66
67
  }
67
68
 
68
69
  componentDidMount() {
@@ -217,6 +218,15 @@ class MFBanDoSo extends MFMapView {
217
218
  });
218
219
  }
219
220
 
221
+ _snapSelectorOpen() {
222
+ Animated.timing(this._selectorAnim, {
223
+ toValue: 1,
224
+ duration: SELECTOR_OPEN_DURATION_MS,
225
+ easing: Easing.out(Easing.cubic),
226
+ useNativeDriver: true,
227
+ }).start();
228
+ }
229
+
220
230
  _syncGeojsonStyle() {
221
231
  if (!this.state.isReady) {
222
232
  return;
@@ -287,9 +297,11 @@ class MFBanDoSo extends MFMapView {
287
297
  title={selectorTitle}
288
298
  groupSections={groupSections}
289
299
  expandedGroupKeys={this.state.expandedGroupKeys}
300
+ dragAnim={this._selectorAnim}
290
301
  backdropAnimatedStyle={backdropAnimatedStyle}
291
302
  panelAnimatedStyle={panelAnimatedStyle}
292
303
  onClose={this._toggleSelectorVisibility}
304
+ onDragCancel={this._snapSelectorOpen}
293
305
  onToggleGroup={this._toggleGroup}
294
306
  onToggleGroupChecked={this._toggleGroupChecked}
295
307
  onToggleItem={this._toggleItem}