@lodev09/react-native-true-sheet 0.4.5 → 0.5.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 +141 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +57 -53
- package/android/src/main/java/com/lodev09/truesheet/core/Events.kt +8 -2
- package/android/src/main/java/com/lodev09/truesheet/core/{SheetBehavior.kt → TrueSheetBehavior.kt} +35 -29
- package/ios/Extensions/UIBlurEffect+withStyle.swift +62 -0
- package/ios/TrueSheetView.swift +50 -14
- package/ios/TrueSheetViewController.swift +58 -8
- package/ios/TrueSheetViewManager.m +3 -0
- package/lib/commonjs/TrueSheet.js +40 -12
- package/lib/commonjs/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.js +40 -12
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +1 -1
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +44 -14
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/TrueSheet.tsx +42 -20
- package/src/types.ts +70 -15
|
@@ -18,7 +18,7 @@ struct SizeInfo {
|
|
|
18
18
|
protocol TrueSheetViewControllerDelegate: AnyObject {
|
|
19
19
|
func viewControllerDidChangeWidth(_ width: CGFloat)
|
|
20
20
|
func viewControllerDidDismiss()
|
|
21
|
-
func viewControllerSheetDidChangeSize(_
|
|
21
|
+
func viewControllerSheetDidChangeSize(_ sizeInfo: SizeInfo)
|
|
22
22
|
func viewControllerWillAppear()
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -29,24 +29,65 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe
|
|
|
29
29
|
|
|
30
30
|
weak var delegate: TrueSheetViewControllerDelegate?
|
|
31
31
|
|
|
32
|
+
var blurView: UIVisualEffectView
|
|
33
|
+
var lastViewWidth: CGFloat = 0
|
|
34
|
+
var detentValues: [String: SizeInfo] = [:]
|
|
35
|
+
|
|
32
36
|
var sizes: [Any] = ["medium", "large"]
|
|
33
37
|
var maxHeight: CGFloat?
|
|
34
38
|
|
|
35
|
-
var
|
|
36
|
-
|
|
39
|
+
var cornerRadius: CGFloat? {
|
|
40
|
+
didSet {
|
|
41
|
+
if #available(iOS 15.0, *) {
|
|
42
|
+
sheet?.preferredCornerRadius = cornerRadius
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var grabber = true {
|
|
48
|
+
didSet {
|
|
49
|
+
if #available(iOS 15.0, *) {
|
|
50
|
+
sheet?.prefersGrabberVisible = grabber
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
37
54
|
|
|
38
55
|
@available(iOS 15.0, *)
|
|
39
56
|
var sheet: UISheetPresentationController? {
|
|
40
57
|
return sheetPresentationController
|
|
41
58
|
}
|
|
42
59
|
|
|
60
|
+
@available(iOS 15.0, *)
|
|
61
|
+
var selectedSizeInfo: SizeInfo? {
|
|
62
|
+
guard let rawValue = sheet?.selectedDetentIdentifier?.rawValue else {
|
|
63
|
+
return nil
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return detentValues[rawValue]
|
|
67
|
+
}
|
|
68
|
+
|
|
43
69
|
// MARK: - Setup
|
|
44
70
|
|
|
71
|
+
init() {
|
|
72
|
+
blurView = UIVisualEffectView()
|
|
73
|
+
|
|
74
|
+
super.init(nibName: nil, bundle: nil)
|
|
75
|
+
|
|
76
|
+
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
77
|
+
blurView.frame = view.bounds
|
|
78
|
+
view.insertSubview(blurView, at: 0)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@available(*, unavailable)
|
|
82
|
+
required init?(coder _: NSCoder) {
|
|
83
|
+
fatalError("init(coder:) has not been implemented")
|
|
84
|
+
}
|
|
85
|
+
|
|
45
86
|
@available(iOS 15.0, *)
|
|
46
87
|
func sheetPresentationControllerDidChangeSelectedDetentIdentifier(_ sheet: UISheetPresentationController) {
|
|
47
|
-
if let
|
|
48
|
-
let
|
|
49
|
-
delegate?.viewControllerSheetDidChangeSize(
|
|
88
|
+
if let rawValue = sheet.selectedDetentIdentifier?.rawValue,
|
|
89
|
+
let sizeInfo = detentValues[rawValue] {
|
|
90
|
+
delegate?.viewControllerSheetDidChangeSize(sizeInfo)
|
|
50
91
|
}
|
|
51
92
|
}
|
|
52
93
|
|
|
@@ -71,6 +112,15 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe
|
|
|
71
112
|
}
|
|
72
113
|
}
|
|
73
114
|
|
|
115
|
+
func setBlurStyle(_ style: String?) {
|
|
116
|
+
guard let style else {
|
|
117
|
+
blurView.effect = nil
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
blurView.effect = UIBlurEffect(with: style)
|
|
122
|
+
}
|
|
123
|
+
|
|
74
124
|
/// Prepares the view controller for sheet presentation
|
|
75
125
|
/// Do nothing on IOS 14 and below... sad
|
|
76
126
|
@available(iOS 15.0, *)
|
|
@@ -90,9 +140,9 @@ class TrueSheetViewController: UIViewController, UISheetPresentationControllerDe
|
|
|
90
140
|
}
|
|
91
141
|
|
|
92
142
|
sheet.detents = detents
|
|
93
|
-
sheet.prefersGrabberVisible = true
|
|
94
143
|
sheet.prefersEdgeAttachedInCompactHeight = true
|
|
95
|
-
|
|
144
|
+
sheet.prefersGrabberVisible = grabber
|
|
145
|
+
sheet.preferredCornerRadius = cornerRadius
|
|
96
146
|
|
|
97
147
|
sheet.delegate = self
|
|
98
148
|
|
|
@@ -31,5 +31,8 @@ RCT_EXPORT_VIEW_PROPERTY(onSizeChange, RCTDirectEventBlock)
|
|
|
31
31
|
RCT_EXPORT_VIEW_PROPERTY(scrollableHandle, NSNumber)
|
|
32
32
|
RCT_EXPORT_VIEW_PROPERTY(maxHeight, NSNumber)
|
|
33
33
|
RCT_EXPORT_VIEW_PROPERTY(sizes, NSArray)
|
|
34
|
+
RCT_EXPORT_VIEW_PROPERTY(blurStyle, NSString)
|
|
35
|
+
RCT_EXPORT_VIEW_PROPERTY(cornerRadius, NSNumber)
|
|
36
|
+
RCT_EXPORT_VIEW_PROPERTY(grabber, BOOL)
|
|
34
37
|
|
|
35
38
|
@end
|
|
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
|
|
|
9
9
|
var _TrueSheetModule = require("./TrueSheetModule");
|
|
10
10
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
11
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
13
|
const LINKING_ERROR = `The package '@lodev09/react-native-true-sheet' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
13
14
|
ios: "- You have run 'pod install'\n",
|
|
14
15
|
default: ''
|
|
@@ -46,8 +47,8 @@ class TrueSheet extends _react.PureComponent {
|
|
|
46
47
|
onSizeChange(event) {
|
|
47
48
|
this.props.onSizeChange?.(event.nativeEvent);
|
|
48
49
|
}
|
|
49
|
-
onPresent() {
|
|
50
|
-
this.props.onPresent?.();
|
|
50
|
+
onPresent(event) {
|
|
51
|
+
this.props.onPresent?.(event.nativeEvent);
|
|
51
52
|
}
|
|
52
53
|
onDismiss() {
|
|
53
54
|
this.props.onDismiss?.();
|
|
@@ -71,31 +72,57 @@ class TrueSheet extends _react.PureComponent {
|
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
|
-
*
|
|
75
|
+
* Dismisses the Sheet
|
|
75
76
|
*/
|
|
76
77
|
async dismiss() {
|
|
77
78
|
await _TrueSheetModule.TrueSheetModule.dismiss(this.handle);
|
|
78
79
|
}
|
|
79
80
|
render() {
|
|
80
|
-
const
|
|
81
|
+
const {
|
|
82
|
+
sizes,
|
|
83
|
+
backgroundColor,
|
|
84
|
+
blurStyle,
|
|
85
|
+
cornerRadius,
|
|
86
|
+
grabber,
|
|
87
|
+
maxHeight,
|
|
88
|
+
FooterComponent,
|
|
89
|
+
testID,
|
|
90
|
+
style,
|
|
91
|
+
children,
|
|
92
|
+
...rest
|
|
93
|
+
} = this.props;
|
|
81
94
|
return /*#__PURE__*/_react.default.createElement(TrueSheetNativeView, {
|
|
82
95
|
ref: this.ref,
|
|
83
96
|
style: $nativeSheet,
|
|
84
97
|
scrollableHandle: this.state.scrollableHandle,
|
|
85
|
-
sizes:
|
|
86
|
-
|
|
98
|
+
sizes: sizes ?? ['medium', 'large'],
|
|
99
|
+
blurStyle: blurStyle,
|
|
100
|
+
cornerRadius: cornerRadius,
|
|
101
|
+
grabber: grabber ?? true,
|
|
102
|
+
maxHeight: maxHeight,
|
|
87
103
|
onPresent: this.onPresent,
|
|
88
104
|
onDismiss: this.onDismiss,
|
|
89
|
-
onSizeChange: this.onSizeChange
|
|
90
|
-
|
|
105
|
+
onSizeChange: this.onSizeChange,
|
|
106
|
+
testID: testID
|
|
107
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
|
|
91
108
|
collapsable: false,
|
|
92
109
|
style: {
|
|
93
|
-
|
|
110
|
+
overflow: _reactNative.Platform.select({
|
|
111
|
+
ios: undefined,
|
|
112
|
+
android: 'hidden'
|
|
113
|
+
}),
|
|
114
|
+
borderTopLeftRadius: cornerRadius,
|
|
115
|
+
borderTopRightRadius: cornerRadius,
|
|
116
|
+
// Remove backgroundColor if `blurStyle` is set on iOS
|
|
117
|
+
backgroundColor: _reactNative.Platform.select({
|
|
118
|
+
ios: blurStyle ? undefined : backgroundColor ?? 'white',
|
|
119
|
+
android: backgroundColor ?? 'white'
|
|
120
|
+
})
|
|
94
121
|
}
|
|
95
|
-
}, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
122
|
+
}, rest), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
96
123
|
collapsable: false,
|
|
97
|
-
style:
|
|
98
|
-
},
|
|
124
|
+
style: style
|
|
125
|
+
}, children), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
99
126
|
collapsable: false
|
|
100
127
|
}, !!FooterComponent && /*#__PURE__*/_react.default.createElement(FooterComponent, null))));
|
|
101
128
|
}
|
|
@@ -103,6 +130,7 @@ class TrueSheet extends _react.PureComponent {
|
|
|
103
130
|
exports.TrueSheet = TrueSheet;
|
|
104
131
|
const $nativeSheet = {
|
|
105
132
|
position: 'absolute',
|
|
133
|
+
width: 0,
|
|
106
134
|
zIndex: -9999
|
|
107
135
|
};
|
|
108
136
|
//# sourceMappingURL=TrueSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_TrueSheetModule","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","LINKING_ERROR","Platform","select","ios","ComponentName","TrueSheetNativeView","requireNativeComponent","Error","TrueSheet","PureComponent","displayName","constructor","props","ref","createRef","onDismiss","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_TrueSheetModule","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","LINKING_ERROR","Platform","select","ios","ComponentName","TrueSheetNativeView","requireNativeComponent","Error","TrueSheet","PureComponent","displayName","constructor","props","ref","createRef","onDismiss","onPresent","onSizeChange","state","scrollableHandle","handle","nodeHandle","findNodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","componentDidMount","sizes","console","warn","componentDidUpdate","present","index","TrueSheetModule","dismiss","render","backgroundColor","blurStyle","cornerRadius","grabber","maxHeight","FooterComponent","testID","style","children","rest","createElement","$nativeSheet","View","collapsable","overflow","undefined","android","borderTopLeftRadius","borderTopRightRadius","exports","position","width","zIndex"],"sourceRoot":"../../src","sources":["TrueSheet.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAWA,IAAAE,gBAAA,GAAAF,OAAA;AAAmD,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,W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heet.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1
2
|
import React, { PureComponent, createRef } from 'react';
|
|
2
3
|
import { requireNativeComponent, Platform, findNodeHandle, View } from 'react-native';
|
|
3
4
|
import { TrueSheetModule } from './TrueSheetModule';
|
|
@@ -38,8 +39,8 @@ export class TrueSheet extends PureComponent {
|
|
|
38
39
|
onSizeChange(event) {
|
|
39
40
|
this.props.onSizeChange?.(event.nativeEvent);
|
|
40
41
|
}
|
|
41
|
-
onPresent() {
|
|
42
|
-
this.props.onPresent?.();
|
|
42
|
+
onPresent(event) {
|
|
43
|
+
this.props.onPresent?.(event.nativeEvent);
|
|
43
44
|
}
|
|
44
45
|
onDismiss() {
|
|
45
46
|
this.props.onDismiss?.();
|
|
@@ -63,37 +64,64 @@ export class TrueSheet extends PureComponent {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
+
* Dismisses the Sheet
|
|
67
68
|
*/
|
|
68
69
|
async dismiss() {
|
|
69
70
|
await TrueSheetModule.dismiss(this.handle);
|
|
70
71
|
}
|
|
71
72
|
render() {
|
|
72
|
-
const
|
|
73
|
+
const {
|
|
74
|
+
sizes,
|
|
75
|
+
backgroundColor,
|
|
76
|
+
blurStyle,
|
|
77
|
+
cornerRadius,
|
|
78
|
+
grabber,
|
|
79
|
+
maxHeight,
|
|
80
|
+
FooterComponent,
|
|
81
|
+
testID,
|
|
82
|
+
style,
|
|
83
|
+
children,
|
|
84
|
+
...rest
|
|
85
|
+
} = this.props;
|
|
73
86
|
return /*#__PURE__*/React.createElement(TrueSheetNativeView, {
|
|
74
87
|
ref: this.ref,
|
|
75
88
|
style: $nativeSheet,
|
|
76
89
|
scrollableHandle: this.state.scrollableHandle,
|
|
77
|
-
sizes:
|
|
78
|
-
|
|
90
|
+
sizes: sizes ?? ['medium', 'large'],
|
|
91
|
+
blurStyle: blurStyle,
|
|
92
|
+
cornerRadius: cornerRadius,
|
|
93
|
+
grabber: grabber ?? true,
|
|
94
|
+
maxHeight: maxHeight,
|
|
79
95
|
onPresent: this.onPresent,
|
|
80
96
|
onDismiss: this.onDismiss,
|
|
81
|
-
onSizeChange: this.onSizeChange
|
|
82
|
-
|
|
97
|
+
onSizeChange: this.onSizeChange,
|
|
98
|
+
testID: testID
|
|
99
|
+
}, /*#__PURE__*/React.createElement(View, _extends({
|
|
83
100
|
collapsable: false,
|
|
84
101
|
style: {
|
|
85
|
-
|
|
102
|
+
overflow: Platform.select({
|
|
103
|
+
ios: undefined,
|
|
104
|
+
android: 'hidden'
|
|
105
|
+
}),
|
|
106
|
+
borderTopLeftRadius: cornerRadius,
|
|
107
|
+
borderTopRightRadius: cornerRadius,
|
|
108
|
+
// Remove backgroundColor if `blurStyle` is set on iOS
|
|
109
|
+
backgroundColor: Platform.select({
|
|
110
|
+
ios: blurStyle ? undefined : backgroundColor ?? 'white',
|
|
111
|
+
android: backgroundColor ?? 'white'
|
|
112
|
+
})
|
|
86
113
|
}
|
|
87
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
114
|
+
}, rest), /*#__PURE__*/React.createElement(View, {
|
|
88
115
|
collapsable: false,
|
|
89
|
-
style:
|
|
90
|
-
},
|
|
116
|
+
style: style
|
|
117
|
+
}, children), /*#__PURE__*/React.createElement(View, {
|
|
91
118
|
collapsable: false
|
|
92
119
|
}, !!FooterComponent && /*#__PURE__*/React.createElement(FooterComponent, null))));
|
|
93
120
|
}
|
|
94
121
|
}
|
|
95
122
|
const $nativeSheet = {
|
|
96
123
|
position: 'absolute',
|
|
124
|
+
width: 0,
|
|
97
125
|
zIndex: -9999
|
|
98
126
|
};
|
|
99
127
|
//# sourceMappingURL=TrueSheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","PureComponent","createRef","requireNativeComponent","Platform","findNodeHandle","View","TrueSheetModule","LINKING_ERROR","select","ios","default","ComponentName","TrueSheetNativeView","Error","TrueSheet","displayName","constructor","props","ref","onDismiss","bind","onPresent","onSizeChange","state","scrollableHandle","handle","nodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","componentDidMount","sizes","length","console","warn","componentDidUpdate","present","index","dismiss","render","FooterComponent","
|
|
1
|
+
{"version":3,"names":["React","PureComponent","createRef","requireNativeComponent","Platform","findNodeHandle","View","TrueSheetModule","LINKING_ERROR","select","ios","default","ComponentName","TrueSheetNativeView","Error","TrueSheet","displayName","constructor","props","ref","onDismiss","bind","onPresent","onSizeChange","state","scrollableHandle","handle","nodeHandle","current","updateState","scrollRef","setState","event","nativeEvent","componentDidMount","sizes","length","console","warn","componentDidUpdate","present","index","dismiss","render","backgroundColor","blurStyle","cornerRadius","grabber","maxHeight","FooterComponent","testID","style","children","rest","createElement","$nativeSheet","_extends","collapsable","overflow","undefined","android","borderTopLeftRadius","borderTopRightRadius","position","width","zIndex"],"sourceRoot":"../../src","sources":["TrueSheet.tsx"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,aAAa,EAA6BC,SAAS,QAAwB,OAAO;AAClG,SACEC,sBAAsB,EACtBC,QAAQ,EACRC,cAAc,EACdC,IAAI,QAIC,cAAc;AAGrB,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,MAAMC,aAAa,GAChB,2FAA0F,GAC3FJ,QAAQ,CAACK,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,aAAa,GAAG,eAAe;AAQrC,MAAMC,mBAAmB,GAAGV,sBAAsB,CAA2BS,aAAa,CAAC;AAE3F,IAAI,CAACC,mBAAmB,EAAE;EACxB,MAAM,IAAIC,KAAK,CAACN,aAAa,CAAC;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AACA,SAAU;MAC1BF,SAAS,EAAE,IAAI,CAACA,SAAU;MAC1BG,YAAY,EAAE,IAAI,CAACA,YAAa;MAChC2B,MAAM,EAAEA;IAAO,gBAEflD,KAAA,CAAAsD,aAAA,CAAChD,IAAI,EAAAkD,QAAA;MACHC,WAAW,EAAE,KAAM;MACnBN,KAAK,EAAE;QACLO,QAAQ,EAAEtD,QAAQ,CAACK,MAAM,CAAC;UAAEC,GAAG,EAAEiD,SAAS;UAAEC,OAAO,EAAE;QAAS,CAAC,CAAC;QAChEC,mBAAmB,EAAEf,YAAY;QACjCgB,oBAAoB,EAAEhB,YAAY;QAElC;QACAF,eAAe,EAAExC,QAAQ,CAACK,MAAM,CAAC;UAC/BC,GAAG,EAAEmC,SAAS,GAAGc,SAAS,GAAGf,eAAe,IAAI,OAAO;UACvDgB,OAAO,EAAEhB,eAAe,IAAI;QAC9B,CAAC;MACH;IAAE,GACES,IAAI,gBAERrD,KAAA,CAAAsD,aAAA,CAAChD,IAAI;MAACmD,WAAW,EAAE,KAAM;MAACN,KAAK,EAAEA;IAAM,GACpCC,QACG,CAAC,eACPpD,KAAA,CAAAsD,aAAA,CAAChD,IAAI;MAACmD,WAAW,EAAE;IAAM,GAAE,CAAC,CAACR,eAAe,iBAAIjD,KAAA,CAAAsD,aAAA,CAACL,eAAe,MAAE,CAAQ,CACtE,CACa,CAAC;EAE1B;AACF;AAEA,MAAMM,YAAuB,GAAG;EAC9BQ,QAAQ,EAAE,UAAU;EACpBC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;AACX,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrueSheet.d.ts","sourceRoot":"","sources":["../../../src/TrueSheet.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAwC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"TrueSheet.d.ts","sourceRoot":"","sources":["../../../src/TrueSheet.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAwC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAWlG,OAAO,KAAK,EAAE,cAAc,EAAY,MAAM,SAAS,CAAA;AAyBvD,UAAU,cAAc;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED,qBAAa,SAAU,SAAQ,aAAa,CAAC,cAAc,EAAE,cAAc,CAAC;IAC1E,WAAW,SAAc;IAEzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAsB;gBAE9B,KAAK,EAAE,cAAc;IAcjC,OAAO,KAAK,MAAM,GAOjB;IAED,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAIjB,iBAAiB,IAAI,IAAI;IAUzB,kBAAkB,IAAI,IAAI;IAI1B;;;OAGG;IACU,OAAO,CAAC,KAAK,GAAE,MAAU;IAItC;;OAEG;IACU,OAAO;IAIpB,MAAM,IAAI,SAAS;CAqDpB"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { Component, ComponentType, RefObject } from 'react';
|
|
2
2
|
import type { ColorValue, ViewProps } from 'react-native';
|
|
3
|
-
export interface
|
|
3
|
+
export interface SizeInfo {
|
|
4
4
|
index: number;
|
|
5
5
|
value: number;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Blur style mapped to native values in IOS.
|
|
9
|
+
*
|
|
10
|
+
* @platform ios
|
|
11
|
+
*/
|
|
12
|
+
export type BlurStyle = 'light' | 'dark' | 'default' | 'extraLight' | 'regular' | 'prominent' | 'systemUltraThinMaterial' | 'systemThinMaterial' | 'systemMaterial' | 'systemThickMaterial' | 'systemChromeMaterial' | 'systemUltraThinMaterialLight' | 'systemThinMaterialLight' | 'systemMaterialLight' | 'systemThickMaterialLight' | 'systemChromeMaterialLight' | 'systemUltraThinMaterialDark' | 'systemThinMaterialDark' | 'systemMaterialDark' | 'systemThickMaterialDark' | 'systemChromeMaterialDark';
|
|
7
13
|
/**
|
|
8
14
|
* Supported Sheet size.
|
|
9
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* @platform android
|
|
17
|
+
* @platform ios 15+
|
|
10
18
|
*/
|
|
11
19
|
export type SheetSize =
|
|
12
20
|
/**
|
|
@@ -52,15 +60,6 @@ export type SheetSize =
|
|
|
52
60
|
*/
|
|
53
61
|
| 'large';
|
|
54
62
|
export interface TrueSheetProps extends ViewProps {
|
|
55
|
-
/**
|
|
56
|
-
* Main sheet background color
|
|
57
|
-
*/
|
|
58
|
-
backgroundColor?: ColorValue;
|
|
59
|
-
/**
|
|
60
|
-
* The main scrollable ref that Sheet should handle on IOS.
|
|
61
|
-
* @platform ios
|
|
62
|
-
*/
|
|
63
|
-
scrollRef?: RefObject<Component<unknown>>;
|
|
64
63
|
/**
|
|
65
64
|
* The sizes you want the Sheet to support.
|
|
66
65
|
* Maximum of 3 sizes only; collapsed, half-expanded, expanded.
|
|
@@ -73,6 +72,37 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
73
72
|
* @default ['medium', 'large']
|
|
74
73
|
*/
|
|
75
74
|
sizes?: SheetSize[];
|
|
75
|
+
/**
|
|
76
|
+
* Main sheet background color
|
|
77
|
+
*/
|
|
78
|
+
backgroundColor?: ColorValue;
|
|
79
|
+
/**
|
|
80
|
+
* The sheet corner radius.
|
|
81
|
+
*
|
|
82
|
+
* @platform android
|
|
83
|
+
* @platform ios 15+
|
|
84
|
+
*/
|
|
85
|
+
cornerRadius?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Shows native grabber (or handle) on IOS
|
|
88
|
+
*
|
|
89
|
+
* @platform ios
|
|
90
|
+
* @default true
|
|
91
|
+
*/
|
|
92
|
+
grabber?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The blur effect style on iOS.
|
|
95
|
+
* Overrides `backgroundColor` if set.
|
|
96
|
+
*
|
|
97
|
+
* @platform ios
|
|
98
|
+
*/
|
|
99
|
+
blurStyle?: BlurStyle;
|
|
100
|
+
/**
|
|
101
|
+
* The main scrollable ref that Sheet should handle on IOS.
|
|
102
|
+
*
|
|
103
|
+
* @platform ios
|
|
104
|
+
*/
|
|
105
|
+
scrollRef?: RefObject<Component<unknown>>;
|
|
76
106
|
/**
|
|
77
107
|
* Overrides `large` or `100%` height.
|
|
78
108
|
*/
|
|
@@ -83,9 +113,9 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
83
113
|
FooterComponent?: ComponentType<unknown>;
|
|
84
114
|
/**
|
|
85
115
|
* Called when the Sheet has been presented.
|
|
86
|
-
* Comes with the size
|
|
116
|
+
* Comes with the size info.
|
|
87
117
|
*/
|
|
88
|
-
onPresent?: () => void;
|
|
118
|
+
onPresent?: (info: SizeInfo) => void;
|
|
89
119
|
/**
|
|
90
120
|
* Called when the Sheet has been dismissed
|
|
91
121
|
*/
|
|
@@ -94,6 +124,6 @@ export interface TrueSheetProps extends ViewProps {
|
|
|
94
124
|
* Called when the size of the sheet has changed.
|
|
95
125
|
* Either by dragging or programatically.
|
|
96
126
|
*/
|
|
97
|
-
onSizeChange?: (
|
|
127
|
+
onSizeChange?: (info: SizeInfo) => void;
|
|
98
128
|
}
|
|
99
129
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAEzD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAChE,OAAO,K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,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAA;IAEpC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IAEtB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAA;CACxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lodev09/react-native-true-sheet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "The true native bottom sheet. 💩",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -38,7 +38,10 @@
|
|
|
38
38
|
"keywords": [
|
|
39
39
|
"react-native",
|
|
40
40
|
"ios",
|
|
41
|
-
"android"
|
|
41
|
+
"android",
|
|
42
|
+
"bottom-sheet",
|
|
43
|
+
"native-sheet",
|
|
44
|
+
"sheet"
|
|
42
45
|
],
|
|
43
46
|
"repository": {
|
|
44
47
|
"type": "git",
|
package/src/TrueSheet.tsx
CHANGED
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
type NativeMethods,
|
|
8
8
|
type ViewStyle,
|
|
9
9
|
type NativeSyntheticEvent,
|
|
10
|
-
type StyleProp,
|
|
11
10
|
} from 'react-native'
|
|
12
11
|
|
|
13
|
-
import type { TrueSheetProps,
|
|
12
|
+
import type { TrueSheetProps, SizeInfo } from './types'
|
|
14
13
|
import { TrueSheetModule } from './TrueSheetModule'
|
|
15
14
|
|
|
16
15
|
const LINKING_ERROR =
|
|
@@ -21,15 +20,10 @@ const LINKING_ERROR =
|
|
|
21
20
|
|
|
22
21
|
const ComponentName = 'TrueSheetView'
|
|
23
22
|
|
|
24
|
-
interface TrueSheetNativeViewProps {
|
|
23
|
+
interface TrueSheetNativeViewProps extends Omit<TrueSheetProps, 'onPresent' | 'onSizeChange'> {
|
|
25
24
|
scrollableHandle: number | null
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
maxHeight?: TrueSheetProps['maxHeight']
|
|
29
|
-
children: ReactNode
|
|
30
|
-
onDismiss: () => void
|
|
31
|
-
onPresent: (event: NativeSyntheticEvent<{ index: number }>) => void
|
|
32
|
-
onSizeChange: (event: NativeSyntheticEvent<SizeChangeEvent>) => void
|
|
25
|
+
onPresent: (event: NativeSyntheticEvent<SizeInfo>) => void
|
|
26
|
+
onSizeChange: (event: NativeSyntheticEvent<SizeInfo>) => void
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
const TrueSheetNativeView = requireNativeComponent<TrueSheetNativeViewProps>(ComponentName)
|
|
@@ -82,12 +76,12 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
82
76
|
})
|
|
83
77
|
}
|
|
84
78
|
|
|
85
|
-
private onSizeChange(event: NativeSyntheticEvent<
|
|
79
|
+
private onSizeChange(event: NativeSyntheticEvent<SizeInfo>) {
|
|
86
80
|
this.props.onSizeChange?.(event.nativeEvent)
|
|
87
81
|
}
|
|
88
82
|
|
|
89
|
-
private onPresent(): void {
|
|
90
|
-
this.props.onPresent?.()
|
|
83
|
+
private onPresent(event: NativeSyntheticEvent<SizeInfo>): void {
|
|
84
|
+
this.props.onPresent?.(event.nativeEvent)
|
|
91
85
|
}
|
|
92
86
|
|
|
93
87
|
private onDismiss(): void {
|
|
@@ -117,32 +111,59 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
117
111
|
}
|
|
118
112
|
|
|
119
113
|
/**
|
|
120
|
-
*
|
|
114
|
+
* Dismisses the Sheet
|
|
121
115
|
*/
|
|
122
116
|
public async dismiss() {
|
|
123
117
|
await TrueSheetModule.dismiss(this.handle)
|
|
124
118
|
}
|
|
125
119
|
|
|
126
120
|
render(): ReactNode {
|
|
127
|
-
const
|
|
121
|
+
const {
|
|
122
|
+
sizes,
|
|
123
|
+
backgroundColor,
|
|
124
|
+
blurStyle,
|
|
125
|
+
cornerRadius,
|
|
126
|
+
grabber,
|
|
127
|
+
maxHeight,
|
|
128
|
+
FooterComponent,
|
|
129
|
+
testID,
|
|
130
|
+
style,
|
|
131
|
+
children,
|
|
132
|
+
...rest
|
|
133
|
+
} = this.props
|
|
128
134
|
|
|
129
135
|
return (
|
|
130
136
|
<TrueSheetNativeView
|
|
131
137
|
ref={this.ref}
|
|
132
138
|
style={$nativeSheet}
|
|
133
139
|
scrollableHandle={this.state.scrollableHandle}
|
|
134
|
-
sizes={
|
|
135
|
-
|
|
140
|
+
sizes={sizes ?? ['medium', 'large']}
|
|
141
|
+
blurStyle={blurStyle}
|
|
142
|
+
cornerRadius={cornerRadius}
|
|
143
|
+
grabber={grabber ?? true}
|
|
144
|
+
maxHeight={maxHeight}
|
|
136
145
|
onPresent={this.onPresent}
|
|
137
146
|
onDismiss={this.onDismiss}
|
|
138
147
|
onSizeChange={this.onSizeChange}
|
|
148
|
+
testID={testID}
|
|
139
149
|
>
|
|
140
150
|
<View
|
|
141
151
|
collapsable={false}
|
|
142
|
-
style={{
|
|
152
|
+
style={{
|
|
153
|
+
overflow: Platform.select({ ios: undefined, android: 'hidden' }),
|
|
154
|
+
borderTopLeftRadius: cornerRadius,
|
|
155
|
+
borderTopRightRadius: cornerRadius,
|
|
156
|
+
|
|
157
|
+
// Remove backgroundColor if `blurStyle` is set on iOS
|
|
158
|
+
backgroundColor: Platform.select({
|
|
159
|
+
ios: blurStyle ? undefined : backgroundColor ?? 'white',
|
|
160
|
+
android: backgroundColor ?? 'white',
|
|
161
|
+
}),
|
|
162
|
+
}}
|
|
163
|
+
{...rest}
|
|
143
164
|
>
|
|
144
|
-
<View collapsable={false} style={
|
|
145
|
-
{
|
|
165
|
+
<View collapsable={false} style={style}>
|
|
166
|
+
{children}
|
|
146
167
|
</View>
|
|
147
168
|
<View collapsable={false}>{!!FooterComponent && <FooterComponent />}</View>
|
|
148
169
|
</View>
|
|
@@ -153,5 +174,6 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
153
174
|
|
|
154
175
|
const $nativeSheet: ViewStyle = {
|
|
155
176
|
position: 'absolute',
|
|
177
|
+
width: 0,
|
|
156
178
|
zIndex: -9999,
|
|
157
179
|
}
|