@lodev09/react-native-true-sheet 0.7.0 → 0.8.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 +34 -18
- package/android/src/main/java/com/lodev09/truesheet/{core/TrueSheetBehavior.kt → TrueSheetBehavior.kt} +69 -39
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +84 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +82 -61
- package/android/src/main/java/com/lodev09/truesheet/core/Events.kt +1 -0
- package/android/src/main/java/com/lodev09/truesheet/core/KeyboardManager.kt +53 -0
- package/android/src/main/java/com/lodev09/truesheet/core/RootViewGroup.kt +1 -1
- package/android/src/main/java/com/lodev09/truesheet/core/Utils.kt +5 -37
- package/ios/Extensions/UIView+pinTo.swift +54 -10
- package/ios/TrueSheetView.swift +56 -22
- package/ios/TrueSheetViewController.swift +36 -0
- package/lib/commonjs/TrueSheet.js +4 -1
- package/lib/commonjs/TrueSheet.js.map +1 -1
- package/lib/commonjs/TrueSheetGrabber.js +56 -0
- package/lib/commonjs/TrueSheetGrabber.js.map +1 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/TrueSheet.js +4 -1
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheetGrabber.js +48 -0
- package/lib/module/TrueSheetGrabber.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts +31 -0
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrueSheet.tsx +2 -0
- package/src/TrueSheetGrabber.tsx +74 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, type ColorValue, type ViewProps, type ViewStyle } from 'react-native'
|
|
3
|
+
|
|
4
|
+
const GRABBER_WRAPPER_HEIGHT = 24
|
|
5
|
+
const GRABBER_DEFAULT_HEIGHT = 4
|
|
6
|
+
const GRABBER_DEFAULT_WIDTH = 32
|
|
7
|
+
const GRABBER_DEFAULT_COLOR = '#49454F'
|
|
8
|
+
|
|
9
|
+
interface TrueSheetGrabberProps extends ViewProps {
|
|
10
|
+
/**
|
|
11
|
+
* Is grabber visible
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
visible?: boolean
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Grabber color according to M3 specs
|
|
18
|
+
* @default #49454F
|
|
19
|
+
*/
|
|
20
|
+
color?: ColorValue
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Grabber height according to M3 specs
|
|
24
|
+
* @default 4
|
|
25
|
+
*/
|
|
26
|
+
height?: number
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Grabber width according to M3 specs
|
|
30
|
+
* @default 32
|
|
31
|
+
*/
|
|
32
|
+
width?: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Little Grabber component.
|
|
37
|
+
* Used by defualt for Android but feel free to re-use.
|
|
38
|
+
*/
|
|
39
|
+
export const TrueSheetGrabber = (props: TrueSheetGrabberProps) => {
|
|
40
|
+
const {
|
|
41
|
+
visible = true,
|
|
42
|
+
color = GRABBER_DEFAULT_COLOR,
|
|
43
|
+
width = GRABBER_DEFAULT_WIDTH,
|
|
44
|
+
height = GRABBER_DEFAULT_HEIGHT,
|
|
45
|
+
style,
|
|
46
|
+
...rest
|
|
47
|
+
} = props
|
|
48
|
+
|
|
49
|
+
if (!visible) return null
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View style={$wrapper}>
|
|
53
|
+
<View style={[$grabber, { height, width, backgroundColor: color }, style]} {...rest} />
|
|
54
|
+
</View>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const $wrapper: ViewStyle = {
|
|
59
|
+
position: 'absolute',
|
|
60
|
+
top: 0,
|
|
61
|
+
left: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
alignSelf: 'center',
|
|
64
|
+
height: GRABBER_WRAPPER_HEIGHT,
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
zIndex: 9999,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const $grabber: ViewStyle = {
|
|
70
|
+
// M3 spec for opacity
|
|
71
|
+
opacity: 0.4,
|
|
72
|
+
borderRadius: GRABBER_DEFAULT_HEIGHT / 2,
|
|
73
|
+
top: 6,
|
|
74
|
+
}
|
package/src/index.ts
CHANGED