react-native-sheet2 1.1.20 → 1.1.22

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.
@@ -15,7 +15,13 @@ class ModalHostShadowView: RCTShadowView {
15
15
  override func insertReactSubview(_ subview: RCTShadowView!, at atIndex: Int) {
16
16
  super.insertReactSubview(subview, at: atIndex)
17
17
  if subview != nil {
18
- (subview as RCTShadowView).width = YGValue.init(value: Float(RCTScreenSize().width), unit: .point)
18
+ let s = RCTScreenSize()
19
+ let orientation = UIDevice.current.orientation
20
+ var width = s.width
21
+ if orientation == .landscapeLeft || orientation == .landscapeRight {
22
+ width = s.height
23
+ }
24
+ (subview as RCTShadowView).width = YGValue.init(value: Float(width), unit: .point)
19
25
  subview.position = .absolute
20
26
  }
21
27
  }
@@ -24,11 +30,13 @@ class ModalHostShadowView: RCTShadowView {
24
30
  super.layoutSubviews(with: layoutContext)
25
31
  let tag = self.reactTag.intValue
26
32
  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
33
 
31
34
  DispatchQueue.main.async {
35
+ let view = ModalHostShadowView.attachedViews[tag]
36
+ let maxWidth = view?.sheetWidth ?? .infinity
37
+ let maxheight = view?.sheetMaxHeightSize?.doubleValue ?? .infinity
38
+ let minHeight = view?.sheetMinHeightSize?.doubleValue ?? .zero
39
+
32
40
  if size.height > maxheight {
33
41
  debugPrint("😀 constraint \(tag) \(size) \(maxheight)")
34
42
  size.height = maxheight
@@ -39,9 +47,14 @@ class ModalHostShadowView: RCTShadowView {
39
47
  size.height = minHeight
40
48
  view!.notifyForBoundsChange(newBounds: size)
41
49
  }
50
+ if size.width > maxWidth {
51
+ debugPrint("😀 constraint \(tag) \(size) \(maxWidth)")
52
+ size.width = maxWidth
53
+ view!.notifyForBoundsChange(newBounds: size)
54
+ }
42
55
  view?._modalViewController?.setSizes([.fixed(size.height)])
56
+ debugPrint("😀 layout(with \(tag) \(size) \(maxheight)")
43
57
  }
44
- debugPrint("😀 layout(with \(tag) \(size) \(maxheight)")
45
58
  }
46
59
  }
47
60
 
@@ -148,7 +161,7 @@ class HostFittedSheet: UIView {
148
161
  debugPrint("", increasedHeight)
149
162
  }
150
163
 
151
- private var sheetMaxWidthSize: NSNumber?
164
+ var sheetMaxWidthSize: NSNumber?
152
165
  private var dismissable = true
153
166
  var sheetMaxHeightSize: NSNumber?
154
167
  var sheetMinHeightSize: NSNumber?
@@ -158,6 +171,7 @@ class HostFittedSheet: UIView {
158
171
  @objc
159
172
  var fittedSheetParams: NSDictionary? {
160
173
  didSet {
174
+ debugPrint("😀 ", fittedSheetParams ?? "nil")
161
175
  sheetMaxWidthSize = (fittedSheetParams?["maxWidth"] as? NSNumber)
162
176
  sheetMaxHeightSize = (fittedSheetParams?["maxHeight"] as? NSNumber)
163
177
  sheetMinHeightSize = (fittedSheetParams?["minHeight"] as? NSNumber)
@@ -167,7 +181,7 @@ class HostFittedSheet: UIView {
167
181
  }
168
182
  }
169
183
 
170
- private var sheetWidth: CGFloat {
184
+ var sheetWidth: CGFloat {
171
185
  return CGFloat(sheetMaxWidthSize?.floatValue ?? Float(UIScreen.main.bounds.width))
172
186
  }
173
187
 
@@ -227,20 +241,27 @@ class HostFittedSheet: UIView {
227
241
  self._reactSubview?.layoutIfNeeded()
228
242
  self._reactSubview?.sizeToFit()
229
243
  size = self._reactSubview?.frame.size ?? .zero
244
+ debugPrint("😀 self._sheetSize?.floatValue == nil", size)
230
245
  } else {
231
246
  size = .init(width: self.sheetWidth, height: CGFloat(self._sheetSize!.floatValue))
247
+ debugPrint("😀 else", size)
232
248
  }
249
+ var shouldUpdate = false
233
250
  if size.width > self.sheetWidth {
234
251
  size.width = self.sheetWidth
252
+ shouldUpdate = true
235
253
  }
236
254
  // if maxSize is present notify react native view
237
255
  if self.sheetMaxHeightSize != nil && size.height > self.sheetMaxHeightSize!.doubleValue {
238
256
  size.height = self.sheetMaxHeightSize!.doubleValue
239
- self.notifyForBoundsChange(newBounds: size)
257
+ shouldUpdate = true
240
258
  }
241
259
  // if maxSize is present notify react native view
242
260
  if self.sheetMinHeightSize != nil && size.height < self.sheetMinHeightSize!.doubleValue {
243
261
  size.height = self.sheetMinHeightSize!.doubleValue
262
+ shouldUpdate = true
263
+ }
264
+ if shouldUpdate {
244
265
  self.notifyForBoundsChange(newBounds: size)
245
266
  }
246
267
  self._modalViewController = SheetViewController(
@@ -335,7 +356,7 @@ class HostFittedSheet: UIView {
335
356
  extension UIView {
336
357
  func find(_ nId: String, deepIndex: Int) -> UIView? {
337
358
  if deepIndex >= 10 { return nil }
338
- if self.nativeID == nId || self.accessibilityIdentifier == nId {
359
+ if self.nativeID?.contains(nId) == true || self.accessibilityIdentifier?.contains(nId) == true {
339
360
  return self
340
361
  }
341
362
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-sheet2",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Native implementation of Bottom sheet",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
package/src/index.tsx CHANGED
@@ -5,11 +5,8 @@ import {
5
5
  FittedSheetParams,
6
6
  } from './FittedSheet';
7
7
 
8
- export {
9
- FittedSheet,
10
- FITTED_SHEET_SCROLL_VIEW,
11
- useFittedSheetContext,
12
- FittedSheetParams,
13
- };
8
+ export { FittedSheet, FITTED_SHEET_SCROLL_VIEW, useFittedSheetContext };
9
+
10
+ export type { FittedSheetParams };
14
11
 
15
12
  export { TopModal } from './TopModal';