@onekeyfe/react-native-native-sheet 3.0.125 → 3.0.126
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.
|
@@ -198,7 +198,9 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
198
198
|
private let cornerRadiusValue: CGFloat
|
|
199
199
|
private let showHandleValue: Bool
|
|
200
200
|
private let dismissOnBackdropPressValue: Bool
|
|
201
|
+
private let dimAmountValue: CGFloat
|
|
201
202
|
private var backdropTap: UITapGestureRecognizer?
|
|
203
|
+
private var dimmingView: UIView?
|
|
202
204
|
|
|
203
205
|
init(
|
|
204
206
|
host: NativeSheetContainerView,
|
|
@@ -206,7 +208,8 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
206
208
|
backgroundColor: UIColor,
|
|
207
209
|
cornerRadius: CGFloat,
|
|
208
210
|
showHandle: Bool,
|
|
209
|
-
dismissOnBackdropPress: Bool
|
|
211
|
+
dismissOnBackdropPress: Bool,
|
|
212
|
+
dimAmount: CGFloat
|
|
210
213
|
) {
|
|
211
214
|
self.host = host
|
|
212
215
|
self.lockedHeight = height
|
|
@@ -214,6 +217,7 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
214
217
|
self.cornerRadiusValue = cornerRadius
|
|
215
218
|
self.showHandleValue = showHandle
|
|
216
219
|
self.dismissOnBackdropPressValue = dismissOnBackdropPress
|
|
220
|
+
self.dimAmountValue = min(max(dimAmount, 0), 1)
|
|
217
221
|
super.init(nibName: nil, bundle: nil)
|
|
218
222
|
modalPresentationStyle = .pageSheet
|
|
219
223
|
}
|
|
@@ -231,6 +235,7 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
deinit {
|
|
238
|
+
dimmingView?.removeFromSuperview()
|
|
234
239
|
if isViewLoaded {
|
|
235
240
|
host.detachTouchHandler(from: view)
|
|
236
241
|
}
|
|
@@ -247,6 +252,7 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
247
252
|
},
|
|
248
253
|
]
|
|
249
254
|
sheet.selectedDetentIdentifier = identifier
|
|
255
|
+
sheet.largestUndimmedDetentIdentifier = identifier
|
|
250
256
|
sheet.prefersGrabberVisible = showHandleValue
|
|
251
257
|
sheet.preferredCornerRadius = cornerRadiusValue
|
|
252
258
|
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
|
|
@@ -258,6 +264,7 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
258
264
|
|
|
259
265
|
override func viewDidAppear(_ animated: Bool) {
|
|
260
266
|
super.viewDidAppear(animated)
|
|
267
|
+
installDimmingView()
|
|
261
268
|
guard dismissOnBackdropPressValue,
|
|
262
269
|
backdropTap == nil,
|
|
263
270
|
let container = presentationController?.containerView else {
|
|
@@ -270,6 +277,12 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
270
277
|
backdropTap = recognizer
|
|
271
278
|
}
|
|
272
279
|
|
|
280
|
+
override func viewDidDisappear(_ animated: Bool) {
|
|
281
|
+
super.viewDidDisappear(animated)
|
|
282
|
+
dimmingView?.removeFromSuperview()
|
|
283
|
+
dimmingView = nil
|
|
284
|
+
}
|
|
285
|
+
|
|
273
286
|
override func viewDidLayoutSubviews() {
|
|
274
287
|
super.viewDidLayoutSubviews()
|
|
275
288
|
host.layoutPresentedContent(in: view.bounds)
|
|
@@ -293,6 +306,19 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
293
306
|
guard recognizer.state == .ended else { return }
|
|
294
307
|
NativeSheetPresentationCoordinator.shared.dismiss(host, reason: "backdrop", animated: true)
|
|
295
308
|
}
|
|
309
|
+
|
|
310
|
+
private func installDimmingView() {
|
|
311
|
+
guard dimmingView == nil,
|
|
312
|
+
let container = presentationController?.containerView else {
|
|
313
|
+
return
|
|
314
|
+
}
|
|
315
|
+
let dimmingView = UIView(frame: container.bounds)
|
|
316
|
+
dimmingView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
317
|
+
dimmingView.backgroundColor = UIColor.black.withAlphaComponent(dimAmountValue)
|
|
318
|
+
dimmingView.isUserInteractionEnabled = false
|
|
319
|
+
container.insertSubview(dimmingView, at: 0)
|
|
320
|
+
self.dimmingView = dimmingView
|
|
321
|
+
}
|
|
296
322
|
}
|
|
297
323
|
|
|
298
324
|
@objc final class NativeSheetContainerView: UIView {
|
|
@@ -390,7 +416,8 @@ private final class NativeSheetViewController: UIViewController,
|
|
|
390
416
|
backgroundColor: sheetBackgroundColor ?? .systemBackground,
|
|
391
417
|
cornerRadius: max(cornerRadius, 0),
|
|
392
418
|
showHandle: showHandle,
|
|
393
|
-
dismissOnBackdropPress: dismissOnBackdropPress
|
|
419
|
+
dismissOnBackdropPress: dismissOnBackdropPress,
|
|
420
|
+
dimAmount: dimAmount
|
|
394
421
|
)
|
|
395
422
|
presentedController = controller
|
|
396
423
|
return controller
|
package/package.json
CHANGED