@lodev09/react-native-true-sheet 2.0.6 → 4.0.0-beta.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 +36 -8
- package/RNTrueSheet.podspec +20 -0
- package/android/build.gradle +26 -14
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +108 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +46 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +47 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterViewManager.kt +21 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +165 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +36 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +257 -303
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +855 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +104 -82
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +32 -0
- package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +27 -0
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +20 -0
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +26 -0
- package/android/src/main/java/com/lodev09/truesheet/{core/Utils.kt → utils/ScreenUtils.kt} +47 -17
- package/android/src/main/res/values/styles.xml +8 -0
- package/ios/TrueSheetComponentDescriptor.h +24 -0
- package/ios/TrueSheetContainerView.h +47 -0
- package/ios/TrueSheetContainerView.mm +117 -0
- package/ios/TrueSheetContentView.h +37 -0
- package/ios/TrueSheetContentView.mm +114 -0
- package/ios/TrueSheetFooterView.h +27 -0
- package/ios/TrueSheetFooterView.mm +101 -0
- package/ios/TrueSheetModule.h +44 -0
- package/ios/TrueSheetModule.mm +133 -0
- package/ios/TrueSheetView.h +53 -0
- package/ios/TrueSheetView.mm +433 -0
- package/ios/TrueSheetViewController.h +53 -0
- package/ios/TrueSheetViewController.mm +649 -0
- package/ios/events/OnDetentChangeEvent.h +28 -0
- package/ios/events/OnDetentChangeEvent.mm +30 -0
- package/ios/events/OnDidDismissEvent.h +26 -0
- package/ios/events/OnDidDismissEvent.mm +25 -0
- package/ios/events/OnDidPresentEvent.h +28 -0
- package/ios/events/OnDidPresentEvent.mm +30 -0
- package/ios/events/OnDragBeginEvent.h +28 -0
- package/ios/events/OnDragBeginEvent.mm +30 -0
- package/ios/events/OnDragChangeEvent.h +28 -0
- package/ios/events/OnDragChangeEvent.mm +30 -0
- package/ios/events/OnDragEndEvent.h +28 -0
- package/ios/events/OnDragEndEvent.mm +30 -0
- package/ios/events/OnMountEvent.h +26 -0
- package/ios/events/OnMountEvent.mm +25 -0
- package/ios/events/OnPositionChangeEvent.h +29 -0
- package/ios/events/OnPositionChangeEvent.mm +32 -0
- package/ios/events/OnSizeChangeEvent.h +28 -0
- package/ios/events/OnSizeChangeEvent.mm +30 -0
- package/ios/events/OnWillDismissEvent.h +26 -0
- package/ios/events/OnWillDismissEvent.mm +25 -0
- package/ios/events/OnWillPresentEvent.h +28 -0
- package/ios/events/OnWillPresentEvent.mm +30 -0
- package/ios/utils/GestureUtil.h +25 -0
- package/ios/utils/GestureUtil.mm +26 -0
- package/ios/utils/LayoutUtil.h +44 -0
- package/ios/utils/LayoutUtil.mm +50 -0
- package/ios/utils/WindowUtil.h +27 -0
- package/ios/utils/WindowUtil.mm +42 -0
- package/lib/module/TrueSheet.js +231 -135
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheetGrabber.js +16 -14
- package/lib/module/TrueSheetGrabber.js.map +1 -1
- package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +63 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.js +87 -0
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +72 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -0
- package/lib/module/reanimated/index.js +6 -0
- package/lib/module/reanimated/index.js.map +1 -0
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.js +19 -0
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.js.map +1 -0
- package/lib/module/specs/NativeTrueSheetModule.js +12 -0
- package/lib/module/specs/NativeTrueSheetModule.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/TrueSheet.d.ts +79 -0
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheet.types.d.ts +260 -0
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/TrueSheetGrabber.d.ts +1 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +44 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/{commonjs/src → src}/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts +43 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +57 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/index.d.ts +4 -0
- package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.d.ts +6 -0
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +34 -0
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -0
- package/package.json +104 -75
- package/react-native.config.js +17 -0
- package/src/TrueSheet.tsx +285 -188
- package/src/TrueSheet.types.ts +119 -106
- package/src/TrueSheetGrabber.tsx +29 -28
- package/src/__mocks__/index.js +60 -12
- package/src/fabric/TrueSheetContainerViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetContentViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetFooterViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +63 -0
- package/src/index.ts +4 -3
- package/src/reanimated/ReanimatedTrueSheet.tsx +95 -0
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +92 -0
- package/src/reanimated/index.ts +3 -0
- package/src/reanimated/useReanimatedPositionChangeHandler.ts +26 -0
- package/src/specs/NativeTrueSheetModule.ts +38 -0
- package/TrueSheet.podspec +0 -49
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetDialog.kt +0 -413
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetEvent.kt +0 -22
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewModule.kt +0 -63
- package/android/src/main/java/com/lodev09/truesheet/core/KeyboardManager.kt +0 -58
- package/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +0 -102
- package/ios/Extensions/UIBlurEffect+withTint.swift +0 -62
- package/ios/Extensions/UIView+pinTo.swift +0 -74
- package/ios/Extensions/UIViewController+detentForSize.swift +0 -134
- package/ios/TrueSheet-Bridging-Header.h +0 -14
- package/ios/TrueSheetEvent.swift +0 -48
- package/ios/TrueSheetView.swift +0 -467
- package/ios/TrueSheetViewController.swift +0 -275
- package/ios/TrueSheetViewManager.m +0 -53
- package/ios/TrueSheetViewManager.swift +0 -48
- package/ios/Utils/Logger.swift +0 -39
- package/ios/Utils/Promise.swift +0 -25
- package/lib/commonjs/TrueSheet.js +0 -258
- package/lib/commonjs/TrueSheet.js.map +0 -1
- package/lib/commonjs/TrueSheet.types.js +0 -6
- package/lib/commonjs/TrueSheet.types.js.map +0 -1
- package/lib/commonjs/TrueSheetFooter.js +0 -19
- package/lib/commonjs/TrueSheetFooter.js.map +0 -1
- package/lib/commonjs/TrueSheetGrabber.js +0 -54
- package/lib/commonjs/TrueSheetGrabber.js.map +0 -1
- package/lib/commonjs/TrueSheetModule.js +0 -19
- package/lib/commonjs/TrueSheetModule.js.map +0 -1
- package/lib/commonjs/__mocks__/index.js +0 -52
- package/lib/commonjs/__mocks__/index.js.map +0 -1
- package/lib/commonjs/index.js +0 -39
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/TrueSheetFooter.js +0 -14
- package/lib/module/TrueSheetFooter.js.map +0 -1
- package/lib/module/TrueSheetModule.js +0 -15
- package/lib/module/TrueSheetModule.js.map +0 -1
- package/lib/module/__mocks__/index.js +0 -21
- package/lib/module/__mocks__/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/TrueSheet.d.ts +0 -70
- package/lib/typescript/commonjs/src/TrueSheet.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheet.types.d.ts +0 -241
- package/lib/typescript/commonjs/src/TrueSheet.types.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheetFooter.d.ts +0 -7
- package/lib/typescript/commonjs/src/TrueSheetFooter.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheetGrabber.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/TrueSheetModule.d.ts +0 -2
- package/lib/typescript/commonjs/src/TrueSheetModule.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheet.d.ts +0 -70
- package/lib/typescript/module/src/TrueSheet.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheet.types.d.ts +0 -241
- package/lib/typescript/module/src/TrueSheet.types.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheetFooter.d.ts +0 -7
- package/lib/typescript/module/src/TrueSheetFooter.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/module/src/TrueSheetGrabber.d.ts.map +0 -1
- package/lib/typescript/module/src/TrueSheetModule.d.ts +0 -2
- package/lib/typescript/module/src/TrueSheetModule.d.ts.map +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -4
- package/lib/typescript/module/src/index.d.ts.map +0 -1
- package/src/TrueSheetFooter.tsx +0 -17
- package/src/TrueSheetModule.ts +0 -19
- /package/lib/{typescript/module → module}/package.json +0 -0
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
extension UIBlurEffect {
|
|
10
|
-
convenience init(with tint: String) {
|
|
11
|
-
var blurStyle: Style
|
|
12
|
-
|
|
13
|
-
switch tint {
|
|
14
|
-
case "default":
|
|
15
|
-
blurStyle = .regular
|
|
16
|
-
case "extraLight":
|
|
17
|
-
blurStyle = .extraLight
|
|
18
|
-
case "light":
|
|
19
|
-
blurStyle = .light
|
|
20
|
-
case "regular":
|
|
21
|
-
blurStyle = .regular
|
|
22
|
-
case "dark":
|
|
23
|
-
blurStyle = .dark
|
|
24
|
-
case "prominent":
|
|
25
|
-
blurStyle = .prominent
|
|
26
|
-
case "systemUltraThinMaterial":
|
|
27
|
-
blurStyle = .systemUltraThinMaterial
|
|
28
|
-
case "systemThinMaterial":
|
|
29
|
-
blurStyle = .systemThinMaterial
|
|
30
|
-
case "systemMaterial":
|
|
31
|
-
blurStyle = .systemMaterial
|
|
32
|
-
case "systemThickMaterial":
|
|
33
|
-
blurStyle = .systemThickMaterial
|
|
34
|
-
case "systemChromeMaterial":
|
|
35
|
-
blurStyle = .systemChromeMaterial
|
|
36
|
-
case "systemUltraThinMaterialLight":
|
|
37
|
-
blurStyle = .systemUltraThinMaterialLight
|
|
38
|
-
case "systemThickMaterialLight":
|
|
39
|
-
blurStyle = .systemThickMaterialLight
|
|
40
|
-
case "systemThinMaterialLight":
|
|
41
|
-
blurStyle = .systemThinMaterialLight
|
|
42
|
-
case "systemMaterialLight":
|
|
43
|
-
blurStyle = .systemMaterialLight
|
|
44
|
-
case "systemChromeMaterialLight":
|
|
45
|
-
blurStyle = .systemChromeMaterialLight
|
|
46
|
-
case "systemUltraThinMaterialDark":
|
|
47
|
-
blurStyle = .systemUltraThinMaterialDark
|
|
48
|
-
case "systemThinMaterialDark":
|
|
49
|
-
blurStyle = .systemThinMaterialDark
|
|
50
|
-
case "systemMaterialDark":
|
|
51
|
-
blurStyle = .systemMaterialDark
|
|
52
|
-
case "systemThickMaterialDark":
|
|
53
|
-
blurStyle = .systemThickMaterialDark
|
|
54
|
-
case "systemChromeMaterialDark":
|
|
55
|
-
blurStyle = .systemChromeMaterialDark
|
|
56
|
-
default:
|
|
57
|
-
blurStyle = .light
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
self.init(style: blurStyle)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
// MARK: - Constraints
|
|
10
|
-
|
|
11
|
-
struct Constraints {
|
|
12
|
-
var top: NSLayoutConstraint?
|
|
13
|
-
var bottom: NSLayoutConstraint?
|
|
14
|
-
var left: NSLayoutConstraint?
|
|
15
|
-
var right: NSLayoutConstraint?
|
|
16
|
-
var height: NSLayoutConstraint?
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
extension UIView {
|
|
20
|
-
/// Pin a view to the given view.
|
|
21
|
-
/// Optionally accepts a completion handler for the resulting constraints
|
|
22
|
-
func pinTo(
|
|
23
|
-
view: UIView,
|
|
24
|
-
from edges: UIRectEdge = .all,
|
|
25
|
-
with height: CGFloat? = nil,
|
|
26
|
-
constraints: ((Constraints) -> Void)?
|
|
27
|
-
) {
|
|
28
|
-
translatesAutoresizingMaskIntoConstraints = false
|
|
29
|
-
|
|
30
|
-
var topConstraint: NSLayoutConstraint?
|
|
31
|
-
var bottomConstraint: NSLayoutConstraint?
|
|
32
|
-
var leftConstraint: NSLayoutConstraint?
|
|
33
|
-
var rightConstraint: NSLayoutConstraint?
|
|
34
|
-
var heightConstraint: NSLayoutConstraint?
|
|
35
|
-
|
|
36
|
-
if edges.contains(.top) {
|
|
37
|
-
topConstraint = topAnchor.constraint(equalTo: view.topAnchor)
|
|
38
|
-
topConstraint?.isActive = true
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if edges.contains(.bottom) {
|
|
42
|
-
bottomConstraint = bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
|
43
|
-
bottomConstraint?.isActive = true
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if edges.contains(.left) {
|
|
47
|
-
leftConstraint = leadingAnchor.constraint(equalTo: view.leadingAnchor)
|
|
48
|
-
leftConstraint?.isActive = true
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if edges.contains(.right) {
|
|
52
|
-
rightConstraint = trailingAnchor.constraint(equalTo: view.trailingAnchor)
|
|
53
|
-
rightConstraint?.isActive = true
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if let height {
|
|
57
|
-
heightConstraint = heightAnchor.constraint(equalToConstant: height)
|
|
58
|
-
heightConstraint?.isActive = true
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
constraints?(Constraints(
|
|
62
|
-
top: topConstraint,
|
|
63
|
-
bottom: bottomConstraint,
|
|
64
|
-
left: leftConstraint,
|
|
65
|
-
right: rightConstraint,
|
|
66
|
-
height: heightConstraint
|
|
67
|
-
))
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
func unpin() {
|
|
71
|
-
translatesAutoresizingMaskIntoConstraints = true
|
|
72
|
-
removeConstraints(constraints)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
@available(iOS 15.0, *)
|
|
10
|
-
extension UISheetPresentationController.Detent.Identifier {
|
|
11
|
-
static let small = UISheetPresentationController.Detent.Identifier("small")
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@available(iOS 15.0, *)
|
|
15
|
-
extension UIViewController {
|
|
16
|
-
private func minValue(_ x: CGFloat?, _ maxHeight: CGFloat?) -> CGFloat {
|
|
17
|
-
let x = x ?? 0
|
|
18
|
-
guard let maxHeight else {
|
|
19
|
-
return x
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return min(x, maxHeight)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private func detentFor(identifier: UISheetPresentationController.Detent.Identifier,
|
|
26
|
-
with maxHeight: CGFloat?,
|
|
27
|
-
_ resolution: @escaping (CGFloat) -> Void) -> UISheetPresentationController.Detent {
|
|
28
|
-
switch identifier {
|
|
29
|
-
case .large:
|
|
30
|
-
if #available(iOS 16.0, *) {
|
|
31
|
-
return .custom(identifier: .large) { context in
|
|
32
|
-
let value = self.minValue(UISheetPresentationController.Detent.large().resolvedValue(in: context), maxHeight)
|
|
33
|
-
resolution(value)
|
|
34
|
-
return value
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
resolution(view.frame.height)
|
|
38
|
-
return .large()
|
|
39
|
-
}
|
|
40
|
-
case .medium:
|
|
41
|
-
if #available(iOS 16.0, *) {
|
|
42
|
-
return .custom(identifier: .medium) { context in
|
|
43
|
-
let value = self.minValue(UISheetPresentationController.Detent.medium().resolvedValue(in: context), maxHeight)
|
|
44
|
-
resolution(value)
|
|
45
|
-
return value
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
case .small:
|
|
49
|
-
if #available(iOS 16.0, *) {
|
|
50
|
-
return .custom { context in
|
|
51
|
-
let value = self.minValue(0.25 * context.maximumDetentValue, maxHeight)
|
|
52
|
-
resolution(value)
|
|
53
|
-
return value
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
default:
|
|
57
|
-
break
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
resolution(view.frame.height / 2)
|
|
61
|
-
return .medium()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/// Get the custom detent based on the given size and view frame size
|
|
65
|
-
func detentFor(_ anySize: Any,
|
|
66
|
-
with height: CGFloat?,
|
|
67
|
-
with maxHeight: CGFloat?,
|
|
68
|
-
_ resolution: @escaping (String, CGFloat) -> Void) -> UISheetPresentationController.Detent {
|
|
69
|
-
let id = "custom-\(anySize)"
|
|
70
|
-
|
|
71
|
-
if let floatSize = anySize as? CGFloat {
|
|
72
|
-
if #available(iOS 16.0, *) {
|
|
73
|
-
return .custom(identifier: identifier(from: id)) { context in
|
|
74
|
-
let value = min(floatSize, self.minValue(context.maximumDetentValue, maxHeight))
|
|
75
|
-
resolution(id, value)
|
|
76
|
-
return value
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
return detentFor(identifier: .medium, with: maxHeight) { value in
|
|
80
|
-
resolution(id, value)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if var stringSize = anySize as? String {
|
|
86
|
-
switch stringSize {
|
|
87
|
-
case "small":
|
|
88
|
-
return detentFor(identifier: .small, with: maxHeight) { value in
|
|
89
|
-
resolution(UISheetPresentationController.Detent.Identifier.small.rawValue, value)
|
|
90
|
-
}
|
|
91
|
-
case "medium":
|
|
92
|
-
return detentFor(identifier: .medium, with: maxHeight) { value in
|
|
93
|
-
resolution(UISheetPresentationController.Detent.Identifier.medium.rawValue, value)
|
|
94
|
-
}
|
|
95
|
-
case "large":
|
|
96
|
-
return detentFor(identifier: .large, with: maxHeight) { value in
|
|
97
|
-
resolution(UISheetPresentationController.Detent.Identifier.large.rawValue, value)
|
|
98
|
-
}
|
|
99
|
-
default:
|
|
100
|
-
if #available(iOS 16.0, *) {
|
|
101
|
-
if stringSize == "auto" {
|
|
102
|
-
return .custom(identifier: identifier(from: id)) { context in
|
|
103
|
-
let value = min(height ?? context.maximumDetentValue / 2, self.minValue(context.maximumDetentValue, maxHeight))
|
|
104
|
-
resolution(id, value)
|
|
105
|
-
return value
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
// Percent
|
|
109
|
-
stringSize.removeAll(where: { $0 == "%" })
|
|
110
|
-
let floatSize = CGFloat((stringSize as NSString).floatValue)
|
|
111
|
-
if floatSize > 0.0 {
|
|
112
|
-
return .custom(identifier: identifier(from: id)) { context in
|
|
113
|
-
let value = min((floatSize / 100) * context.maximumDetentValue, self.minValue(context.maximumDetentValue, maxHeight))
|
|
114
|
-
resolution(id, value)
|
|
115
|
-
return value
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
return detentFor(identifier: .medium, with: maxHeight) { value in
|
|
121
|
-
resolution(id, value)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
resolution(id, view.frame.height / 2)
|
|
128
|
-
return .medium()
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
func identifier(from id: String) -> UISheetPresentationController.Detent.Identifier {
|
|
132
|
-
return UISheetPresentationController.Detent.Identifier(id)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <React/RCTBridgeModule.h>
|
|
10
|
-
#import <React/RCTViewManager.h>
|
|
11
|
-
#import <React/RCTUIManager.h>
|
|
12
|
-
#import <React/RCTTouchHandler.h>
|
|
13
|
-
#import <React/RCTSurfaceTouchHandler.h>
|
|
14
|
-
#import <React/RCTScrollView.h>
|
package/ios/TrueSheetEvent.swift
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Created by Jovanni Lo (@lodev09)
|
|
3
|
-
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This source code is licensed under the MIT license found in the
|
|
6
|
-
// LICENSE file in the root directory of this source tree.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
class TrueSheetEvent: NSObject, RCTEvent {
|
|
10
|
-
var viewTag: NSNumber
|
|
11
|
-
|
|
12
|
-
private var name: String
|
|
13
|
-
private var data: [String: Any]?
|
|
14
|
-
|
|
15
|
-
var eventName: String {
|
|
16
|
-
return name
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var coalescingKey: UInt16 {
|
|
20
|
-
return 0
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
init(viewTag: NSNumber, name: String, data: [String: Any]?) {
|
|
24
|
-
self.name = name
|
|
25
|
-
self.viewTag = viewTag
|
|
26
|
-
self.data = data
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static func moduleDotMethod() -> String {
|
|
30
|
-
return "RCTEventEmitter.receiveEvent"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
func arguments() -> [Any] {
|
|
34
|
-
return [
|
|
35
|
-
viewTag,
|
|
36
|
-
RCTNormalizeInputEventName(eventName)!,
|
|
37
|
-
data ?? [:],
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
func canCoalesce() -> Bool {
|
|
42
|
-
return true
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
func coalesce(with newEvent: RCTEvent) -> RCTEvent {
|
|
46
|
-
return newEvent
|
|
47
|
-
}
|
|
48
|
-
}
|