react-native-sheet2 1.1.19

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 (74) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +79 -0
  3. package/android/build.gradle +83 -0
  4. package/android/gradle.properties +6 -0
  5. package/android/src/main/AndroidManifest.xml +12 -0
  6. package/android/src/main/java/com/behavior/BottomSheetBehavior.java +2329 -0
  7. package/android/src/main/java/com/behavior/InsetsAnimationCallback.java +83 -0
  8. package/android/src/main/java/com/modal/FullScreenDialog.kt +100 -0
  9. package/android/src/main/java/com/modal/TopModalView.kt +77 -0
  10. package/android/src/main/java/com/modal/TopModalViewManager.kt +83 -0
  11. package/android/src/main/java/com/modal/TopModalViewModule.kt +36 -0
  12. package/android/src/main/java/com/sheet/AppFittedSheet.kt +149 -0
  13. package/android/src/main/java/com/sheet/BaseRNView.kt +73 -0
  14. package/android/src/main/java/com/sheet/CustomBottomSheetDialog.java +238 -0
  15. package/android/src/main/java/com/sheet/DialogRootViewGroup.kt +159 -0
  16. package/android/src/main/java/com/sheet/FragmentModalBottomSheet.kt +54 -0
  17. package/android/src/main/java/com/sheet/ReactNativeReflection.java +24 -0
  18. package/android/src/main/java/com/sheet/SheetPackage.kt +20 -0
  19. package/android/src/main/java/com/sheet/SheetViewManager.kt +144 -0
  20. package/android/src/main/java/com/sheet/SheetViewModule.kt +43 -0
  21. package/android/src/main/java/com/sheet/utils.kt +71 -0
  22. package/android/src/main/java/com/transparent/activity/ActivityModalView.kt +71 -0
  23. package/android/src/main/java/com/transparent/activity/TransparentActivity.kt +48 -0
  24. package/android/src/main/java/com/transparent/activity/TransparentActivityManager.kt +63 -0
  25. package/android/src/main/java/com/transparent/activity/TransparentActivityModule.kt +28 -0
  26. package/android/src/main/res/anim/fade_in.xml +8 -0
  27. package/android/src/main/res/anim/fade_out.xml +11 -0
  28. package/android/src/main/res/anim/slide_down.xml +8 -0
  29. package/android/src/main/res/anim/slide_up.xml +8 -0
  30. package/android/src/main/res/layout/dialog_bottom_sheet.xml +64 -0
  31. package/android/src/main/res/layout/item_full.xml +14 -0
  32. package/android/src/main/res/values/colors.xml +15 -0
  33. package/android/src/main/res/values/styles.xml +75 -0
  34. package/ios/FittedSheets/Compatible.swift +55 -0
  35. package/ios/FittedSheets/InitialTouchPanGestureRecognizer.swift +19 -0
  36. package/ios/FittedSheets/SheetContentViewController.swift +326 -0
  37. package/ios/FittedSheets/SheetContentViewDelegate.swift +17 -0
  38. package/ios/FittedSheets/SheetOptions.swift +100 -0
  39. package/ios/FittedSheets/SheetSize.swift +20 -0
  40. package/ios/FittedSheets/SheetTransition.swift +153 -0
  41. package/ios/FittedSheets/SheetView.swift +21 -0
  42. package/ios/FittedSheets/SheetViewController.swift +761 -0
  43. package/ios/FittedSheets/SheetViewDelegate.swift +16 -0
  44. package/ios/FittedSheets/UIColorExtension.swift +59 -0
  45. package/ios/FittedSheets/UIViewControllerExtension.swift +27 -0
  46. package/ios/FittedSheets/Yalta.swift +420 -0
  47. package/ios/LBBottomSheet/BottomSheetConstant.swift +48 -0
  48. package/ios/LBBottomSheet/Model/BottomSheetController+Behavior.swift +262 -0
  49. package/ios/LBBottomSheet/Model/BottomSheetController+Theme.swift +156 -0
  50. package/ios/LBBottomSheet/Protocols/BottomSheetInteractionDelegate.swift +29 -0
  51. package/ios/LBBottomSheet/Protocols/BottomSheetPositionDelegate.swift +31 -0
  52. package/ios/LBBottomSheet/UI/BottomSheet.storyboard +105 -0
  53. package/ios/LBBottomSheet/UI/BottomSheetController.swift +601 -0
  54. package/ios/LBBottomSheet/Utils/Components/ForwardingEventsView.swift +60 -0
  55. package/ios/LBBottomSheet/Utils/Extensions/CACornerMask+Extension.swift +33 -0
  56. package/ios/LBBottomSheet/Utils/Extensions/Mirror+Extension.swift +47 -0
  57. package/ios/LBBottomSheet/Utils/Extensions/UIApplication+Extension.swift +35 -0
  58. package/ios/LBBottomSheet/Utils/Extensions/UIColor+Extension.swift +61 -0
  59. package/ios/LBBottomSheet/Utils/Extensions/UIGestureRecognizer+Extensions.swift +28 -0
  60. package/ios/LBBottomSheet/Utils/Extensions/UIScreen+Extension.swift +28 -0
  61. package/ios/LBBottomSheet/Utils/Extensions/UIScrollView+Extension.swift +25 -0
  62. package/ios/LBBottomSheet/Utils/Extensions/UIView+Extension.swift +52 -0
  63. package/ios/LBBottomSheet/Utils/Extensions/UIViewController+Extension.swift +104 -0
  64. package/ios/Sheet-Bridging-Header.h +1 -0
  65. package/ios/Sheet.xcodeproj/project.pbxproj +377 -0
  66. package/ios/SheetViewManager.m +27 -0
  67. package/ios/SheetViewManager.swift +351 -0
  68. package/ios/TopModalViewManager.swift +196 -0
  69. package/package.json +103 -0
  70. package/react-native-sheet.podspec +21 -0
  71. package/src/FittedSheet.tsx +177 -0
  72. package/src/TopModal.tsx +94 -0
  73. package/src/TransparentActivity.tsx +98 -0
  74. package/src/index.tsx +16 -0
@@ -0,0 +1,351 @@
1
+ //
2
+ // AppFittedSheet.swift
3
+ // PopupMenu
4
+ //
5
+ // Created by Sergei Golishnikov on 14/02/2022.
6
+ // Copyright © 2022 Facebook. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+ import UIKit
11
+ import React
12
+
13
+ class ModalHostShadowView: RCTShadowView {
14
+ static var attachedViews: [Int: HostFittedSheet] = [:]
15
+ override func insertReactSubview(_ subview: RCTShadowView!, at atIndex: Int) {
16
+ super.insertReactSubview(subview, at: atIndex)
17
+ if subview != nil {
18
+ (subview as RCTShadowView).width = YGValue.init(value: Float(RCTScreenSize().width), unit: .point)
19
+ subview.position = .absolute
20
+ }
21
+ }
22
+
23
+ override func layoutSubviews(with layoutContext: RCTLayoutContext) {
24
+ super.layoutSubviews(with: layoutContext)
25
+ let tag = self.reactTag.intValue
26
+ var size = reactSubviews()[0].contentFrame.size
27
+ let view = ModalHostShadowView.attachedViews[tag]
28
+ let maxheight = view?.sheetMaxHeightSize?.doubleValue ?? .infinity
29
+ let minHeight = view?.sheetMinHeightSize?.doubleValue ?? .zero
30
+
31
+ DispatchQueue.main.async {
32
+ if size.height > maxheight {
33
+ debugPrint("😀 constraint \(tag) \(size) \(maxheight)")
34
+ size.height = maxheight
35
+ view!.notifyForBoundsChange(newBounds: size)
36
+ }
37
+ if size.height < minHeight {
38
+ debugPrint("😀 constraint \(tag) \(size) \(minHeight)")
39
+ size.height = minHeight
40
+ view!.notifyForBoundsChange(newBounds: size)
41
+ }
42
+ view?._modalViewController?.setSizes([.fixed(size.height)])
43
+ }
44
+ debugPrint("😀 layout(with \(tag) \(size) \(maxheight)")
45
+ }
46
+ }
47
+
48
+ let FITTED_SHEET_SCROLL_VIEW = "fittedSheetScrollView"
49
+
50
+ @objc(SheetViewManager)
51
+ class SheetViewManager: RCTViewManager {
52
+ override static func requiresMainQueueSetup() -> Bool {
53
+ return true
54
+ }
55
+
56
+ override func view() -> UIView! {
57
+ let v = HostFittedSheet(bridge: bridge)
58
+ return v
59
+ }
60
+
61
+ private func getSheetView(withTag tag: NSNumber) -> HostFittedSheet {
62
+ // swiftlint:disable force_cast
63
+ return bridge.uiManager.view(forReactTag: tag) as! HostFittedSheet
64
+ }
65
+
66
+ @objc
67
+ final func dismiss(_ node: NSNumber) {
68
+ DispatchQueue.main.async {
69
+ let component = self.getSheetView(withTag: node)
70
+ component._modalViewController?.dismiss(animated: true)
71
+ debugPrint("😀dismiss")
72
+ }
73
+ }
74
+
75
+ override func shadowView() -> RCTShadowView! {
76
+ return ModalHostShadowView()
77
+ }
78
+
79
+ deinit {
80
+ debugPrint("😀 deinit view manager")
81
+ }
82
+ }
83
+
84
+
85
+ class HostFittedSheet: UIView {
86
+ var _modalViewController: SheetViewController?
87
+ let viewController = UIViewController()
88
+ var _touchHandler: RCTTouchHandler?
89
+ var _reactSubview: UIView?
90
+ var _bridge: RCTBridge?
91
+ var _isPresented = false
92
+ var _sheetSize: NSNumber?
93
+ var _scrollViewTag: NSNumber?
94
+
95
+ private var _alertWindow: UIWindow?
96
+ private lazy var presentViewController: UIViewController = {
97
+ _alertWindow = UIWindow(frame: .init(origin: .zero, size: RCTScreenSize()))
98
+ let controller = UIViewController()
99
+ _alertWindow?.rootViewController = controller
100
+ _alertWindow?.windowLevel = UIWindow.Level.alert
101
+ _alertWindow?.isHidden = false
102
+ _alertWindow?.makeKeyAndVisible()
103
+ return controller
104
+ }()
105
+
106
+ @objc
107
+ private var onSheetDismiss: RCTDirectEventBlock?
108
+
109
+ @objc
110
+ func setIncreaseHeight(_ by: NSNumber) {
111
+ if by.floatValue == 0 { return }
112
+ debugPrint("setIncreaseHeight", by.floatValue)
113
+ changeHeight(by.floatValue)
114
+ }
115
+
116
+ @objc
117
+ func setDecreaseHeight(_ by: NSNumber) {
118
+ if by.floatValue == 0 { return }
119
+ debugPrint("setDecreaseHeight", -by.floatValue)
120
+ changeHeight(-by.floatValue)
121
+ }
122
+
123
+ @objc
124
+ func setPassScrollViewReactTag(_ tag: NSNumber) {
125
+ debugPrint("😀 setPassScrollViewReactTag", tag)
126
+ guard let scrollView = self._bridge?.uiManager.view(forReactTag: tag) as? RCTScrollView else {
127
+ return
128
+ }
129
+ if self._modalViewController == nil {
130
+ self._scrollViewTag = tag
131
+ }
132
+ debugPrint("😀 setPassScrollViewReactTag found", scrollView, self._modalViewController)
133
+ self._modalViewController?.handleScrollView(scrollView.scrollView)
134
+ }
135
+
136
+ private func changeHeight(_ by: Float) {
137
+ if !_isPresented { return }
138
+ guard let reactSubView = _reactSubview else { return }
139
+
140
+ let newHeight = CGFloat(by)
141
+ if reactSubView.frame.height == newHeight { return }
142
+ let increasedHeight = reactSubView.frame.height + newHeight
143
+ debugPrint("changeHeight from", reactSubView.frame.height, "to", increasedHeight)
144
+ let sizes: [SheetSize] = [.fixed(increasedHeight)]
145
+ self._modalViewController?.sizes = sizes
146
+ self._modalViewController?.resize(to: sizes[0], animated: true)
147
+ self.notifyForBoundsChange(newBounds: .init(width: reactSubView.frame.width, height: increasedHeight))
148
+ debugPrint("", increasedHeight)
149
+ }
150
+
151
+ private var sheetMaxWidthSize: NSNumber?
152
+ private var dismissable = true
153
+ var sheetMaxHeightSize: NSNumber?
154
+ var sheetMinHeightSize: NSNumber?
155
+ private var topLeftRightCornerRadius: NSNumber?
156
+ private var sheetBackgroundColor: UIColor?
157
+
158
+ @objc
159
+ var fittedSheetParams: NSDictionary? {
160
+ didSet {
161
+ sheetMaxWidthSize = (fittedSheetParams?["maxWidth"] as? NSNumber)
162
+ sheetMaxHeightSize = (fittedSheetParams?["maxHeight"] as? NSNumber)
163
+ sheetMinHeightSize = (fittedSheetParams?["minHeight"] as? NSNumber)
164
+ dismissable = (fittedSheetParams?["dismissable"] as? Bool) ?? true
165
+ topLeftRightCornerRadius = (fittedSheetParams?["topLeftRightCornerRadius"] as? NSNumber)
166
+ sheetBackgroundColor = RCTConvert.uiColor(fittedSheetParams?["backgroundColor"])
167
+ }
168
+ }
169
+
170
+ private var sheetWidth: CGFloat {
171
+ return CGFloat(sheetMaxWidthSize?.floatValue ?? Float(UIScreen.main.bounds.width))
172
+ }
173
+
174
+ init(bridge: RCTBridge) {
175
+ self._bridge = bridge
176
+ super.init(frame: .zero)
177
+ _touchHandler = RCTTouchHandler(bridge: bridge)
178
+ }
179
+
180
+ required init?(coder: NSCoder) {
181
+ fatalError("init(coder:) has not been implemented")
182
+ }
183
+
184
+ func notifyForBoundsChange(newBounds: CGSize) {
185
+ if (_reactSubview != nil && _isPresented) {
186
+ debugPrint("😀notifyForBoundsChange \(newBounds)")
187
+ _bridge?.uiManager.setSize(newBounds, for: _reactSubview!)
188
+ }
189
+ }
190
+
191
+ override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
192
+ debugPrint("😀insertReactSubview")
193
+ super.insertReactSubview(subview, at: atIndex)
194
+ _touchHandler?.attach(to: subview)
195
+ viewController.view.insertSubview(subview, at: 0)
196
+ _reactSubview = subview
197
+ }
198
+
199
+ override func removeReactSubview(_ subview: UIView!) {
200
+ debugPrint("😀removeReactSubview")
201
+ super.removeReactSubview(subview)
202
+ _touchHandler?.detach(from: subview)
203
+ _reactSubview = nil
204
+ //destroy()
205
+ }
206
+
207
+ // need to leave it empty
208
+ override func didUpdateReactSubviews() {}
209
+
210
+ override func didMoveToWindow() {
211
+ super.didMoveToWindow()
212
+
213
+ // In the case where there is a LayoutAnimation, we will be reinserted into the view hierarchy but only for aesthetic
214
+ // purposes. In such a case, we should NOT represent the <Modal>.
215
+
216
+ if (!self.isUserInteractionEnabled && self.superview?.reactSubviews().contains(self) != nil) {
217
+ return;
218
+ }
219
+
220
+ if (!_isPresented && self.window != nil) {
221
+ _isPresented = true
222
+ var size: CGSize = .zero
223
+ DispatchQueue.main.async { [weak self] in
224
+ guard let self = self else { return }
225
+ if self._sheetSize?.floatValue == nil {
226
+ self._reactSubview?.setNeedsLayout()
227
+ self._reactSubview?.layoutIfNeeded()
228
+ self._reactSubview?.sizeToFit()
229
+ size = self._reactSubview?.frame.size ?? .zero
230
+ } else {
231
+ size = .init(width: self.sheetWidth, height: CGFloat(self._sheetSize!.floatValue))
232
+ }
233
+ if size.width > self.sheetWidth {
234
+ size.width = self.sheetWidth
235
+ }
236
+ // if maxSize is present notify react native view
237
+ if self.sheetMaxHeightSize != nil && size.height > self.sheetMaxHeightSize!.doubleValue {
238
+ size.height = self.sheetMaxHeightSize!.doubleValue
239
+ self.notifyForBoundsChange(newBounds: size)
240
+ }
241
+ // if maxSize is present notify react native view
242
+ if self.sheetMinHeightSize != nil && size.height < self.sheetMinHeightSize!.doubleValue {
243
+ size.height = self.sheetMinHeightSize!.doubleValue
244
+ self.notifyForBoundsChange(newBounds: size)
245
+ }
246
+ self._modalViewController = SheetViewController(
247
+ controller: self.viewController,
248
+ sizes: [.fixed(size.height)],
249
+ options: .init(
250
+ pullBarHeight: 0,
251
+ shouldExtendBackground: false,
252
+ shrinkPresentingViewController: false,
253
+ maxWidth: self.sheetWidth
254
+ )
255
+ )
256
+ self._modalViewController?.allowPullingPastMaxHeight = false
257
+ self._modalViewController?.dismissOnOverlayTap = self.dismissable
258
+ self._modalViewController?.autoAdjustToKeyboard = false
259
+ self._modalViewController?.dismissOnPull = self.dismissable
260
+ self._modalViewController?.cornerRadius = self.topLeftRightCornerRadius?.doubleValue ?? 12
261
+ self._modalViewController?.contentBackgroundColor = self.sheetBackgroundColor ?? .clear
262
+ debugPrint("😀 attachedViews \(self.reactTag.intValue)")
263
+ ModalHostShadowView.attachedViews[self.reactTag.intValue] = self
264
+
265
+ if let tag = self._scrollViewTag {
266
+ self.setPassScrollViewReactTag(tag)
267
+ } else {
268
+ let scrollView = self._reactSubview?.find(FITTED_SHEET_SCROLL_VIEW, deepIndex: 0) as? RCTScrollView
269
+ if scrollView != nil {
270
+ self._modalViewController?.handleScrollView(scrollView!.scrollView)
271
+ }
272
+ }
273
+
274
+ self.presentViewController.present(self._modalViewController!, animated: true)
275
+ //self.reactViewController().present(self._modalViewController!, animated: true)
276
+
277
+ self._modalViewController?.didDismiss = { [weak self] _ in
278
+ debugPrint("😀didDismiss \(self?.onSheetDismiss)")
279
+ self?.onSheetDismiss?([:])
280
+ }
281
+ }
282
+ }
283
+ }
284
+
285
+ override func removeFromSuperview() {
286
+ super.removeFromSuperview()
287
+ debugPrint("😀removeFromSuperview")
288
+ //destroy()
289
+ }
290
+
291
+ override func didMoveToSuperview() {
292
+ super.didMoveToSuperview()
293
+ if _isPresented && superview == nil {
294
+ debugPrint("😀didMoveToSuperview")
295
+ destroy()
296
+ }
297
+ }
298
+
299
+ func destroy() {
300
+ debugPrint("😀destroy")
301
+ _isPresented = false
302
+
303
+ let cleanup = { [weak self] in
304
+ guard let self = self else { return }
305
+ debugPrint("😀 cleanup")
306
+ ModalHostShadowView.attachedViews.removeValue(forKey: self.reactTag.intValue)
307
+ self._modalViewController = nil
308
+ self._reactSubview?.removeFromSuperview()
309
+ self._touchHandler?.detach(from: self._reactSubview)
310
+ self._touchHandler = nil
311
+ self._bridge = nil
312
+ self.onSheetDismiss = nil
313
+ self._sheetSize = nil
314
+ self.sheetMaxWidthSize = nil
315
+ self._reactSubview = nil
316
+ self._alertWindow = nil
317
+ }
318
+
319
+ if self._modalViewController?.isBeingDismissed != true {
320
+ debugPrint("😀dismissViewController")
321
+ self._modalViewController?.dismiss(animated: true, completion: cleanup)
322
+ } else {
323
+ cleanup()
324
+ }
325
+
326
+ }
327
+
328
+ deinit {
329
+ debugPrint("😀deinit")
330
+ }
331
+
332
+ }
333
+
334
+
335
+ extension UIView {
336
+ func find(_ nId: String, deepIndex: Int) -> UIView? {
337
+ if deepIndex >= 10 { return nil }
338
+ if self.nativeID == nId || self.accessibilityIdentifier == nId {
339
+ return self
340
+ }
341
+
342
+ let index = deepIndex + 1
343
+ for subview in subviews {
344
+ if let v = subview.find(nId, deepIndex: index) {
345
+ return v
346
+ }
347
+ }
348
+
349
+ return nil
350
+ }
351
+ }
@@ -0,0 +1,196 @@
1
+ //
2
+ // TopModalViewManager.swift
3
+ // Sheet
4
+ //
5
+ // Created by Sergei Golishnikov on 10/03/2023.
6
+ // Copyright © 2023 Facebook. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+ import UIKit
11
+ import React
12
+
13
+
14
+ class TopModalShadowView: RCTShadowView {
15
+ static var attachedViews: [Int: HostFittedSheet] = [:]
16
+ override func insertReactSubview(_ subview: RCTShadowView!, at atIndex: Int) {
17
+ super.insertReactSubview(subview, at: atIndex)
18
+ if subview != nil {
19
+ let size = RCTScreenSize()
20
+ subview.width = .init(value: Float(size.width), unit: .point)
21
+ subview.height = .init(value: Float(size.height), unit: .point)
22
+ subview.position = .absolute
23
+ }
24
+ }
25
+ }
26
+
27
+ @objc(TopModalViewManager)
28
+ class TopModalViewManager: RCTViewManager {
29
+ override static func requiresMainQueueSetup() -> Bool {
30
+ return true
31
+ }
32
+
33
+ override func view() -> UIView! {
34
+ let v = TopModalView(bridge: bridge)
35
+ return v
36
+ }
37
+
38
+ private func getSheetView(withTag tag: NSNumber) -> TopModalView {
39
+ // swiftlint:disable force_cast
40
+ return bridge.uiManager.view(forReactTag: tag) as! TopModalView
41
+ }
42
+
43
+ @objc
44
+ final func dismiss(_ node: NSNumber) {
45
+ DispatchQueue.main.async {
46
+ let component = self.getSheetView(withTag: node)
47
+ component.dismissVC()
48
+ debugPrint("😀dismiss")
49
+ }
50
+ }
51
+
52
+ override func shadowView() -> RCTShadowView! {
53
+ return TopModalShadowView()
54
+ }
55
+
56
+ deinit {
57
+ debugPrint("😀 deinit view manager")
58
+ }
59
+ }
60
+
61
+
62
+ class TopModalView: RCTView {
63
+ let viewController = UIViewController()
64
+ var _touchHandler: RCTTouchHandler?
65
+ var _reactSubview: UIView?
66
+ var _bridge: RCTBridge?
67
+ weak var manager: SheetViewManager?
68
+ var _isPresented = false
69
+ var _scrollViewTag: NSNumber?
70
+
71
+ private var _alertWindow: UIWindow?
72
+ private lazy var presentViewController: UIViewController = {
73
+ _alertWindow = UIWindow(frame: .init(origin: .zero, size: RCTScreenSize()))
74
+ let controller = UIViewController()
75
+ _alertWindow?.rootViewController = controller
76
+ _alertWindow?.windowLevel = UIWindow.Level.alert
77
+ _alertWindow?.isHidden = false
78
+ viewController.modalPresentationStyle = .fullScreen
79
+
80
+ if (animationType == "fade") {
81
+ viewController.modalTransitionStyle = .crossDissolve
82
+ } else if (animationType == "slide") {
83
+ viewController.modalTransitionStyle = .coverVertical
84
+ } else if animationType == "none" {
85
+
86
+ }
87
+
88
+ viewController.view.backgroundColor = .clear
89
+ return controller
90
+ }()
91
+
92
+ @objc
93
+ private var onModalDismiss: RCTDirectEventBlock?
94
+ @objc
95
+ private var animated: Bool = true
96
+ /// objc doesn't support String Enums
97
+ @objc
98
+ private var animationType = "slide"
99
+
100
+ init(bridge: RCTBridge) {
101
+ self._bridge = bridge
102
+ super.init(frame: .zero)
103
+ _touchHandler = RCTTouchHandler(bridge: bridge)
104
+ }
105
+
106
+ required init?(coder: NSCoder) {
107
+ fatalError("init(coder:) has not been implemented")
108
+ }
109
+
110
+ override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
111
+ debugPrint("😀insertReactSubview")
112
+ super.insertReactSubview(subview, at: atIndex)
113
+ _touchHandler?.attach(to: subview)
114
+ viewController.view.insertSubview(subview, at: 0)
115
+ _reactSubview = subview
116
+ }
117
+
118
+ override func removeReactSubview(_ subview: UIView!) {
119
+ debugPrint("😀removeReactSubview")
120
+ super.removeReactSubview(subview)
121
+ _touchHandler?.detach(from: subview)
122
+ _reactSubview = nil
123
+ //destroy()
124
+ }
125
+
126
+ // need to leave it empty
127
+ override func didUpdateReactSubviews() {}
128
+
129
+ override func didMoveToWindow() {
130
+ super.didMoveToWindow()
131
+ if (!self.isUserInteractionEnabled && self.superview?.reactSubviews().contains(self) != nil) {
132
+ return;
133
+ }
134
+
135
+ if (!_isPresented && self.window != nil) {
136
+ _isPresented = true
137
+ DispatchQueue.main.async { [weak self] in
138
+ guard let self = self else {return}
139
+ guard let rv = self._reactSubview else {return}
140
+ self.viewController.view.addSubview(rv)
141
+ self.presentViewController.present(self.viewController, animated: self.animated)
142
+ }
143
+ }
144
+ }
145
+
146
+ override func removeFromSuperview() {
147
+ super.removeFromSuperview()
148
+ debugPrint("😀removeFromSuperview")
149
+ //destroy()
150
+ }
151
+
152
+ override func didMoveToSuperview() {
153
+ super.didMoveToSuperview()
154
+ if _isPresented && superview == nil {
155
+ debugPrint("😀didMoveToSuperview")
156
+ destroy()
157
+ }
158
+ }
159
+
160
+ func dismissVC() {
161
+ self.viewController.dismiss(animated: self.animated) {
162
+ debugPrint("😀 dismissVC \(self.onModalDismiss)")
163
+ self.onModalDismiss?([:])
164
+ }
165
+ }
166
+
167
+ func destroy() {
168
+ debugPrint("😀destroy")
169
+ _isPresented = false
170
+
171
+ let cleanup = { [weak self] in
172
+ guard let self = self else { return }
173
+ debugPrint("😀 cleanup")
174
+ self._reactSubview?.removeFromSuperview()
175
+ self._touchHandler?.detach(from: self._reactSubview)
176
+ self._touchHandler = nil
177
+ self._bridge = nil
178
+ self.onModalDismiss = nil
179
+ self._reactSubview = nil
180
+ self._alertWindow = nil
181
+ }
182
+
183
+
184
+ if self.viewController.isBeingDismissed != true {
185
+ debugPrint("😀dismissViewController")
186
+ self.viewController.dismiss(animated: self.animated, completion: cleanup)
187
+ } else {
188
+ cleanup()
189
+ }
190
+
191
+ }
192
+
193
+ deinit {
194
+ debugPrint("😀deinit")
195
+ }
196
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "react-native-sheet2",
3
+ "version": "1.1.19",
4
+ "description": "Native implementation of Bottom sheet",
5
+ "main": "src/index",
6
+ "module": "src/index",
7
+ "react-native": "src/index",
8
+ "source": "src/index",
9
+ "files": [
10
+ "src",
11
+ "lib",
12
+ "android",
13
+ "ios",
14
+ "cpp",
15
+ "*.podspec",
16
+ "!lib/typescript/example",
17
+ "!ios/build",
18
+ "!android/build",
19
+ "!android/gradle",
20
+ "!android/gradlew",
21
+ "!android/gradlew.bat",
22
+ "!android/local.properties",
23
+ "!**/__tests__",
24
+ "!**/__fixtures__",
25
+ "!**/__mocks__",
26
+ "!**/.*"
27
+ ],
28
+ "scripts": {
29
+ "test": "jest",
30
+ "typecheck": "tsc --noEmit",
31
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
32
+ "example": "yarn --cwd example",
33
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
34
+ },
35
+ "keywords": [
36
+ "react-native",
37
+ "ios",
38
+ "android"
39
+ ],
40
+ "repository": "https://github.com/sergeymild/react-native-sheet",
41
+ "author": "Sergei Golishnikov <sergeymild@yandex.ru> (https://github.com/sergeymild)",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/sergeymild/react-native-sheet/issues"
45
+ },
46
+ "homepage": "https://github.com/sergeymild/react-native-sheet#readme",
47
+ "publishConfig": {
48
+ "registry": "https://registry.npmjs.org/"
49
+ },
50
+ "devDependencies": {
51
+ "@react-native-community/eslint-config": "^3.2.0",
52
+ "@types/react": "~18.2.38",
53
+ "@types/react-native": "0.72.7",
54
+ "eslint": "^8.4.1",
55
+ "eslint-config-prettier": "^9.0.0",
56
+ "eslint-plugin-prettier": "^5.0.1",
57
+ "pod-install": "^0.1.39",
58
+ "prettier": "^3.1.0",
59
+ "react": "18.2.0",
60
+ "react-native": "0.72.7",
61
+ "typescript": "^5.3.2"
62
+ },
63
+ "resolutions": {
64
+ "@types/react": "18.2.0"
65
+ },
66
+ "peerDependencies": {
67
+ "react": "*",
68
+ "react-native": "*"
69
+ },
70
+ "engines": {
71
+ "node": ">= 16.0.0"
72
+ },
73
+ "eslintConfig": {
74
+ "root": true,
75
+ "extends": [
76
+ "@react-native-community",
77
+ "prettier"
78
+ ],
79
+ "rules": {
80
+ "prettier/prettier": [
81
+ "error",
82
+ {
83
+ "quoteProps": "consistent",
84
+ "singleQuote": true,
85
+ "tabWidth": 2,
86
+ "trailingComma": "es5",
87
+ "useTabs": false
88
+ }
89
+ ]
90
+ }
91
+ },
92
+ "eslintIgnore": [
93
+ "node_modules/",
94
+ "lib/"
95
+ ],
96
+ "prettier": {
97
+ "quoteProps": "consistent",
98
+ "singleQuote": true,
99
+ "tabWidth": 2,
100
+ "trailingComma": "es5",
101
+ "useTabs": false
102
+ }
103
+ }
@@ -0,0 +1,21 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-sheet"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://github.com/sergeymild/react-native-sheet.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm,swift}"
18
+ s.resources = "ios/**/*.{storyboard}"
19
+
20
+ s.dependency "React-Core"
21
+ end