@lodev09/react-native-true-sheet 3.0.0-beta.9 → 3.0.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/README.md +16 -6
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +29 -33
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +3 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +53 -43
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +390 -89
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +42 -4
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensFragmentObserver.kt +0 -5
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDialogObserver.kt +67 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +70 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetDragEvents.kt +71 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetFocusEvents.kt +65 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +94 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetStateEvents.kt +56 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +37 -33
- package/android/src/main/res/anim/true_sheet_slide_in.xml +13 -0
- package/android/src/main/res/anim/true_sheet_slide_out.xml +13 -0
- package/android/src/main/res/values/styles.xml +13 -1
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +5 -3
- package/ios/TrueSheetContainerView.mm +4 -0
- package/ios/TrueSheetContentView.h +2 -1
- package/ios/TrueSheetContentView.mm +91 -11
- package/ios/TrueSheetView.mm +94 -41
- package/ios/TrueSheetViewController.h +22 -10
- package/ios/TrueSheetViewController.mm +360 -173
- package/ios/core/TrueSheetBlurView.h +26 -0
- package/ios/{utils/ConversionUtil.mm → core/TrueSheetBlurView.mm} +64 -3
- package/ios/core/TrueSheetGrabberView.h +42 -0
- package/ios/core/TrueSheetGrabberView.mm +107 -0
- package/ios/events/TrueSheetDragEvents.h +39 -0
- package/ios/events/TrueSheetDragEvents.mm +62 -0
- package/ios/events/{OnPositionChangeEvent.h → TrueSheetFocusEvents.h} +8 -5
- package/ios/events/TrueSheetFocusEvents.mm +49 -0
- package/ios/events/TrueSheetLifecycleEvents.h +40 -0
- package/ios/events/TrueSheetLifecycleEvents.mm +71 -0
- package/ios/events/TrueSheetStateEvents.h +35 -0
- package/ios/events/TrueSheetStateEvents.mm +49 -0
- package/ios/utils/GestureUtil.h +7 -0
- package/ios/utils/GestureUtil.mm +12 -0
- package/lib/module/TrueSheet.js +72 -12
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +28 -5
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.js +13 -7
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +4 -2
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +4 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +105 -6
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +25 -5
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +8 -2
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/TrueSheet.tsx +87 -10
- package/src/TrueSheet.types.ts +114 -6
- package/src/__mocks__/index.js +0 -5
- package/src/fabric/TrueSheetViewNativeComponent.ts +28 -5
- package/src/index.ts +0 -1
- package/src/reanimated/ReanimatedTrueSheet.tsx +12 -7
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +11 -3
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +0 -32
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +0 -26
- package/ios/events/OnDetentChangeEvent.h +0 -28
- package/ios/events/OnDetentChangeEvent.mm +0 -30
- package/ios/events/OnDidDismissEvent.h +0 -26
- package/ios/events/OnDidDismissEvent.mm +0 -25
- package/ios/events/OnDidPresentEvent.h +0 -28
- package/ios/events/OnDidPresentEvent.mm +0 -30
- package/ios/events/OnDragBeginEvent.h +0 -28
- package/ios/events/OnDragBeginEvent.mm +0 -30
- package/ios/events/OnDragChangeEvent.h +0 -28
- package/ios/events/OnDragChangeEvent.mm +0 -30
- package/ios/events/OnDragEndEvent.h +0 -28
- package/ios/events/OnDragEndEvent.mm +0 -30
- package/ios/events/OnMountEvent.h +0 -26
- package/ios/events/OnMountEvent.mm +0 -25
- package/ios/events/OnPositionChangeEvent.mm +0 -32
- package/ios/events/OnWillDismissEvent.h +0 -26
- package/ios/events/OnWillDismissEvent.mm +0 -25
- package/ios/events/OnWillPresentEvent.h +0 -28
- package/ios/events/OnWillPresentEvent.mm +0 -30
- package/ios/utils/ConversionUtil.h +0 -24
- package/lib/module/TrueSheetGrabber.js +0 -51
- package/lib/module/TrueSheetGrabber.js.map +0 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +0 -1
- package/src/TrueSheetGrabber.tsx +0 -82
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import type { ViewProps } from 'react-native';
|
|
2
|
-
import type { DirectEventHandler, Double, Int32, WithDefault
|
|
2
|
+
import type { DirectEventHandler, Double, Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
type GrabberOptionsType = Readonly<{
|
|
4
|
+
width?: Double;
|
|
5
|
+
height?: Double;
|
|
6
|
+
topMargin?: Double;
|
|
7
|
+
cornerRadius?: WithDefault<Double, -1>;
|
|
8
|
+
color?: Int32;
|
|
9
|
+
}>;
|
|
10
|
+
type BlurOptionsType = Readonly<{
|
|
11
|
+
intensity?: WithDefault<Double, -1>;
|
|
12
|
+
interaction?: WithDefault<boolean, true>;
|
|
13
|
+
}>;
|
|
3
14
|
export interface DetentInfoEventPayload {
|
|
4
15
|
index: Int32;
|
|
5
16
|
position: Double;
|
|
17
|
+
detent: Double;
|
|
6
18
|
}
|
|
7
19
|
export interface PositionChangeEventPayload {
|
|
8
|
-
index:
|
|
20
|
+
index: Double;
|
|
9
21
|
position: Double;
|
|
10
|
-
|
|
22
|
+
detent: Double;
|
|
23
|
+
realtime: boolean;
|
|
11
24
|
}
|
|
12
25
|
export interface NativeProps extends ViewProps {
|
|
13
|
-
detents?: ReadonlyArray<
|
|
26
|
+
detents?: ReadonlyArray<Double>;
|
|
14
27
|
maxHeight?: WithDefault<Double, 0>;
|
|
15
28
|
background?: WithDefault<Int32, 0>;
|
|
16
29
|
cornerRadius?: WithDefault<Double, -1>;
|
|
@@ -18,12 +31,15 @@ export interface NativeProps extends ViewProps {
|
|
|
18
31
|
dimmedDetentIndex?: WithDefault<Int32, 0>;
|
|
19
32
|
blurTint?: WithDefault<string, ''>;
|
|
20
33
|
keyboardMode?: WithDefault<'resize' | 'pan', 'resize'>;
|
|
34
|
+
blurOptions?: BlurOptionsType;
|
|
21
35
|
grabber?: WithDefault<boolean, true>;
|
|
36
|
+
grabberOptions?: GrabberOptionsType;
|
|
22
37
|
dismissible?: WithDefault<boolean, true>;
|
|
38
|
+
draggable?: WithDefault<boolean, true>;
|
|
23
39
|
dimmed?: WithDefault<boolean, true>;
|
|
24
40
|
initialDetentAnimated?: WithDefault<boolean, true>;
|
|
25
41
|
edgeToEdgeFullScreen?: WithDefault<boolean, false>;
|
|
26
|
-
|
|
42
|
+
scrollable?: WithDefault<boolean, false>;
|
|
27
43
|
pageSizing?: WithDefault<boolean, true>;
|
|
28
44
|
onMount?: DirectEventHandler<null>;
|
|
29
45
|
onWillPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
@@ -35,6 +51,10 @@ export interface NativeProps extends ViewProps {
|
|
|
35
51
|
onDragChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
36
52
|
onDragEnd?: DirectEventHandler<DetentInfoEventPayload>;
|
|
37
53
|
onPositionChange?: DirectEventHandler<PositionChangeEventPayload>;
|
|
54
|
+
onWillFocus?: DirectEventHandler<null>;
|
|
55
|
+
onDidFocus?: DirectEventHandler<null>;
|
|
56
|
+
onWillBlur?: DirectEventHandler<null>;
|
|
57
|
+
onDidBlur?: DirectEventHandler<null>;
|
|
38
58
|
}
|
|
39
59
|
declare const _default: import("react-native").HostComponent<NativeProps>;
|
|
40
60
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrueSheetViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/TrueSheetViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"TrueSheetViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/TrueSheetViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,MAAM,EACN,KAAK,EACL,WAAW,EACZ,MAAM,2CAA2C,CAAC;AAGnD,KAAK,kBAAkB,GAAG,QAAQ,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC,CAAC;AAEH,KAAK,eAAe,GAAG,QAAQ,CAAC;IAC9B,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAY,SAAQ,SAAS;IAE5C,OAAO,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAGhC,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACvC,kBAAkB,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,iBAAiB,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAG1C,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,WAAW,CAAC,QAAQ,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC;IAGvD,WAAW,CAAC,EAAE,eAAe,CAAC;IAG9B,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpC,qBAAqB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnD,oBAAoB,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACzC,UAAU,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAGxC,OAAO,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACnC,aAAa,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC3D,YAAY,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC1D,aAAa,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACxC,cAAc,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC5D,WAAW,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IACvD,gBAAgB,CAAC,EAAE,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;IAClE,WAAW,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC;CACtC;;AAED,wBAEG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReanimatedTrueSheet.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/ReanimatedTrueSheet.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAgB9E,UAAU,wBAAyB,SAAQ,cAAc;IACvD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;CACvD;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ReanimatedTrueSheet.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/ReanimatedTrueSheet.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAgB9E,UAAU,wBAAyB,SAAQ,cAAc;IACvD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;CACvD;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,mBAAmB,gHA8B9B,CAAC"}
|
|
@@ -2,13 +2,19 @@ import { type ReactNode } from 'react';
|
|
|
2
2
|
import { type SharedValue } from 'react-native-reanimated';
|
|
3
3
|
export interface ReanimatedTrueSheetContextValue {
|
|
4
4
|
/**
|
|
5
|
-
* Shared value representing the current sheet position (Y offset from
|
|
5
|
+
* Shared value representing the current sheet position (Y offset from top of screen)
|
|
6
6
|
*/
|
|
7
7
|
animatedPosition: SharedValue<number>;
|
|
8
8
|
/**
|
|
9
|
-
* Shared value representing the current detent index
|
|
9
|
+
* Shared value representing the current detent index as a continuous float.
|
|
10
|
+
* Interpolates smoothly between -1 (off-screen) and the target detent index.
|
|
10
11
|
*/
|
|
11
12
|
animatedIndex: SharedValue<number>;
|
|
13
|
+
/**
|
|
14
|
+
* Shared value representing the current detent value (0-1 fraction of screen height).
|
|
15
|
+
* Interpolates smoothly between detent values as the sheet is dragged.
|
|
16
|
+
*/
|
|
17
|
+
animatedDetent: SharedValue<number>;
|
|
12
18
|
}
|
|
13
19
|
export interface ReanimatedTrueSheetProviderProps {
|
|
14
20
|
children: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReanimatedTrueSheetProvider.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/ReanimatedTrueSheetProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3E,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC
|
|
1
|
+
{"version":3,"file":"ReanimatedTrueSheetProvider.d.ts","sourceRoot":"","sources":["../../../../src/reanimated/ReanimatedTrueSheetProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3E,MAAM,WAAW,+BAA+B;IAC9C;;OAEG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC;;;OAGG;IACH,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACrC;AAID,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,GAAI,cAAc,gCAAgC,4CAoBzF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,sBAAsB,QAAO,+BAWzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "The true native bottom sheet experience for your React Native Apps.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"tidy": "yarn typecheck && yarn lint && yarn format && scripts/objclint.sh && scripts/ktlint.sh",
|
|
42
42
|
"clean": "scripts/clean.sh",
|
|
43
43
|
"prepare": "bob build",
|
|
44
|
-
"release": "
|
|
44
|
+
"release": "release-it",
|
|
45
45
|
"release:beta": "yarn release --preRelease=beta"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
@@ -152,6 +152,12 @@
|
|
|
152
152
|
"npm": {
|
|
153
153
|
"publish": true
|
|
154
154
|
},
|
|
155
|
+
"hooks": {
|
|
156
|
+
"before:init": [
|
|
157
|
+
"yarn tidy",
|
|
158
|
+
"yarn test"
|
|
159
|
+
]
|
|
160
|
+
},
|
|
155
161
|
"github": {
|
|
156
162
|
"release": true,
|
|
157
163
|
"comments": {
|
package/src/TrueSheet.tsx
CHANGED
|
@@ -20,6 +20,10 @@ import type {
|
|
|
20
20
|
DidDismissEvent,
|
|
21
21
|
WillDismissEvent,
|
|
22
22
|
MountEvent,
|
|
23
|
+
WillFocusEvent,
|
|
24
|
+
DidFocusEvent,
|
|
25
|
+
WillBlurEvent,
|
|
26
|
+
DidBlurEvent,
|
|
23
27
|
} from './TrueSheet.types';
|
|
24
28
|
import TrueSheetViewNativeComponent from './fabric/TrueSheetViewNativeComponent';
|
|
25
29
|
import TrueSheetContainerViewNativeComponent from './fabric/TrueSheetContainerViewNativeComponent';
|
|
@@ -29,7 +33,7 @@ import TrueSheetFooterViewNativeComponent from './fabric/TrueSheetFooterViewNati
|
|
|
29
33
|
|
|
30
34
|
import TrueSheetModule from './specs/NativeTrueSheetModule';
|
|
31
35
|
|
|
32
|
-
import { Platform, processColor, StyleSheet, findNodeHandle } from 'react-native';
|
|
36
|
+
import { Platform, processColor, StyleSheet, findNodeHandle, View } from 'react-native';
|
|
33
37
|
|
|
34
38
|
const LINKING_ERROR =
|
|
35
39
|
`The package '@lodev09/react-native-true-sheet' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -38,6 +42,9 @@ const LINKING_ERROR =
|
|
|
38
42
|
'- You are not using Expo Go\n' +
|
|
39
43
|
'- You are using the new architecture (Fabric)\n';
|
|
40
44
|
|
|
45
|
+
// Material Design 3 minimum touch target
|
|
46
|
+
const ANDROID_HITBOX_HEIGHT = 48;
|
|
47
|
+
|
|
41
48
|
if (!TrueSheetModule) {
|
|
42
49
|
throw new Error(LINKING_ERROR);
|
|
43
50
|
}
|
|
@@ -88,6 +95,10 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
88
95
|
this.onDragChange = this.onDragChange.bind(this);
|
|
89
96
|
this.onDragEnd = this.onDragEnd.bind(this);
|
|
90
97
|
this.onPositionChange = this.onPositionChange.bind(this);
|
|
98
|
+
this.onWillFocus = this.onWillFocus.bind(this);
|
|
99
|
+
this.onDidFocus = this.onDidFocus.bind(this);
|
|
100
|
+
this.onWillBlur = this.onWillBlur.bind(this);
|
|
101
|
+
this.onDidBlur = this.onDidBlur.bind(this);
|
|
91
102
|
}
|
|
92
103
|
|
|
93
104
|
private validateDetents(): void {
|
|
@@ -250,6 +261,22 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
250
261
|
this.props.onPositionChange?.(event);
|
|
251
262
|
}
|
|
252
263
|
|
|
264
|
+
private onWillFocus(event: WillFocusEvent): void {
|
|
265
|
+
this.props.onWillFocus?.(event);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private onDidFocus(event: DidFocusEvent): void {
|
|
269
|
+
this.props.onDidFocus?.(event);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
private onWillBlur(event: WillBlurEvent): void {
|
|
273
|
+
this.props.onWillBlur?.(event);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private onDidBlur(event: DidBlurEvent): void {
|
|
277
|
+
this.props.onDidBlur?.(event);
|
|
278
|
+
}
|
|
279
|
+
|
|
253
280
|
/**
|
|
254
281
|
* Present the Sheet by `index` (Promise-based)
|
|
255
282
|
* @param index - Detent index (default: 0)
|
|
@@ -313,23 +340,25 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
313
340
|
detents = [0.5, 1],
|
|
314
341
|
backgroundColor,
|
|
315
342
|
dismissible = true,
|
|
343
|
+
draggable = true,
|
|
316
344
|
grabber = true,
|
|
345
|
+
grabberOptions,
|
|
317
346
|
dimmed = true,
|
|
318
347
|
initialDetentIndex = -1,
|
|
319
348
|
initialDetentAnimated = true,
|
|
320
349
|
keyboardMode = 'resize',
|
|
321
350
|
dimmedDetentIndex,
|
|
322
351
|
blurTint,
|
|
352
|
+
blurOptions,
|
|
323
353
|
cornerRadius,
|
|
324
354
|
maxHeight,
|
|
325
355
|
edgeToEdgeFullScreen,
|
|
326
|
-
|
|
356
|
+
scrollable = false,
|
|
327
357
|
pageSizing = true,
|
|
328
358
|
children,
|
|
329
359
|
style,
|
|
330
360
|
header,
|
|
331
361
|
footer,
|
|
332
|
-
testID,
|
|
333
362
|
...rest
|
|
334
363
|
} = this.props;
|
|
335
364
|
|
|
@@ -344,6 +373,18 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
344
373
|
return Math.min(1, detent);
|
|
345
374
|
});
|
|
346
375
|
|
|
376
|
+
const containerStyle =
|
|
377
|
+
this.props.scrollable &&
|
|
378
|
+
Platform.select({
|
|
379
|
+
android: styles.scrollableAndroidContainer,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const contentStyle =
|
|
383
|
+
this.props.scrollable &&
|
|
384
|
+
Platform.select({
|
|
385
|
+
android: styles.scrollableAndroidContent,
|
|
386
|
+
});
|
|
387
|
+
|
|
347
388
|
return (
|
|
348
389
|
<TrueSheetViewNativeComponent
|
|
349
390
|
{...rest}
|
|
@@ -351,18 +392,24 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
351
392
|
style={styles.sheetView}
|
|
352
393
|
detents={resolvedDetents}
|
|
353
394
|
blurTint={blurTint}
|
|
395
|
+
blurOptions={blurOptions}
|
|
354
396
|
background={(processColor(backgroundColor) as number) ?? 0}
|
|
355
397
|
cornerRadius={cornerRadius}
|
|
356
398
|
grabber={grabber}
|
|
399
|
+
grabberOptions={{
|
|
400
|
+
...grabberOptions,
|
|
401
|
+
color: (processColor(grabberOptions?.color) as number) ?? 0,
|
|
402
|
+
}}
|
|
357
403
|
dimmed={dimmed}
|
|
358
404
|
dimmedDetentIndex={dimmedDetentIndex}
|
|
359
405
|
keyboardMode={keyboardMode}
|
|
360
406
|
initialDetentIndex={initialDetentIndex}
|
|
361
407
|
initialDetentAnimated={initialDetentAnimated}
|
|
362
408
|
dismissible={dismissible}
|
|
409
|
+
draggable={draggable}
|
|
363
410
|
maxHeight={maxHeight}
|
|
364
411
|
edgeToEdgeFullScreen={edgeToEdgeFullScreen}
|
|
365
|
-
|
|
412
|
+
scrollable={scrollable}
|
|
366
413
|
pageSizing={pageSizing}
|
|
367
414
|
onMount={this.onMount}
|
|
368
415
|
onWillPresent={this.onWillPresent}
|
|
@@ -374,22 +421,29 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
374
421
|
onDragChange={this.onDragChange}
|
|
375
422
|
onDragEnd={this.onDragEnd}
|
|
376
423
|
onPositionChange={this.onPositionChange}
|
|
424
|
+
onWillFocus={this.onWillFocus}
|
|
425
|
+
onDidFocus={this.onDidFocus}
|
|
426
|
+
onWillBlur={this.onWillBlur}
|
|
427
|
+
onDidBlur={this.onDidBlur}
|
|
377
428
|
>
|
|
378
429
|
{this.state.shouldRenderNativeView && (
|
|
379
|
-
<TrueSheetContainerViewNativeComponent
|
|
430
|
+
<TrueSheetContainerViewNativeComponent style={containerStyle}>
|
|
380
431
|
{header && (
|
|
381
|
-
<TrueSheetHeaderViewNativeComponent
|
|
432
|
+
<TrueSheetHeaderViewNativeComponent>
|
|
382
433
|
{isValidElement(header) ? header : createElement(header)}
|
|
383
434
|
</TrueSheetHeaderViewNativeComponent>
|
|
384
435
|
)}
|
|
385
|
-
<TrueSheetContentViewNativeComponent style={style
|
|
436
|
+
<TrueSheetContentViewNativeComponent style={[style, contentStyle]}>
|
|
386
437
|
{children}
|
|
387
438
|
</TrueSheetContentViewNativeComponent>
|
|
388
439
|
{footer && (
|
|
389
|
-
<TrueSheetFooterViewNativeComponent style={styles.footer}
|
|
440
|
+
<TrueSheetFooterViewNativeComponent style={styles.footer}>
|
|
390
441
|
{isValidElement(footer) ? footer : createElement(footer)}
|
|
391
442
|
</TrueSheetFooterViewNativeComponent>
|
|
392
443
|
)}
|
|
444
|
+
{Platform.OS === 'android' && grabber && draggable && (
|
|
445
|
+
<View collapsable={false} style={styles.grabberHitbox} />
|
|
446
|
+
)}
|
|
393
447
|
</TrueSheetContainerViewNativeComponent>
|
|
394
448
|
)}
|
|
395
449
|
</TrueSheetViewNativeComponent>
|
|
@@ -399,13 +453,36 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
399
453
|
|
|
400
454
|
const styles = StyleSheet.create({
|
|
401
455
|
sheetView: {
|
|
402
|
-
position: 'absolute',
|
|
403
|
-
width: '100%',
|
|
404
456
|
zIndex: -9999,
|
|
457
|
+
position: 'absolute',
|
|
458
|
+
top: 0,
|
|
459
|
+
left: 0,
|
|
460
|
+
right: 0,
|
|
461
|
+
|
|
462
|
+
// Android needs a fixed bottom to avoid jumping content
|
|
463
|
+
bottom: Platform.select({ android: 0 }),
|
|
464
|
+
},
|
|
465
|
+
scrollableAndroidContainer: {
|
|
466
|
+
position: 'absolute',
|
|
467
|
+
top: 0,
|
|
468
|
+
left: 0,
|
|
469
|
+
right: 0,
|
|
470
|
+
bottom: 0,
|
|
471
|
+
},
|
|
472
|
+
scrollableAndroidContent: {
|
|
473
|
+
flexGrow: 1,
|
|
474
|
+
flexBasis: 0,
|
|
405
475
|
},
|
|
406
476
|
footer: {
|
|
407
477
|
position: 'absolute',
|
|
408
478
|
left: 0,
|
|
409
479
|
right: 0,
|
|
410
480
|
},
|
|
481
|
+
grabberHitbox: {
|
|
482
|
+
position: 'absolute',
|
|
483
|
+
top: 0,
|
|
484
|
+
left: 0,
|
|
485
|
+
right: 0,
|
|
486
|
+
height: ANDROID_HITBOX_HEIGHT,
|
|
487
|
+
},
|
|
411
488
|
});
|
package/src/TrueSheet.types.ts
CHANGED
|
@@ -10,14 +10,18 @@ export interface DetentInfoEventPayload {
|
|
|
10
10
|
* The Y position of the sheet relative to the screen.
|
|
11
11
|
*/
|
|
12
12
|
position: number;
|
|
13
|
+
/**
|
|
14
|
+
* The detent value (0-1) for the current index.
|
|
15
|
+
*/
|
|
16
|
+
detent: number;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export interface PositionChangeEventPayload extends DetentInfoEventPayload {
|
|
16
20
|
/**
|
|
17
|
-
*
|
|
18
|
-
* When
|
|
21
|
+
* Indicates whether the position value is real-time (e.g., during drag or animation tracking).
|
|
22
|
+
* When false, the position should be animated in JS.
|
|
19
23
|
*/
|
|
20
|
-
|
|
24
|
+
realtime: boolean;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
export type MountEvent = NativeSyntheticEvent<null>;
|
|
@@ -30,6 +34,67 @@ export type DragBeginEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
|
30
34
|
export type DragChangeEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
31
35
|
export type DragEndEvent = NativeSyntheticEvent<DetentInfoEventPayload>;
|
|
32
36
|
export type PositionChangeEvent = NativeSyntheticEvent<PositionChangeEventPayload>;
|
|
37
|
+
export type DidFocusEvent = NativeSyntheticEvent<null>;
|
|
38
|
+
export type DidBlurEvent = NativeSyntheticEvent<null>;
|
|
39
|
+
export type WillFocusEvent = NativeSyntheticEvent<null>;
|
|
40
|
+
export type WillBlurEvent = NativeSyntheticEvent<null>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Options for customizing the grabber (drag handle) appearance.
|
|
44
|
+
*/
|
|
45
|
+
export interface GrabberOptions {
|
|
46
|
+
/**
|
|
47
|
+
* The width of the grabber pill.
|
|
48
|
+
*
|
|
49
|
+
* @default iOS: 36, Android: 32
|
|
50
|
+
*/
|
|
51
|
+
width?: number;
|
|
52
|
+
/**
|
|
53
|
+
* The height of the grabber pill.
|
|
54
|
+
*
|
|
55
|
+
* @default iOS: 5, Android: 4
|
|
56
|
+
*/
|
|
57
|
+
height?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The top margin of the grabber from the sheet edge.
|
|
60
|
+
*
|
|
61
|
+
* @default iOS: 5, Android: 16
|
|
62
|
+
*/
|
|
63
|
+
topMargin?: number;
|
|
64
|
+
/**
|
|
65
|
+
* The corner radius of the grabber pill.
|
|
66
|
+
*
|
|
67
|
+
* @default height / 2
|
|
68
|
+
*/
|
|
69
|
+
cornerRadius?: number;
|
|
70
|
+
/**
|
|
71
|
+
* The color of the grabber.
|
|
72
|
+
* Uses native vibrancy/material styling when not provided.
|
|
73
|
+
*/
|
|
74
|
+
color?: ColorValue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Options for customizing the blur effect.
|
|
79
|
+
* Only applies when `blurTint` is set.
|
|
80
|
+
*
|
|
81
|
+
* @platform ios
|
|
82
|
+
*/
|
|
83
|
+
export interface BlurOptions {
|
|
84
|
+
/**
|
|
85
|
+
* The intensity of the blur effect (0-100).
|
|
86
|
+
* Uses system default if not provided.
|
|
87
|
+
*/
|
|
88
|
+
intensity?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Enables or disables user interaction on the blur view.
|
|
91
|
+
* Disabling this can help with visual artifacts (flash) on iOS 18+
|
|
92
|
+
* when touching the sheet content with blur enabled.
|
|
93
|
+
*
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
interaction?: boolean;
|
|
97
|
+
}
|
|
33
98
|
|
|
34
99
|
/**
|
|
35
100
|
* Blur style mapped to native values in IOS.
|
|
@@ -152,6 +217,14 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
152
217
|
*/
|
|
153
218
|
dismissible?: boolean;
|
|
154
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Enables or disables dragging the sheet to resize it.
|
|
222
|
+
* When disabled, the sheet becomes static and can only be resized programmatically.
|
|
223
|
+
*
|
|
224
|
+
* @default true
|
|
225
|
+
*/
|
|
226
|
+
draggable?: boolean;
|
|
227
|
+
|
|
155
228
|
/**
|
|
156
229
|
* Main sheet background color.
|
|
157
230
|
* Uses system default when not provided.
|
|
@@ -177,6 +250,12 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
177
250
|
*/
|
|
178
251
|
grabber?: boolean;
|
|
179
252
|
|
|
253
|
+
/**
|
|
254
|
+
* Options for customizing the grabber appearance.
|
|
255
|
+
* Only applies when `grabber` is `true`.
|
|
256
|
+
*/
|
|
257
|
+
grabberOptions?: GrabberOptions;
|
|
258
|
+
|
|
180
259
|
/**
|
|
181
260
|
* Controls the sheet presentation style on iPad.
|
|
182
261
|
* When enabled (true), uses a large page sheet for better readability.
|
|
@@ -195,6 +274,14 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
195
274
|
*/
|
|
196
275
|
blurTint?: BlurTint;
|
|
197
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Options for customizing the blur effect.
|
|
279
|
+
* Only applies when `blurTint` is set.
|
|
280
|
+
*
|
|
281
|
+
* @platform ios
|
|
282
|
+
*/
|
|
283
|
+
blurOptions?: BlurOptions;
|
|
284
|
+
|
|
198
285
|
/**
|
|
199
286
|
* Overrides `large` or `100%` height.
|
|
200
287
|
* Also sets the maximum height for 'auto' detents.
|
|
@@ -222,14 +309,15 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
222
309
|
footer?: ComponentType<unknown> | ReactElement;
|
|
223
310
|
|
|
224
311
|
/**
|
|
225
|
-
*
|
|
312
|
+
* On iOS, automatically pins ScrollView or FlatList to fit within the sheet's available space.
|
|
226
313
|
* When enabled, the ScrollView's top edge will be pinned below any top sibling views,
|
|
227
314
|
* and its left, right, and bottom edges will be pinned to the container.
|
|
228
315
|
*
|
|
229
|
-
*
|
|
316
|
+
* On Android, it adds additional style to the content for scrollable to work.
|
|
317
|
+
*
|
|
230
318
|
* @default false
|
|
231
319
|
*/
|
|
232
|
-
|
|
320
|
+
scrollable?: boolean;
|
|
233
321
|
|
|
234
322
|
/**
|
|
235
323
|
* Determines how the software keyboard will impact the layout of the sheet.
|
|
@@ -297,4 +385,24 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
297
385
|
* Comes with the detent info.
|
|
298
386
|
*/
|
|
299
387
|
onPositionChange?: (event: PositionChangeEvent) => void;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Called when the sheet is about to regain focus because a sheet presented on top of it is being dismissed.
|
|
391
|
+
*/
|
|
392
|
+
onWillFocus?: (event: WillFocusEvent) => void;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Called when the sheet regains focus after a sheet presented on top of it is dismissed.
|
|
396
|
+
*/
|
|
397
|
+
onDidFocus?: (event: DidFocusEvent) => void;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Called when the sheet is about to lose focus because another sheet is being presented on top of it.
|
|
401
|
+
*/
|
|
402
|
+
onWillBlur?: (event: WillBlurEvent) => void;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Called when the sheet loses focus because another sheet is presented on top of it.
|
|
406
|
+
*/
|
|
407
|
+
onDidBlur?: (event: DidBlurEvent) => void;
|
|
300
408
|
}
|
package/src/__mocks__/index.js
CHANGED
|
@@ -47,11 +47,6 @@ export class ReanimatedTrueSheet extends TrueSheet {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// Mock TrueSheetGrabber
|
|
51
|
-
export const TrueSheetGrabber = ({ style, ...props }) => (
|
|
52
|
-
<View style={style} {...props} testID="true-sheet-grabber" />
|
|
53
|
-
);
|
|
54
|
-
|
|
55
50
|
// Mock ReanimatedTrueSheetProvider
|
|
56
51
|
export const ReanimatedTrueSheetProvider = ({ children }) => <>{children}</>;
|
|
57
52
|
|
|
@@ -4,24 +4,38 @@ import type {
|
|
|
4
4
|
Double,
|
|
5
5
|
Int32,
|
|
6
6
|
WithDefault,
|
|
7
|
-
Float,
|
|
8
7
|
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
9
8
|
import { codegenNativeComponent } from 'react-native';
|
|
10
9
|
|
|
10
|
+
type GrabberOptionsType = Readonly<{
|
|
11
|
+
width?: Double;
|
|
12
|
+
height?: Double;
|
|
13
|
+
topMargin?: Double;
|
|
14
|
+
cornerRadius?: WithDefault<Double, -1>;
|
|
15
|
+
color?: Int32;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
type BlurOptionsType = Readonly<{
|
|
19
|
+
intensity?: WithDefault<Double, -1>;
|
|
20
|
+
interaction?: WithDefault<boolean, true>;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
11
23
|
export interface DetentInfoEventPayload {
|
|
12
24
|
index: Int32;
|
|
13
25
|
position: Double;
|
|
26
|
+
detent: Double;
|
|
14
27
|
}
|
|
15
28
|
|
|
16
29
|
export interface PositionChangeEventPayload {
|
|
17
|
-
index:
|
|
30
|
+
index: Double;
|
|
18
31
|
position: Double;
|
|
19
|
-
|
|
32
|
+
detent: Double;
|
|
33
|
+
realtime: boolean;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
export interface NativeProps extends ViewProps {
|
|
23
37
|
// Array properties
|
|
24
|
-
detents?: ReadonlyArray<
|
|
38
|
+
detents?: ReadonlyArray<Double>;
|
|
25
39
|
|
|
26
40
|
// Number properties - use 0 as default to avoid nil insertion
|
|
27
41
|
maxHeight?: WithDefault<Double, 0>;
|
|
@@ -34,13 +48,18 @@ export interface NativeProps extends ViewProps {
|
|
|
34
48
|
blurTint?: WithDefault<string, ''>;
|
|
35
49
|
keyboardMode?: WithDefault<'resize' | 'pan', 'resize'>;
|
|
36
50
|
|
|
51
|
+
// Blur options
|
|
52
|
+
blurOptions?: BlurOptionsType;
|
|
53
|
+
|
|
37
54
|
// Boolean properties - match defaults from TrueSheet.types.ts
|
|
38
55
|
grabber?: WithDefault<boolean, true>;
|
|
56
|
+
grabberOptions?: GrabberOptionsType;
|
|
39
57
|
dismissible?: WithDefault<boolean, true>;
|
|
58
|
+
draggable?: WithDefault<boolean, true>;
|
|
40
59
|
dimmed?: WithDefault<boolean, true>;
|
|
41
60
|
initialDetentAnimated?: WithDefault<boolean, true>;
|
|
42
61
|
edgeToEdgeFullScreen?: WithDefault<boolean, false>;
|
|
43
|
-
|
|
62
|
+
scrollable?: WithDefault<boolean, false>;
|
|
44
63
|
pageSizing?: WithDefault<boolean, true>;
|
|
45
64
|
|
|
46
65
|
// Event handlers
|
|
@@ -54,6 +73,10 @@ export interface NativeProps extends ViewProps {
|
|
|
54
73
|
onDragChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
55
74
|
onDragEnd?: DirectEventHandler<DetentInfoEventPayload>;
|
|
56
75
|
onPositionChange?: DirectEventHandler<PositionChangeEventPayload>;
|
|
76
|
+
onWillFocus?: DirectEventHandler<null>;
|
|
77
|
+
onDidFocus?: DirectEventHandler<null>;
|
|
78
|
+
onWillBlur?: DirectEventHandler<null>;
|
|
79
|
+
onDidBlur?: DirectEventHandler<null>;
|
|
57
80
|
}
|
|
58
81
|
|
|
59
82
|
export default codegenNativeComponent<NativeProps>('TrueSheetView', {
|
package/src/index.ts
CHANGED
|
@@ -70,24 +70,29 @@ const AnimatedTrueSheet = Animated.createAnimatedComponent(TrueSheet);
|
|
|
70
70
|
export const ReanimatedTrueSheet = forwardRef<TrueSheet, ReanimatedTrueSheetProps>((props, ref) => {
|
|
71
71
|
const { onPositionChange, ...rest } = props;
|
|
72
72
|
|
|
73
|
-
const { animatedPosition, animatedIndex } = useReanimatedTrueSheet();
|
|
73
|
+
const { animatedPosition, animatedIndex, animatedDetent } = useReanimatedTrueSheet();
|
|
74
74
|
|
|
75
75
|
const positionChangeHandler = useReanimatedPositionChangeHandler((payload) => {
|
|
76
76
|
'worklet';
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if (payload.realtime) {
|
|
79
|
+
// Update directly when we have real-time values (during drag or animation tracking)
|
|
80
|
+
animatedPosition.value = payload.position;
|
|
81
|
+
animatedIndex.value = payload.index;
|
|
82
|
+
animatedDetent.value = payload.detent;
|
|
83
|
+
} else {
|
|
84
|
+
// Animate position, index, and detent when not real-time
|
|
81
85
|
if (Platform.OS === 'android') {
|
|
82
86
|
animatedPosition.value = withTiming(payload.position, TIMING_CONFIG);
|
|
87
|
+
animatedIndex.value = withTiming(payload.index, TIMING_CONFIG);
|
|
88
|
+
animatedDetent.value = withTiming(payload.detent, TIMING_CONFIG);
|
|
83
89
|
} else {
|
|
84
90
|
animatedPosition.value = withSpring(payload.position, SPRING_CONFIG);
|
|
91
|
+
animatedIndex.value = withSpring(payload.index, SPRING_CONFIG);
|
|
92
|
+
animatedDetent.value = withSpring(payload.detent, SPRING_CONFIG);
|
|
85
93
|
}
|
|
86
|
-
} else {
|
|
87
|
-
animatedPosition.value = payload.position;
|
|
88
94
|
}
|
|
89
95
|
|
|
90
|
-
animatedIndex.value = payload.index;
|
|
91
96
|
onPositionChange?.({ nativeEvent: payload } as PositionChangeEvent);
|
|
92
97
|
});
|
|
93
98
|
|