react-native-swipeable-actions 0.1.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/README.md +250 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/swipeable/SwipeConstants.kt +29 -0
- package/android/src/main/java/expo/modules/swipeable/SwipePhysics.kt +66 -0
- package/android/src/main/java/expo/modules/swipeable/SwipeableModule.kt +69 -0
- package/android/src/main/java/expo/modules/swipeable/SwipeableView.kt +951 -0
- package/build/Swipeable.d.ts +10 -0
- package/build/Swipeable.d.ts.map +1 -0
- package/build/Swipeable.js +114 -0
- package/build/Swipeable.js.map +1 -0
- package/build/Swipeable.types.d.ts +64 -0
- package/build/Swipeable.types.d.ts.map +1 -0
- package/build/Swipeable.types.js +3 -0
- package/build/Swipeable.types.js.map +1 -0
- package/build/SwipeableActions.d.ts +17 -0
- package/build/SwipeableActions.d.ts.map +1 -0
- package/build/SwipeableActions.js +31 -0
- package/build/SwipeableActions.js.map +1 -0
- package/build/SwipeableView.d.ts +10 -0
- package/build/SwipeableView.d.ts.map +1 -0
- package/build/SwipeableView.js +11 -0
- package/build/SwipeableView.js.map +1 -0
- package/build/constants.d.ts +11 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +14 -0
- package/build/constants.js.map +1 -0
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +21 -0
- package/build/index.js.map +1 -0
- package/build/nativeModuleUtils.d.ts +11 -0
- package/build/nativeModuleUtils.d.ts.map +1 -0
- package/build/nativeModuleUtils.js +49 -0
- package/build/nativeModuleUtils.js.map +1 -0
- package/build/swipeStateUtils.d.ts +16 -0
- package/build/swipeStateUtils.d.ts.map +1 -0
- package/build/swipeStateUtils.js +37 -0
- package/build/swipeStateUtils.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/Package.swift +28 -0
- package/ios/SwipeAnimationConfig.swift +27 -0
- package/ios/SwipePhysics.swift +66 -0
- package/ios/SwipeableModule.swift +84 -0
- package/ios/SwipeableView.swift +845 -0
- package/ios/react-native-swipeable-actions.podspec +22 -0
- package/package.json +85 -0
- package/src/Swipeable.tsx +195 -0
- package/src/Swipeable.types.ts +70 -0
- package/src/SwipeableActions.tsx +41 -0
- package/src/SwipeableView.tsx +20 -0
- package/src/constants.ts +11 -0
- package/src/index.ts +22 -0
- package/src/nativeModuleUtils.ts +57 -0
- package/src/swipeStateUtils.ts +55 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SwipeableProps, SwipeableMethods } from './Swipeable.types';
|
|
2
|
+
declare const Swipeable: import("react").ForwardRefExoticComponent<Omit<SwipeableProps, "ref"> & import("react").RefAttributes<SwipeableMethods>>;
|
|
3
|
+
type SwipeableWithStatic = typeof Swipeable & {
|
|
4
|
+
open: (recyclingKey: string) => void;
|
|
5
|
+
close: (recyclingKey: string, animated?: boolean) => void;
|
|
6
|
+
closeAll: (animated?: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const SwipeableExport: SwipeableWithStatic;
|
|
9
|
+
export default SwipeableExport;
|
|
10
|
+
//# sourceMappingURL=Swipeable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swipeable.d.ts","sourceRoot":"","sources":["../src/Swipeable.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,EACd,gBAAgB,EAIjB,MAAM,mBAAmB,CAAA;AAe1B,QAAA,MAAM,SAAS,0HA4Hb,CAAA;AAgBF,KAAK,mBAAmB,GAAG,OAAO,SAAS,GAAG;IAC5C,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACzD,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC,CAAA;AAED,QAAA,MAAM,eAAe,EAAgB,mBAAmB,CAAA;AAsBxD,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const SwipeableView_1 = require("./SwipeableView");
|
|
6
|
+
const SwipeableActions_1 = require("./SwipeableActions");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const nativeModuleUtils_1 = require("./nativeModuleUtils");
|
|
9
|
+
function normalizeRecyclingKey(key) {
|
|
10
|
+
if (key == null)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (typeof key === 'string')
|
|
13
|
+
return key;
|
|
14
|
+
if (typeof key === 'number' && Number.isFinite(key))
|
|
15
|
+
return String(key);
|
|
16
|
+
if (__DEV__) {
|
|
17
|
+
console.warn(`[Swipeable] Invalid recyclingKey: ${key}. Expected string or finite number.`);
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const Swipeable = (0, react_1.forwardRef)(function Swipeable({ children, actions, actionsWidth, actionsPosition = constants_1.SWIPE_DEFAULTS.ACTIONS_POSITION, friction = constants_1.SWIPE_DEFAULTS.FRICTION, threshold = constants_1.SWIPE_DEFAULTS.THRESHOLD, dragOffsetFromEdge = constants_1.SWIPE_DEFAULTS.DRAG_OFFSET_FROM_EDGE, style, testID, onSwipeStart, onSwipeStateChange, onSwipeEnd, onProgress, autoClose = false, autoCloseTimeout = 0, recyclingKey }, ref) {
|
|
22
|
+
const nativeRef = (0, react_1.useRef)(null);
|
|
23
|
+
const [hasActionsRendered, setHasActionsRendered] = (0, react_1.useState)(false);
|
|
24
|
+
const swipeStartedRef = (0, react_1.useRef)(false);
|
|
25
|
+
// Normalize and sync recyclingKey to ref for use in useImperativeHandle
|
|
26
|
+
// (set during render to ensure it's always current before callbacks fire)
|
|
27
|
+
const normalizedKey = normalizeRecyclingKey(recyclingKey);
|
|
28
|
+
const recyclingKeyRef = (0, react_1.useRef)(undefined);
|
|
29
|
+
recyclingKeyRef.current = normalizedKey;
|
|
30
|
+
// Development-time validation
|
|
31
|
+
if (__DEV__) {
|
|
32
|
+
if (autoClose && recyclingKey == null) {
|
|
33
|
+
console.warn('[Swipeable] autoClose is enabled but recyclingKey is not set. ' +
|
|
34
|
+
'This may cause issues in virtualized lists. Consider adding a recyclingKey prop.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
38
|
+
close: (animated) => {
|
|
39
|
+
const key = recyclingKeyRef.current;
|
|
40
|
+
if (key) {
|
|
41
|
+
(0, nativeModuleUtils_1.closeByKey)(key, animated);
|
|
42
|
+
}
|
|
43
|
+
else if (__DEV__) {
|
|
44
|
+
console.warn('[Swipeable] close() called without recyclingKey - method has no effect');
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
open: () => {
|
|
48
|
+
const key = recyclingKeyRef.current;
|
|
49
|
+
if (key) {
|
|
50
|
+
(0, nativeModuleUtils_1.openByKey)(key);
|
|
51
|
+
}
|
|
52
|
+
else if (__DEV__) {
|
|
53
|
+
console.warn('[Swipeable] open() called without recyclingKey - method has no effect');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}), []);
|
|
57
|
+
const handleSwipeStart = (0, react_1.useCallback)(() => {
|
|
58
|
+
if (!hasActionsRendered) {
|
|
59
|
+
setHasActionsRendered(true);
|
|
60
|
+
}
|
|
61
|
+
if (!swipeStartedRef.current) {
|
|
62
|
+
swipeStartedRef.current = true;
|
|
63
|
+
onSwipeStart?.();
|
|
64
|
+
}
|
|
65
|
+
}, [hasActionsRendered, onSwipeStart]);
|
|
66
|
+
const handleSwipeProgress = (0, react_1.useCallback)((event) => {
|
|
67
|
+
const newProgress = event.nativeEvent.progress;
|
|
68
|
+
const clamped = Math.max(0, Math.min(1, newProgress));
|
|
69
|
+
onProgress?.(clamped);
|
|
70
|
+
}, [onProgress]);
|
|
71
|
+
const handleSwipeStateChange = (0, react_1.useCallback)((event) => {
|
|
72
|
+
onSwipeStateChange?.(event.nativeEvent.state);
|
|
73
|
+
}, [onSwipeStateChange]);
|
|
74
|
+
const handleSwipeEnd = (0, react_1.useCallback)((event) => {
|
|
75
|
+
swipeStartedRef.current = false;
|
|
76
|
+
onSwipeEnd?.(event.nativeEvent.state);
|
|
77
|
+
}, [onSwipeEnd]);
|
|
78
|
+
return (<SwipeableView_1.SwipeableView ref={nativeRef} style={[styles.container, style]} actionsWidth={actionsWidth} actionsPosition={actionsPosition} friction={friction} threshold={threshold} dragOffsetFromEdge={dragOffsetFromEdge} autoClose={autoClose} autoCloseTimeout={autoCloseTimeout} {...(normalizedKey ? { recyclingKey: normalizedKey } : {})} {...(testID ? { testID } : {})} onSwipeStart={handleSwipeStart} onSwipeProgress={handleSwipeProgress} onSwipeStateChange={handleSwipeStateChange} onSwipeEnd={handleSwipeEnd}>
|
|
79
|
+
{hasActionsRendered && (<SwipeableActions_1.SwipeableActions actionsPosition={actionsPosition}>{actions}</SwipeableActions_1.SwipeableActions>)}
|
|
80
|
+
|
|
81
|
+
<react_native_1.View style={styles.content}>{children}</react_native_1.View>
|
|
82
|
+
</SwipeableView_1.SwipeableView>);
|
|
83
|
+
});
|
|
84
|
+
const styles = react_native_1.StyleSheet.create({
|
|
85
|
+
container: {
|
|
86
|
+
// iOS: overflow hidden works with native clipsToBounds
|
|
87
|
+
// Android: overflow visible required, native handles clipping
|
|
88
|
+
overflow: react_native_1.Platform.OS === 'ios' ? 'hidden' : 'visible'
|
|
89
|
+
},
|
|
90
|
+
content: {
|
|
91
|
+
width: '100%'
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
Swipeable.displayName = 'Swipeable';
|
|
95
|
+
const SwipeableExport = Swipeable;
|
|
96
|
+
SwipeableExport.open = (recyclingKey) => {
|
|
97
|
+
if (__DEV__ && (!recyclingKey || typeof recyclingKey !== 'string')) {
|
|
98
|
+
console.warn('[Swipeable.open] recyclingKey must be a non-empty string');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
(0, nativeModuleUtils_1.openByKey)(recyclingKey);
|
|
102
|
+
};
|
|
103
|
+
SwipeableExport.close = (recyclingKey, animated) => {
|
|
104
|
+
if (__DEV__ && (!recyclingKey || typeof recyclingKey !== 'string')) {
|
|
105
|
+
console.warn('[Swipeable.close] recyclingKey must be a non-empty string');
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
(0, nativeModuleUtils_1.closeByKey)(recyclingKey, animated);
|
|
109
|
+
};
|
|
110
|
+
SwipeableExport.closeAll = (animated) => {
|
|
111
|
+
(0, nativeModuleUtils_1.closeAll)(animated);
|
|
112
|
+
};
|
|
113
|
+
exports.default = SwipeableExport;
|
|
114
|
+
//# sourceMappingURL=Swipeable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swipeable.js","sourceRoot":"","sources":["../src/Swipeable.tsx"],"names":[],"mappings":";;AAAA,iCAAsF;AACtF,+CAAyD;AAEzD,mDAA+C;AAC/C,yDAAqD;AAQrD,2CAA4C;AAC5C,2DAAqE;AAErE,SAAS,qBAAqB,CAAC,GAAgC;IAC7D,IAAI,GAAG,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IACjC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IAEvE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,qCAAqC,GAAG,qCAAqC,CAAC,CAAA;IAC7F,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,kBAAU,EAA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 'react';
|
|
2
|
+
import { ViewProps, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export interface SwipeProgressEvent {
|
|
4
|
+
nativeEvent: {
|
|
5
|
+
progress: number;
|
|
6
|
+
translationX: number;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface SwipeStateEvent {
|
|
10
|
+
nativeEvent: {
|
|
11
|
+
state: 'open' | 'closed';
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface NativeSwipeableRef {
|
|
15
|
+
close: (animated?: boolean) => Promise<void>;
|
|
16
|
+
open: () => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface SwipeableViewProps extends ViewProps {
|
|
19
|
+
actionsWidth: number;
|
|
20
|
+
actionsPosition?: 'left' | 'right';
|
|
21
|
+
friction?: number;
|
|
22
|
+
threshold?: number;
|
|
23
|
+
dragOffsetFromEdge?: number;
|
|
24
|
+
recyclingKey?: string;
|
|
25
|
+
onSwipeProgress?: (event: SwipeProgressEvent) => void;
|
|
26
|
+
onSwipeStart?: () => void;
|
|
27
|
+
onSwipeStateChange?: (event: SwipeStateEvent) => void;
|
|
28
|
+
onSwipeEnd?: (event: SwipeStateEvent) => void;
|
|
29
|
+
autoClose?: boolean;
|
|
30
|
+
autoCloseTimeout?: number;
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
style?: StyleProp<ViewStyle>;
|
|
33
|
+
nativeRef?: Ref<NativeSwipeableRef>;
|
|
34
|
+
testID?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SwipeableProps {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
actions: ReactNode;
|
|
39
|
+
actionsWidth: number;
|
|
40
|
+
actionsPosition?: 'left' | 'right';
|
|
41
|
+
friction?: number;
|
|
42
|
+
threshold?: number;
|
|
43
|
+
dragOffsetFromEdge?: number;
|
|
44
|
+
style?: StyleProp<ViewStyle>;
|
|
45
|
+
testID?: string;
|
|
46
|
+
ref?: Ref<SwipeableMethods>;
|
|
47
|
+
onSwipeStart?: () => void;
|
|
48
|
+
onSwipeStateChange?: (state: 'open' | 'closed') => void;
|
|
49
|
+
onSwipeEnd?: (state: 'open' | 'closed') => void;
|
|
50
|
+
onProgress?: (progress: number) => void;
|
|
51
|
+
autoClose?: boolean;
|
|
52
|
+
autoCloseTimeout?: number;
|
|
53
|
+
recyclingKey?: string | number;
|
|
54
|
+
}
|
|
55
|
+
export interface SwipeableMethods {
|
|
56
|
+
close: (animated?: boolean) => void;
|
|
57
|
+
open: () => void;
|
|
58
|
+
}
|
|
59
|
+
export interface SwipeableStatic {
|
|
60
|
+
open: (recyclingKey: string) => void;
|
|
61
|
+
close: (recyclingKey: string, animated?: boolean) => void;
|
|
62
|
+
closeAll: (animated?: boolean) => void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=Swipeable.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swipeable.types.d.ts","sourceRoot":"","sources":["../src/Swipeable.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE9D,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,CAAA;QAChB,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;KACzB,CAAA;CACF;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5C,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1B;AAED,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD,YAAY,EAAE,MAAM,C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GAAG,QAAQ,KAAK,IAAI,CAAA;IACvD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,KAAK,IAAI,CAAA;IAC/C,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACnC,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACzD,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swipeable.types.js","sourceRoot":"","sources":["../src/Swipeable.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for SwipeableActions component
|
|
4
|
+
*/
|
|
5
|
+
export interface SwipeableActionsProps {
|
|
6
|
+
/** Action components to render */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Position of actions: 'left' or 'right' */
|
|
9
|
+
actionsPosition: 'left' | 'right';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* SwipeableActions - Internal layout component for swipeable actions
|
|
13
|
+
*
|
|
14
|
+
* Handles entrance animation when children mount.
|
|
15
|
+
*/
|
|
16
|
+
export declare function SwipeableActions({ children, actionsPosition }: SwipeableActionsProps): React.JSX.Element;
|
|
17
|
+
//# sourceMappingURL=SwipeableActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwipeableActions.d.ts","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGxC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAA;IACnB,6CAA6C;IAC7C,eAAe,EAAE,MAAM,GAAG,OAAO,CAAA;CAClC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,qBAAqB,qBASpF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SwipeableActions = SwipeableActions;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_native_1 = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* SwipeableActions - Internal layout component for swipeable actions
|
|
11
|
+
*
|
|
12
|
+
* Handles entrance animation when children mount.
|
|
13
|
+
*/
|
|
14
|
+
function SwipeableActions({ children, actionsPosition }) {
|
|
15
|
+
return (<react_native_1.View style={actionsPosition === 'left' ? styles.actionsLeading : styles.actionsTrailing} pointerEvents={children ? 'auto' : 'none'}>
|
|
16
|
+
{children}
|
|
17
|
+
</react_native_1.View>);
|
|
18
|
+
}
|
|
19
|
+
const styles = react_native_1.StyleSheet.create({
|
|
20
|
+
actionsTrailing: {
|
|
21
|
+
...react_native_1.StyleSheet.absoluteFillObject,
|
|
22
|
+
flexDirection: 'row',
|
|
23
|
+
justifyContent: 'flex-end'
|
|
24
|
+
},
|
|
25
|
+
actionsLeading: {
|
|
26
|
+
...react_native_1.StyleSheet.absoluteFillObject,
|
|
27
|
+
flexDirection: 'row',
|
|
28
|
+
justifyContent: 'flex-start'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=SwipeableActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwipeableActions.js","sourceRoot":"","sources":["../src/SwipeableActions.tsx"],"names":[],"mappings":";;;;;AAkBA,4CASC;AA3BD,kDAAwC;AACxC,+CAA+C;AAY/C;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAyB;IACnF,OAAO,CACL,CAAC,mBAAI,CACH,KAAK,CAAC,CAAC,eAAe,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CACnF,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAE1C;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,mBAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,eAAe,EAAE;QACf,GAAG,yBAAU,CAAC,kBAAkB;QAChC,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,UAAU;KAC3B;IACD,cAAc,EAAE;QACd,GAAG,yBAAU,CAAC,kBAAkB;QAChC,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,YAAY;KAC7B;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SwipeableViewProps, NativeSwipeableRef } from './Swipeable.types';
|
|
2
|
+
interface SwipeableNativeModule {
|
|
3
|
+
openByKey: (key: string) => void;
|
|
4
|
+
closeByKey: (key: string, animated?: boolean) => void;
|
|
5
|
+
closeAll: (animated?: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const SwipeableModule: SwipeableNativeModule;
|
|
8
|
+
export declare const SwipeableView: import("react").ForwardRefExoticComponent<SwipeableViewProps & import("react").RefAttributes<NativeSwipeableRef>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=SwipeableView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwipeableView.d.ts","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAK1E,UAAU,qBAAqB;IAC7B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACrD,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC;AAED,eAAO,MAAM,eAAe,uBAA0D,CAAA;AAEtF,eAAO,MAAM,aAAa,mHAIzB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwipeableView = exports.SwipeableModule = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const expo_modules_core_1 = require("expo-modules-core");
|
|
6
|
+
const NativeView = (0, expo_modules_core_1.requireNativeViewManager)('Swipeable');
|
|
7
|
+
exports.SwipeableModule = (0, expo_modules_core_1.requireNativeModule)('Swipeable');
|
|
8
|
+
exports.SwipeableView = (0, react_1.forwardRef)(function SwipeableView(props, ref) {
|
|
9
|
+
return (0, react_1.createElement)(NativeView, { ...props, ref });
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=SwipeableView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwipeableView.js","sourceRoot":"","sources":["../src/SwipeableView.tsx"],"names":[],"mappings":";;;AAAA,iCAAiE;AACjE,yDAAiF;AAGjF,MAAM,UAAU,GAAG,IAAA,4CAAwB,EAAqB,WAAW,CAAC,CAAA;AAS/D,QAAA,eAAe,GAAG,IAAA,uCAAmB,EAAwB,WAAW,CAAC,CAAA;AAEzE,QAAA,aAAa,GAAG,IAAA,kBAAU,EACrC,SAAS,aAAa,CAAC,KAAK,EAAE,GAAG;IAC/B,OAAO,IAAA,qBAAa,EAAC,UAAU,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAuC,CAAC,CAAA;AAC1F,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const SWIPE_PROGRESS: {
|
|
2
|
+
readonly OPEN_THRESHOLD: 0.99;
|
|
3
|
+
readonly CLOSED_THRESHOLD: 0.01;
|
|
4
|
+
};
|
|
5
|
+
export declare const SWIPE_DEFAULTS: {
|
|
6
|
+
readonly FRICTION: 1;
|
|
7
|
+
readonly THRESHOLD: 0.4;
|
|
8
|
+
readonly DRAG_OFFSET_FROM_EDGE: 0;
|
|
9
|
+
readonly ACTIONS_POSITION: "right";
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;CAGjB,CAAA;AAEV,eAAO,MAAM,cAAc;;;;;CAKjB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SWIPE_DEFAULTS = exports.SWIPE_PROGRESS = void 0;
|
|
4
|
+
exports.SWIPE_PROGRESS = {
|
|
5
|
+
OPEN_THRESHOLD: 0.99,
|
|
6
|
+
CLOSED_THRESHOLD: 0.01
|
|
7
|
+
};
|
|
8
|
+
exports.SWIPE_DEFAULTS = {
|
|
9
|
+
FRICTION: 1,
|
|
10
|
+
THRESHOLD: 0.4,
|
|
11
|
+
DRAG_OFFSET_FROM_EDGE: 0,
|
|
12
|
+
ACTIONS_POSITION: 'right'
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,cAAc,EAAE,IAAI;IACpB,gBAAgB,EAAE,IAAI;CACd,CAAA;AAEG,QAAA,cAAc,GAAG;IAC5B,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,GAAG;IACd,qBAAqB,EAAE,CAAC;IACxB,gBAAgB,EAAE,OAAO;CACjB,CAAA"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Swipeable } from './Swipeable';
|
|
2
|
+
export { SwipeableView } from './SwipeableView';
|
|
3
|
+
export type { SwipeableProps, SwipeableMethods, SwipeableStatic, SwipeableViewProps, SwipeProgressEvent, SwipeStateEvent, NativeSwipeableRef } from './Swipeable.types';
|
|
4
|
+
export { SWIPE_PROGRESS, SWIPE_DEFAULTS } from './constants';
|
|
5
|
+
export { isSwipeFullyOpen, isSwipeFullyClosed, calculateSwipeStateChange } from './swipeStateUtils';
|
|
6
|
+
export type { SwipeState, SwipeStateChange } from './swipeStateUtils';
|
|
7
|
+
export { setGlobalErrorHandler } from './nativeModuleUtils';
|
|
8
|
+
export type { SwipeableErrorHandler, NativeModuleError } from './nativeModuleUtils';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAEnG,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAGrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setGlobalErrorHandler = exports.calculateSwipeStateChange = exports.isSwipeFullyClosed = exports.isSwipeFullyOpen = exports.SWIPE_DEFAULTS = exports.SWIPE_PROGRESS = exports.SwipeableView = exports.Swipeable = void 0;
|
|
7
|
+
var Swipeable_1 = require("./Swipeable");
|
|
8
|
+
Object.defineProperty(exports, "Swipeable", { enumerable: true, get: function () { return __importDefault(Swipeable_1).default; } });
|
|
9
|
+
var SwipeableView_1 = require("./SwipeableView");
|
|
10
|
+
Object.defineProperty(exports, "SwipeableView", { enumerable: true, get: function () { return SwipeableView_1.SwipeableView; } });
|
|
11
|
+
var constants_1 = require("./constants");
|
|
12
|
+
Object.defineProperty(exports, "SWIPE_PROGRESS", { enumerable: true, get: function () { return constants_1.SWIPE_PROGRESS; } });
|
|
13
|
+
Object.defineProperty(exports, "SWIPE_DEFAULTS", { enumerable: true, get: function () { return constants_1.SWIPE_DEFAULTS; } });
|
|
14
|
+
var swipeStateUtils_1 = require("./swipeStateUtils");
|
|
15
|
+
Object.defineProperty(exports, "isSwipeFullyOpen", { enumerable: true, get: function () { return swipeStateUtils_1.isSwipeFullyOpen; } });
|
|
16
|
+
Object.defineProperty(exports, "isSwipeFullyClosed", { enumerable: true, get: function () { return swipeStateUtils_1.isSwipeFullyClosed; } });
|
|
17
|
+
Object.defineProperty(exports, "calculateSwipeStateChange", { enumerable: true, get: function () { return swipeStateUtils_1.calculateSwipeStateChange; } });
|
|
18
|
+
// Error handling utilities
|
|
19
|
+
var nativeModuleUtils_1 = require("./nativeModuleUtils");
|
|
20
|
+
Object.defineProperty(exports, "setGlobalErrorHandler", { enumerable: true, get: function () { return nativeModuleUtils_1.setGlobalErrorHandler; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAkD;AAAzC,uHAAA,OAAO,OAAa;AAC7B,iDAA+C;AAAtC,8GAAA,aAAa,OAAA;AAYtB,yCAA4D;AAAnD,2GAAA,cAAc,OAAA;AAAE,2GAAA,cAAc,OAAA;AAEvC,qDAAmG;AAA1F,mHAAA,gBAAgB,OAAA;AAAE,qHAAA,kBAAkB,OAAA;AAAE,4HAAA,yBAAyB,OAAA;AAIxE,2BAA2B;AAC3B,yDAA2D;AAAlD,0HAAA,qBAAqB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface NativeModuleError {
|
|
2
|
+
code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
nativeStackTrace?: string;
|
|
5
|
+
}
|
|
6
|
+
export type SwipeableErrorHandler = (error: NativeModuleError, operation: string, key?: string) => void;
|
|
7
|
+
export declare function setGlobalErrorHandler(handler: SwipeableErrorHandler | undefined): void;
|
|
8
|
+
export declare function openByKey(key: string): void;
|
|
9
|
+
export declare function closeByKey(key: string, animated?: boolean): void;
|
|
10
|
+
export declare function closeAll(animated?: boolean): void;
|
|
11
|
+
//# sourceMappingURL=nativeModuleUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeModuleUtils.d.ts","sourceRoot":"","sources":["../src/nativeModuleUtils.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,MAAM,MAAM,qBAAqB,GAAG,CAClC,KAAK,EAAE,iBAAiB,EACxB,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,KACT,IAAI,CAAA;AAIT,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS,GAAG,IAAI,CAEtF;AAgBD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAM3C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAMhE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAMjD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setGlobalErrorHandler = setGlobalErrorHandler;
|
|
4
|
+
exports.openByKey = openByKey;
|
|
5
|
+
exports.closeByKey = closeByKey;
|
|
6
|
+
exports.closeAll = closeAll;
|
|
7
|
+
const SwipeableView_1 = require("./SwipeableView");
|
|
8
|
+
let globalErrorHandler;
|
|
9
|
+
function setGlobalErrorHandler(handler) {
|
|
10
|
+
globalErrorHandler = handler;
|
|
11
|
+
}
|
|
12
|
+
function handleNativeError(error, operation, key) {
|
|
13
|
+
const nativeError = {
|
|
14
|
+
code: 'SWIPEABLE_NATIVE_ERROR',
|
|
15
|
+
message: error instanceof Error ? error.message : String(error),
|
|
16
|
+
...(error instanceof Error && error.stack ? { nativeStackTrace: error.stack } : {})
|
|
17
|
+
};
|
|
18
|
+
if (globalErrorHandler) {
|
|
19
|
+
globalErrorHandler(nativeError, operation, key);
|
|
20
|
+
}
|
|
21
|
+
else if (__DEV__) {
|
|
22
|
+
console.error(`[Swipeable] ${operation} failed:`, nativeError.message);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function openByKey(key) {
|
|
26
|
+
try {
|
|
27
|
+
SwipeableView_1.SwipeableModule.openByKey(key);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
handleNativeError(error, 'openByKey', key);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function closeByKey(key, animated) {
|
|
34
|
+
try {
|
|
35
|
+
SwipeableView_1.SwipeableModule.closeByKey(key, animated);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
handleNativeError(error, 'closeByKey', key);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function closeAll(animated) {
|
|
42
|
+
try {
|
|
43
|
+
SwipeableView_1.SwipeableModule.closeAll(animated);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
handleNativeError(error, 'closeAll');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=nativeModuleUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeModuleUtils.js","sourceRoot":"","sources":["../src/nativeModuleUtils.ts"],"names":[],"mappings":";;AAgBA,sDAEC;AAgBD,8BAMC;AAED,gCAMC;AAED,4BAMC;AAxDD,mDAAiD;AAcjD,IAAI,kBAAqD,CAAA;AAEzD,SAAgB,qBAAqB,CAAC,OAA0C;IAC9E,kBAAkB,GAAG,OAAO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pC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SwipeState {
|
|
2
|
+
wasOpen: boolean;
|
|
3
|
+
swipeStarted: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface SwipeStateChange {
|
|
6
|
+
nextState: SwipeState;
|
|
7
|
+
shouldEmitEnd: boolean;
|
|
8
|
+
/** Whether the open state changed (for onOpenChange callback) */
|
|
9
|
+
openStateChanged?: boolean;
|
|
10
|
+
/** The new open state (true = opened, false = closed) */
|
|
11
|
+
newOpenState?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function isSwipeFullyOpen(progress: number): boolean;
|
|
14
|
+
export declare function isSwipeFullyClosed(progress: number): boolean;
|
|
15
|
+
export declare function calculateSwipeStateChange(progress: number, currentState: SwipeState): SwipeStateChange;
|
|
16
|
+
//# sourceMappingURL=swipeStateUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeStateUtils.d.ts","sourceRoot":"","sources":["../src/swipeStateUtils.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,UAAU,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;IACtB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,yDAAyD;IACzD,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,UAAU,GACvB,gBAAgB,CA2BlB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSwipeFullyOpen = isSwipeFullyOpen;
|
|
4
|
+
exports.isSwipeFullyClosed = isSwipeFullyClosed;
|
|
5
|
+
exports.calculateSwipeStateChange = calculateSwipeStateChange;
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
function isSwipeFullyOpen(progress) {
|
|
8
|
+
return progress >= constants_1.SWIPE_PROGRESS.OPEN_THRESHOLD;
|
|
9
|
+
}
|
|
10
|
+
function isSwipeFullyClosed(progress) {
|
|
11
|
+
return progress <= constants_1.SWIPE_PROGRESS.CLOSED_THRESHOLD;
|
|
12
|
+
}
|
|
13
|
+
function calculateSwipeStateChange(progress, currentState) {
|
|
14
|
+
const isOpen = isSwipeFullyOpen(progress);
|
|
15
|
+
const isClosed = isSwipeFullyClosed(progress);
|
|
16
|
+
if (!currentState.swipeStarted) {
|
|
17
|
+
return { nextState: currentState, shouldEmitEnd: false };
|
|
18
|
+
}
|
|
19
|
+
if (isOpen && !currentState.wasOpen) {
|
|
20
|
+
return {
|
|
21
|
+
nextState: { wasOpen: true, swipeStarted: false },
|
|
22
|
+
shouldEmitEnd: true,
|
|
23
|
+
openStateChanged: true,
|
|
24
|
+
newOpenState: true
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (isClosed && currentState.wasOpen) {
|
|
28
|
+
return {
|
|
29
|
+
nextState: { wasOpen: false, swipeStarted: false },
|
|
30
|
+
shouldEmitEnd: true,
|
|
31
|
+
openStateChanged: true,
|
|
32
|
+
newOpenState: false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return { nextState: currentState, shouldEmitEnd: false };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=swipeStateUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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-version:5.4
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "SwipeableActions",
|
|
6
|
+
platforms: [.iOS(.v13), .macOS(.v10_15)],
|
|
7
|
+
products: [
|
|
8
|
+
.library(name: "SwipeableActions", targets: ["SwipeableActions"])
|
|
9
|
+
],
|
|
10
|
+
targets: [
|
|
11
|
+
.target(
|
|
12
|
+
name: "SwipeableActions",
|
|
13
|
+
path: ".",
|
|
14
|
+
exclude: [
|
|
15
|
+
"Tests",
|
|
16
|
+
"SwipeableView.swift",
|
|
17
|
+
"SwipeableModule.swift",
|
|
18
|
+
"react-native-swipeable-actions.podspec"
|
|
19
|
+
],
|
|
20
|
+
sources: ["SwipePhysics.swift", "SwipeAnimationConfig.swift"]
|
|
21
|
+
),
|
|
22
|
+
.testTarget(
|
|
23
|
+
name: "SwipeableActionsTests",
|
|
24
|
+
dependencies: ["SwipeableActions"],
|
|
25
|
+
path: "Tests"
|
|
26
|
+
)
|
|
27
|
+
]
|
|
28
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
#if canImport(CoreGraphics)
|
|
3
|
+
import CoreGraphics
|
|
4
|
+
#endif
|
|
5
|
+
|
|
6
|
+
/// Physics and animation constants for swipeable behavior.
|
|
7
|
+
///
|
|
8
|
+
/// Cross-platform constants (must match Android SwipeConstants.kt):
|
|
9
|
+
/// - rubberBandDivisor, velocityNormalizer, maxNormalizedVelocity
|
|
10
|
+
/// - velocityProjectionFactor, progressChangeThreshold, *Damping
|
|
11
|
+
///
|
|
12
|
+
/// Platform-specific: iOS uses duration-based animation, Android uses spring physics (stiffness).
|
|
13
|
+
/// Both produce similar visual results with critical damping (no oscillation).
|
|
14
|
+
enum SwipeAnimationConfig {
|
|
15
|
+
// iOS-specific: duration-based animation (Android uses spring stiffness)
|
|
16
|
+
static let openDuration: TimeInterval = 0.4
|
|
17
|
+
static let closeDuration: TimeInterval = 0.3
|
|
18
|
+
|
|
19
|
+
// Cross-platform constants - must match Android
|
|
20
|
+
static let openDamping: CGFloat = 1.0 // Critical damping - no oscillation (matches Android)
|
|
21
|
+
static let closeDamping: CGFloat = 1.0 // Critical damping - no oscillation (matches Android)
|
|
22
|
+
static let rubberBandDivisor: CGFloat = 3.0
|
|
23
|
+
static let velocityNormalizer: CGFloat = 500.0
|
|
24
|
+
static let maxNormalizedVelocity: CGFloat = 2.0
|
|
25
|
+
static let velocityProjectionFactor: CGFloat = 0.15
|
|
26
|
+
static let progressChangeThreshold: CGFloat = 0.001
|
|
27
|
+
}
|