@lodev09/react-native-true-sheet 0.2.1 → 0.3.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/README.md +2 -5
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +2 -7
  4. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +233 -0
  5. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +42 -10
  6. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewModule.kt +63 -0
  7. package/android/src/main/java/com/lodev09/truesheet/core/Events.kt +43 -0
  8. package/android/src/main/java/com/lodev09/truesheet/core/RootViewGroup.kt +136 -0
  9. package/android/src/main/java/com/lodev09/truesheet/core/SheetBehavior.kt +198 -0
  10. package/android/src/main/java/com/lodev09/truesheet/utils/maxSize.kt +49 -0
  11. package/android/src/main/java/com/lodev09/truesheet/utils/toDIP.kt +5 -0
  12. package/android/src/main/java/com/lodev09/truesheet/utils/withPromise.kt +13 -0
  13. package/ios/Extensions/UIViewController+detentForSize.swift +22 -13
  14. package/ios/TrueSheetView.swift +3 -3
  15. package/ios/TrueSheetViewManager.m +1 -1
  16. package/lib/commonjs/TrueSheet.js +12 -5
  17. package/lib/commonjs/TrueSheet.js.map +1 -1
  18. package/lib/commonjs/TrueSheetModule.js +3 -1
  19. package/lib/commonjs/TrueSheetModule.js.map +1 -1
  20. package/lib/module/TrueSheet.js +12 -5
  21. package/lib/module/TrueSheet.js.map +1 -1
  22. package/lib/module/TrueSheetModule.js +3 -1
  23. package/lib/module/TrueSheetModule.js.map +1 -1
  24. package/lib/typescript/src/TrueSheet.d.ts +1 -1
  25. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  26. package/lib/typescript/src/TrueSheetModule.d.ts.map +1 -1
  27. package/lib/typescript/src/types.d.ts +4 -3
  28. package/lib/typescript/src/types.d.ts.map +1 -1
  29. package/package.json +5 -2
  30. package/src/TrueSheet.tsx +21 -10
  31. package/src/TrueSheetModule.ts +3 -2
  32. package/src/types.ts +4 -3
package/src/TrueSheet.tsx CHANGED
@@ -23,12 +23,12 @@ const ComponentName = 'TrueSheetView'
23
23
 
24
24
  interface TrueSheetNativeViewProps {
25
25
  scrollableHandle: number | null
26
+ style: StyleProp<ViewStyle>
27
+ sizes: TrueSheetProps['sizes']
28
+ children: ReactNode
26
29
  onDismiss: () => void
27
30
  onPresent: (event: NativeSyntheticEvent<{ index: number }>) => void
28
31
  onSizeChange: (event: NativeSyntheticEvent<SizeChangeEvent>) => void
29
- children: ReactNode
30
- style: StyleProp<ViewStyle>
31
- sizes: TrueSheetProps['sizes']
32
32
  }
33
33
 
34
34
  const TrueSheetNativeView = requireNativeComponent<TrueSheetNativeViewProps>(ComponentName)
@@ -71,7 +71,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
71
71
  return nodeHandle
72
72
  }
73
73
 
74
- private updateHandles() {
74
+ private updateState() {
75
75
  const scrollableHandle = this.props.scrollRef?.current
76
76
  ? findNodeHandle(this.props.scrollRef.current)
77
77
  : null
@@ -94,11 +94,17 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
94
94
  }
95
95
 
96
96
  componentDidMount(): void {
97
- this.updateHandles()
97
+ if (this.props.sizes && this.props.sizes.length > 3) {
98
+ console.warn(
99
+ 'TrueSheet only supports a maximum of 3 sizes; collapsed, half-expanded and expanded. Check your `sizes` prop.'
100
+ )
101
+ }
102
+
103
+ this.updateState()
98
104
  }
99
105
 
100
106
  componentDidUpdate(): void {
101
- this.updateHandles()
107
+ this.updateState()
102
108
  }
103
109
 
104
110
  /**
@@ -129,9 +135,14 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
129
135
  onDismiss={this.onDismiss}
130
136
  onSizeChange={this.onSizeChange}
131
137
  >
132
- <View style={{ backgroundColor: this.props.backgroundColor ?? 'white' }}>
133
- <View style={this.props.style}>{this.props.children}</View>
134
- <View>{!!FooterComponent && <FooterComponent />}</View>
138
+ <View
139
+ collapsable={false}
140
+ style={{ backgroundColor: this.props.backgroundColor ?? 'white' }}
141
+ >
142
+ <View collapsable={false} style={this.props.style}>
143
+ {this.props.children}
144
+ </View>
145
+ <View collapsable={false}>{!!FooterComponent && <FooterComponent />}</View>
135
146
  </View>
136
147
  </TrueSheetNativeView>
137
148
  )
@@ -140,5 +151,5 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
140
151
 
141
152
  const $nativeSheet: ViewStyle = {
142
153
  position: 'absolute',
143
- zIndex: -99,
154
+ zIndex: -9999,
144
155
  }
@@ -6,8 +6,9 @@ const LINKING_ERROR =
6
6
  '- You rebuilt the app after installing the package\n' +
7
7
  '- You are not using Expo Go\n'
8
8
 
9
- export const TrueSheetModule = NativeModules.TrueSheetViewManager
10
- ? NativeModules.TrueSheetViewManager
9
+ // NativeModules automatically resolves 'TrueSheetView' to 'TrueSheetViewModule'
10
+ export const TrueSheetModule = NativeModules.TrueSheetView
11
+ ? NativeModules.TrueSheetView
11
12
  : new Proxy(
12
13
  {},
13
14
  {
package/src/types.ts CHANGED
@@ -66,17 +66,18 @@ export interface TrueSheetProps extends ViewProps {
66
66
  backgroundColor?: ColorValue
67
67
 
68
68
  /**
69
- * The main scrollable ref that Sheet should handle.
69
+ * The main scrollable ref that Sheet should handle on IOS.
70
+ * @platform ios
70
71
  */
71
72
  scrollRef?: RefObject<Component<unknown>>
72
73
 
73
74
  /**
74
75
  * The sizes you want the Sheet to support.
75
- * IMPORTANT! Sort them in ascending order
76
+ * Maximum of 3 sizes only; collapsed, half-expanded, expanded.
76
77
  *
77
78
  * Example:
78
79
  * ```ts
79
- * size={['auto', 400, '80%', 'large']}
80
+ * size={['auto', '60%', 'large']}
80
81
  * ```
81
82
  *
82
83
  * @default ['medium', 'large']