@lodev09/react-native-true-sheet 3.5.7 → 3.6.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.
Files changed (32) hide show
  1. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +4 -0
  2. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +19 -4
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +7 -2
  4. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +8 -0
  5. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetKeyboardObserver.kt +5 -4
  6. package/android/src/main/java/com/lodev09/truesheet/utils/KeyboardUtils.kt +29 -0
  7. package/ios/TrueSheetView.mm +1 -1
  8. package/ios/TrueSheetViewController.h +1 -1
  9. package/ios/TrueSheetViewController.mm +67 -45
  10. package/ios/core/TrueSheetBlurView.h +1 -1
  11. package/ios/core/TrueSheetBlurView.mm +2 -39
  12. package/ios/utils/BlurUtil.h +23 -0
  13. package/ios/utils/BlurUtil.mm +53 -0
  14. package/lib/module/TrueSheet.js +6 -4
  15. package/lib/module/TrueSheet.js.map +1 -1
  16. package/lib/module/TrueSheet.web.js +28 -6
  17. package/lib/module/TrueSheet.web.js.map +1 -1
  18. package/lib/module/fabric/TrueSheetViewNativeComponent.ts +2 -1
  19. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  20. package/lib/typescript/src/TrueSheet.types.d.ts +21 -5
  21. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
  22. package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
  23. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +2 -1
  24. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
  25. package/lib/typescript/src/navigation/types.d.ts +1 -1
  26. package/lib/typescript/src/navigation/types.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/TrueSheet.tsx +6 -4
  29. package/src/TrueSheet.types.ts +30 -5
  30. package/src/TrueSheet.web.tsx +34 -5
  31. package/src/fabric/TrueSheetViewNativeComponent.ts +2 -1
  32. package/src/navigation/types.ts +1 -1
@@ -48,11 +48,30 @@ import type {
48
48
  } from './TrueSheet.types';
49
49
 
50
50
  const DEFAULT_CORNER_RADIUS = 16;
51
+ const DEFAULT_ELEVATION = 4;
51
52
 
52
53
  const DEFAULT_GRABBER_COLOR = 'rgba(0, 0, 0, 0.3)';
53
54
  const DEFAULT_GRABBER_WIDTH = 32;
54
55
  const DEFAULT_GRABBER_HEIGHT = 4;
55
56
 
57
+ /**
58
+ * Converts elevation to CSS box-shadow based on Material Design 3 elevation system.
59
+ * Uses a combination of ambient and key shadows for realistic depth.
60
+ */
61
+ const getElevationShadow = (elevation: number): string => {
62
+ if (elevation <= 0) return 'none';
63
+
64
+ const ambientY = elevation * 0.5;
65
+ const ambientBlur = elevation * 1.5;
66
+ const ambientOpacity = 0.08 + elevation * 0.01;
67
+
68
+ const keyY = elevation;
69
+ const keyBlur = elevation * 2;
70
+ const keyOpacity = 0.12 + elevation * 0.02;
71
+
72
+ return `0px ${ambientY}px ${ambientBlur}px rgba(0, 0, 0, ${ambientOpacity}), 0px ${keyY}px ${keyBlur}px rgba(0, 0, 0, ${keyOpacity})`;
73
+ };
74
+
56
75
  const renderSlot = (slot: TrueSheetProps['header'] | TrueSheetProps['footer']) => {
57
76
  if (!slot) return null;
58
77
  if (isValidElement(slot)) return slot;
@@ -72,11 +91,14 @@ export const TrueSheet = forwardRef<TrueSheetRef, TrueSheetProps>((props, ref) =
72
91
  initialDetentIndex = -1,
73
92
  backgroundColor = '#ffffff',
74
93
  cornerRadius = DEFAULT_CORNER_RADIUS,
94
+ elevation = DEFAULT_ELEVATION,
75
95
  grabber = true,
76
96
  grabberOptions,
77
97
  maxHeight,
78
98
  header,
99
+ headerStyle,
79
100
  footer,
101
+ footerStyle,
80
102
  onMount,
81
103
  onWillPresent,
82
104
  onDidPresent,
@@ -323,12 +345,15 @@ export const TrueSheet = forwardRef<TrueSheetRef, TrueSheetProps>((props, ref) =
323
345
  () =>
324
346
  footer
325
347
  ? (footerProps: BottomSheetFooterProps) => (
326
- <BottomSheetFooter style={styles.footer} {...footerProps}>
348
+ <BottomSheetFooter
349
+ style={StyleSheet.flatten([styles.footer, footerStyle])}
350
+ {...footerProps}
351
+ >
327
352
  {renderSlot(footer)}
328
353
  </BottomSheetFooter>
329
354
  )
330
355
  : undefined,
331
- [footer]
356
+ [footer, footerStyle]
332
357
  );
333
358
 
334
359
  // For scrollable, we render the child directly
@@ -412,7 +437,7 @@ export const TrueSheet = forwardRef<TrueSheetRef, TrueSheetProps>((props, ref) =
412
437
 
413
438
  const sheetContent = (
414
439
  <ContainerComponent>
415
- {renderSlot(header)}
440
+ {header && <View style={headerStyle}>{renderSlot(header)}</View>}
416
441
  {scrollable ? children : <View style={style}>{children}</View>}
417
442
  </ContainerComponent>
418
443
  );
@@ -420,7 +445,12 @@ export const TrueSheet = forwardRef<TrueSheetRef, TrueSheetProps>((props, ref) =
420
445
  const sharedProps = {
421
446
  style: [
422
447
  styles.root,
423
- { backgroundColor, borderTopLeftRadius: cornerRadius, borderTopRightRadius: cornerRadius },
448
+ {
449
+ backgroundColor,
450
+ borderTopLeftRadius: cornerRadius,
451
+ borderTopRightRadius: cornerRadius,
452
+ boxShadow: getElevationShadow(elevation),
453
+ },
424
454
  ],
425
455
  index: snapIndex,
426
456
  enablePanDownToClose: dismissible,
@@ -464,7 +494,6 @@ export const TrueSheet = forwardRef<TrueSheetRef, TrueSheetProps>((props, ref) =
464
494
  const styles = StyleSheet.create({
465
495
  root: {
466
496
  overflow: 'hidden',
467
- boxShadow: '0px -2px 16px 0px rgba(9, 10, 9, 0.08)',
468
497
  },
469
498
  handle: {
470
499
  position: 'absolute',
@@ -41,6 +41,7 @@ export interface NativeProps extends ViewProps {
41
41
  // Number properties - use 0 as default to avoid nil insertion
42
42
  maxHeight?: WithDefault<Double, 0>;
43
43
  cornerRadius?: WithDefault<Double, -1>;
44
+ elevation?: WithDefault<Double, -1>;
44
45
 
45
46
  // Color properties
46
47
  backgroundColor?: ColorValue;
@@ -48,7 +49,7 @@ export interface NativeProps extends ViewProps {
48
49
  dimmedDetentIndex?: WithDefault<Int32, 0>;
49
50
 
50
51
  // String properties - use empty string as default to avoid nil insertion
51
- blurTint?: WithDefault<string, ''>;
52
+ backgroundBlur?: WithDefault<string, ''>;
52
53
 
53
54
  insetAdjustment?: WithDefault<'automatic' | 'never', 'automatic'>;
54
55
 
@@ -133,7 +133,7 @@ export type TrueSheetNavigationOptions = Pick<
133
133
  | 'grabberOptions'
134
134
  | 'dimmed'
135
135
  | 'dimmedDetentIndex'
136
- | 'blurTint'
136
+ | 'backgroundBlur'
137
137
  | 'blurOptions'
138
138
  | 'maxHeight'
139
139
  | 'scrollable'