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,262 @@
1
+ // Copyright © 2021 Lunabee Studio
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // BottomSheetController+Behavior.swift
16
+ // LBBottomSheet
17
+ //
18
+ // Created by Lunabee Studio / Date - 12/10/2021 - for the LBBottomSheet Swift Package.
19
+ //
20
+
21
+ import UIKit
22
+
23
+ extension BottomSheetController {
24
+ /// Struct used to define the behavior of a BottomSheetController.
25
+ public struct Behavior {
26
+ /// An enum describing the available swipe modes.
27
+ /// It impacts the way the swipe down gesture is detected.
28
+ public enum SwipeMode {
29
+ /// Swipe down only detected from the grabber zone. (the top of the bottom sheet)
30
+ case top
31
+ /// Swipe down detected from the whole bottom sheet.
32
+ case full
33
+ /// Swipe down gesture blocked to prevent bottom sheet dismissal.
34
+ case none
35
+ }
36
+
37
+ /// An enum describing the available height modes.
38
+ public enum HeightMode {
39
+ /// The bottom sheet will call `preferredHeightInBottomSheet` on the embedded controller to get the needed height.
40
+ ///
41
+ /// If `preferredHeightInBottomSheet` is not declared on the embedded controller, the BottomSheet will calculate a default height to use based on the embedded controller content: if there is a tableView or a collectionView it will use the content size and content insets, otherwise it will use the first view height. If this calculation returns 0 as the height, 75% of the screen height will be used instead.
42
+ /// To declare the preferred height, add this to your embedded controller:
43
+ /// ```swift
44
+ /// @objc var preferredHeightInBottomSheet: CGFloat { /* Do you custom calculation here */ }
45
+ /// ```
46
+ /// - Parameters:
47
+ /// - heightLimit: The height limit the bottom sheet must not exceed.
48
+ case fitContent(heightLimit: HeightLimit = .navigationBar)
49
+ /// The bottom sheet height will be contained between `minHeight` and `maxHeight` and the bottom sheet will remain where the user releases it.
50
+ /// - Parameters:
51
+ /// - minHeight: The minimum height to use for the bottom sheet.
52
+ /// - maxHeight: The maximum height to use for the bottom sheet.
53
+ /// - heightLimit: The height limit the bottom sheet must not exceed.
54
+ case free(minHeight: CGFloat? = nil, maxHeight: CGFloat? = nil, heightLimit: HeightLimit = .navigationBar)
55
+ /// The bottom sheet will have multiple height values. When the user releases it, it will be attached to the nearest provided specific value.
56
+ /// When presented, the bottom sheet will use the minimum value. It can be swipped up to the maximum value. You don't have to take care of the values order, the bottom sheet will sort them to find the matching one.
57
+ /// - Parameters:
58
+ /// - values: An array of `HeightValue` values to use with the bottom sheet if we need to manage multiple positions.
59
+ /// - heightLimit: The height limit the bottom sheet must not exceed.
60
+ case specific(values: [HeightValue], heightLimit: HeightLimit = .navigationBar)
61
+
62
+ internal func minimumHeight(with childHeight: CGFloat, screenHeight: CGFloat) -> CGFloat {
63
+ switch self {
64
+ case .fitContent:
65
+ return max(childHeight, 0.0)
66
+ case let .free(minHeight , _, _):
67
+ return minHeight ?? 0.0
68
+ case let .specific(values, _):
69
+ return values.sortedPointValues(screenHeight: screenHeight, childHeight: childHeight).first ?? 0.0
70
+ }
71
+ }
72
+
73
+ internal func maximumHeight(with childHeight: CGFloat, screenHeight: CGFloat, from controller: UIViewController) -> CGFloat {
74
+ switch self {
75
+ case let .fitContent(heightLimit):
76
+ return min(childHeight, heightLimit.value(from: controller, screenHeight: screenHeight))
77
+ case let .free(_ , maxHeight, heightLimit):
78
+ let maxHeightLimit: CGFloat = heightLimit.value(from: controller, screenHeight: screenHeight)
79
+ guard let maxHeight = maxHeight else { return maxHeightLimit }
80
+ return min(maxHeight, maxHeightLimit)
81
+ case let .specific(values, heightLimit):
82
+ let maxHeightLimit: CGFloat = heightLimit.value(from: controller, screenHeight: screenHeight)
83
+ guard let maxHeight = values.sortedPointValues(screenHeight: screenHeight, childHeight: childHeight).map({ min($0, maxHeightLimit) }).last else { return maxHeightLimit }
84
+ return min(maxHeight, maxHeightLimit)
85
+ }
86
+ }
87
+
88
+ internal func nextHeight(with childHeight: CGFloat, screenHeight: CGFloat, from controller: UIViewController, originHeight: CGFloat, goingUp: Bool) -> CGFloat? {
89
+ switch self {
90
+ case let .specific(values, heightLimit):
91
+ let maxHeightLimit: CGFloat = heightLimit.value(from: controller, screenHeight: screenHeight)
92
+ let allValues: [CGFloat] = values.sortedPointValues(screenHeight: screenHeight, childHeight: childHeight)
93
+ .map { min($0, maxHeightLimit) }
94
+ guard let currentIndex = allValues.firstIndex(of: originHeight) ?? (originHeight == maxHeightLimit ? allValues.count - 1 : nil) else { return nil }
95
+ let newIndex: Int = goingUp ? currentIndex + 1 : currentIndex - 1
96
+ return newIndex < 0 ? nil : min(allValues[min(newIndex, allValues.count - 1)], heightLimit.value(from: controller, screenHeight: screenHeight))
97
+ default:
98
+ return goingUp ? maximumHeight(with: childHeight, screenHeight: screenHeight, from: controller) : minimumHeight(with: childHeight, screenHeight: screenHeight)
99
+ }
100
+ }
101
+ }
102
+
103
+ /// An enum describing the available height values for the `specific` HeightMode.
104
+ public enum HeightValue {
105
+ /// Defines an arbitrary height in points.
106
+ /// - Parameters:
107
+ /// - value: The absolute height value in points.
108
+ case fixed(value: CGFloat)
109
+ /// Defines a height being a ratio of the screen height.
110
+ /// - Parameters:
111
+ /// - value: A percentage (between 0.0 and 1.0) that will be applied to the screen height to determine the bottom sheet height.
112
+ case screenRatio(value: CGFloat)
113
+ /// Defines a height being a ratio of the embedded controller `preferredHeightInBottomSheet` value.
114
+ /// - Parameters:
115
+ /// - value: A percentage (between 0.0 and 1.0) that will be applied to the height of the controller embedded in the bottom sheet.
116
+ case childRatio(value: CGFloat)
117
+ /// Defines a height value being calculated by the given block.
118
+ /// - Parameters:
119
+ /// - heightBlock: A block that must return the needed height.
120
+ case custom(_ heightBlock: () -> CGFloat)
121
+
122
+ /// This is a shortcut allowing you to have in your specific values, one matching the embedded controller `preferredHeightInBottomSheet` value.
123
+ public static let fitContent: HeightValue = .childRatio(value: 1.0)
124
+ /// This is a shortcut allowing you to have in your specific values, one matching the full screen height.
125
+ public static let fullscreen: HeightValue = .screenRatio(value: 1.0)
126
+ }
127
+
128
+ /// An enum describing the available bottom sheet height limits.
129
+ public enum HeightLimit {
130
+ /// The bottom sheet height limit will be the bottom of the navigation bar behind the bottom sheet.
131
+ /// If there is no navigation controller behind the bottom sheet, this is equivalent to <doc:LBBottomSheet/BottomSheetController/Behavior-swift.struct/HeightLimit/statusBar>.
132
+ case navigationBar
133
+ /// The bottom sheet height limit will be the bottom of the status bar.
134
+ case statusBar
135
+ /// The bottom sheet height limit will be the top of the screen.
136
+ case screen
137
+
138
+ func value(from controller: UIViewController, screenHeight: CGFloat) -> CGFloat {
139
+ switch self {
140
+ case .navigationBar:
141
+ return screenHeight - controller.lbbsRearControllerTopInset()
142
+ case .statusBar:
143
+ return screenHeight - controller.lbbsRearControllerTopInset(includeNavigationBar: false)
144
+ case .screen:
145
+ return screenHeight
146
+ }
147
+ }
148
+ }
149
+
150
+ /// A struct definig custom animation configuration parameters to be used to animate the bottom sheet when it's position is updated.
151
+ public struct BottomSheetAnimationConfiguration {
152
+ /// The duration of the animation.
153
+ public let duration: CGFloat
154
+ /// The spring damping of the animation.
155
+ public let damping: CGFloat
156
+ /// The spring initial velocity of the animation.
157
+ public let velocity: CGFloat
158
+ /// The extra animation options to use.
159
+ public let options: [UIView.AnimationOptions]
160
+
161
+ /// Initializes a new BottomSheetAnimationConfiguration.
162
+ public init(duration: CGFloat, damping: CGFloat, velocity: CGFloat, options: [UIView.AnimationOptions]) {
163
+ self.duration = duration
164
+ self.damping = damping
165
+ self.velocity = velocity
166
+ self.options = options
167
+ }
168
+ }
169
+
170
+ /// Custom animation configuration used to animate the bottom sheet when it is appearing.
171
+ public var appearingAnimationConfiguration: BottomSheetAnimationConfiguration?
172
+ /// Custom animation configuration used to animate the bottom sheet when it is disappearing.
173
+ public var disappearingAnimationConfiguration: BottomSheetAnimationConfiguration?
174
+ /// Custom animation configuration used to animate the bottom sheet when it's position is updated.
175
+ public var bottomSheetAnimationConfiguration: BottomSheetAnimationConfiguration?
176
+ /// Defines how the bottom sheet is swippable.
177
+ public var swipeMode: SwipeMode = .full
178
+ /// Defines whether or not the touch events detected out of the bottom sheet should be forwarded
179
+ /// to the view behind the bottom sheet.
180
+ public var forwardEventsToRearController: Bool = false
181
+ /// Defines the percentage of the bottom sheet height that should be swipped down to dismiss it when releasing it
182
+ /// instead of putting it back to its previous position.
183
+ public var heightPercentageThresholdToDismiss: CGFloat = 0.5
184
+ /// The minimum velocity (in points/second) when swipping the bottom sheet down to dismiss it when released,
185
+ /// even if `heightPercentageThresholdToDismiss` was not reached.
186
+ public var velocityThresholdToDismiss: CGFloat = 700
187
+ /// The minimum velocity (in points/second) when swipping the bottom sheet up to open it at its maximum height.
188
+ public var velocityThresholdToOpenAtMaxHeight: CGFloat = 700
189
+ /// The mode used to calculate the bottom sheet height.
190
+ public var heightMode: HeightMode = .fitContent() {
191
+ didSet {
192
+ switch heightMode {
193
+ case let .specific(values, _):
194
+ guard !values.isEmpty else { fatalError("❌ [LBBottomSheet] ❌: You must provide an HeightValue array containing at least one value for the specific HeightMode.") }
195
+ default:
196
+ break
197
+ }
198
+ }
199
+ }
200
+ /// This is a block allowing you to customize how the elasticity effect is calculated (when you are trying to swipe the BottomSheetController view up, above its maximum height).
201
+ public var elasticityFunction: (_ x: CGFloat) -> CGFloat
202
+ /// Defines whether or not the bottom sheet layout will be updated when the user changes the iOS font size.
203
+ ///
204
+ /// As your embedded controller height might be impacted by a font size change, the bottom sheet will update its height too if you use a <doc:LBBottomSheet/BottomSheetController/Behavior-swift.struct/HeightMode-swift.enum> depending on the embedded controller height.
205
+ ///
206
+ /// If you don't use a <doc:LBBottomSheet/BottomSheetController/Behavior-swift.struct/HeightMode-swift.enum> depending on the embedded controller height, nothing will happen.
207
+ public var updateHeightOnContentSizeCategoryChange: Bool
208
+ /// Defines whether or not the bottom sheet can be dismissed. If set to `false`, it allows the bottom sheet to still be animated while swipping if the <doc:LBBottomSheet/BottomSheetController/Behavior-swift.struct/swipeMode-swift.property> is different from <doc:LBBottomSheet/BottomSheetController/Behavior-swift.struct/SwipeMode-swift.enum/none>.
209
+ public var allowsSwipeToDismiss: Bool
210
+ /// Defines whether or not the bottom sheet can be dismissed by touching the dimming background.
211
+ public var canTouchDimmingBackgroundToDismiss: Bool
212
+
213
+ /// Initializes a new Behavior.
214
+ public init(appearingAnimationConfiguration: BottomSheetAnimationConfiguration? = nil,
215
+ disappearingAnimationConfiguration: BottomSheetAnimationConfiguration? = nil,
216
+ bottomSheetAnimationConfiguration: BottomSheetAnimationConfiguration? = nil,
217
+ swipeMode: BottomSheetController.Behavior.SwipeMode = .full,
218
+ forwardEventsToRearController: Bool = false,
219
+ heightPercentageThresholdToDismiss: CGFloat = 0.5,
220
+ velocityThresholdToDismiss: CGFloat = 700,
221
+ velocityThresholdToOpenAtMaxHeight: CGFloat = 700,
222
+ shouldShowAboveNavigationBar: Bool = false,
223
+ heightMode: BottomSheetController.Behavior.HeightMode = .fitContent(),
224
+ elasticityFunction: @escaping (CGFloat) -> CGFloat = BottomSheetConstant.Animation.Elasticity.logarithmic,
225
+ updateHeightOnContentSizeCategoryChange: Bool = true,
226
+ allowsSwipeToDismiss: Bool = true,
227
+ canTouchDimmingBackgroundToDismiss: Bool = true) {
228
+ self.appearingAnimationConfiguration = appearingAnimationConfiguration
229
+ self.disappearingAnimationConfiguration = disappearingAnimationConfiguration
230
+ self.bottomSheetAnimationConfiguration = bottomSheetAnimationConfiguration
231
+ self.swipeMode = swipeMode
232
+ self.forwardEventsToRearController = forwardEventsToRearController
233
+ self.heightPercentageThresholdToDismiss = heightPercentageThresholdToDismiss
234
+ self.velocityThresholdToDismiss = velocityThresholdToDismiss
235
+ self.velocityThresholdToOpenAtMaxHeight = velocityThresholdToOpenAtMaxHeight
236
+ self.heightMode = heightMode
237
+ self.elasticityFunction = elasticityFunction
238
+ self.updateHeightOnContentSizeCategoryChange = updateHeightOnContentSizeCategoryChange
239
+ self.allowsSwipeToDismiss = allowsSwipeToDismiss
240
+ self.canTouchDimmingBackgroundToDismiss = canTouchDimmingBackgroundToDismiss
241
+ }
242
+ }
243
+ }
244
+
245
+ extension Array where Element == BottomSheetController.Behavior.HeightValue {
246
+
247
+ internal func sortedPointValues(screenHeight: CGFloat, childHeight: CGFloat) -> [CGFloat] {
248
+ map {
249
+ switch $0 {
250
+ case let .fixed(value):
251
+ return Swift.min(Swift.max(value, 0.0), screenHeight)
252
+ case let .screenRatio(value):
253
+ return screenHeight * Swift.min(Swift.max(value, 0.0), 1.0)
254
+ case let .childRatio(value):
255
+ return childHeight * Swift.min(Swift.max(value, 0.0), 1.0)
256
+ case let .custom(block):
257
+ return block()
258
+ }
259
+ }.sorted()
260
+ }
261
+
262
+ }
@@ -0,0 +1,156 @@
1
+ // Copyright © 2021 Lunabee Studio
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // BottomSheetController+Theme.swift
16
+ // LBBottomSheet
17
+ //
18
+ // Created by Lunabee Studio / Date - 12/10/2021 - for the LBBottomSheet Swift Package.
19
+ //
20
+
21
+ import UIKit
22
+
23
+ extension BottomSheetController {
24
+ /// Struct used to define the theme of a BottomSheetController.
25
+ public struct Theme {
26
+ /// Struct used to represent a grabber that can be added to a BottomSheetControllerTheme.
27
+ /// It will be visible at the top of the BottomSheetController.
28
+ /// ![Grabber](Grabber)
29
+ public struct Grabber {
30
+ /// An enum describing the available background types for the Grabber.
31
+ /// ![GrabberBackground](GrabberBackground)
32
+ public enum Background {
33
+ /// Use a simple color as the grabber "zone" background.
34
+ /// - Parameters:
35
+ /// - color: The color to use as the grabber "zone" background.
36
+ /// - isTranslucent: If `true`, the embedded view will be extended under the grabber "zone". Otherwise, the embedded view will have its top starting at the bottom of the grabber "zone".
37
+ case color(_ color: UIColor = .clear, isTranslucent: Bool = true)
38
+ /// Use a custom view as the grabber "zone" background.
39
+ /// - Parameters:
40
+ /// - view: The view to insert as the grabber "zone" background.
41
+ /// - isTranslucent: If `true`, the embedded view will be extended under the grabber "zone". Otherwise, the embedded view will have its top starting at the bottom of the grabber "zone".
42
+ case view(_ view: UIView, isTranslucent: Bool)
43
+
44
+ /// This is a shorcut to easily know if the background is translucent or not.
45
+ public var isTranslucent: Bool {
46
+ switch self {
47
+ case .color(_, let isTranslucent), .view(_, let isTranslucent):
48
+ return isTranslucent
49
+ }
50
+ }
51
+ }
52
+
53
+ /// An enum describing the available corner radius types.
54
+ public enum CornerRadiusType {
55
+ /// The grabber corner radius will be the height of the grabber devided by 2.
56
+ case rounded
57
+ /// The grabber corner redius will be the given value.
58
+ /// - Parameters:
59
+ /// - value: The corner radius value.
60
+ case fixed(_ value: CGFloat)
61
+ }
62
+ /// A Grabber configured to look like the Apple one.
63
+ public static let appleDefault: Grabber = .init(size: CGSize(width: 36.0, height: 5.0),
64
+ color: .lbbsDefaultGrabberColor,
65
+ topMargin: 5.0)
66
+ /// The size of the grabber.
67
+ public var size: CGSize
68
+ /// Defines whether or not the grabber shoiuld have a corner radius.
69
+ public var cornerRadiusType: CornerRadiusType
70
+ /// These are the corners to apply the radius to.
71
+ public var maskedCorners: CACornerMask
72
+ /// The grabber color.
73
+ public var color: UIColor
74
+ /// The margin between the grabber top and the top of the BottomSheetController view.
75
+ public var topMargin: CGFloat
76
+ /// Defines whether or not the BottomSheetController should be dismissed when tapping the grabber.
77
+ public var canTouchToDismiss: Bool
78
+ /// The background to use behind the grabber. By default it is transparent.
79
+ public var background: Background
80
+
81
+ /// Initializes a new Grabber.
82
+ public init(size: CGSize = CGSize(width: 30.0, height: 4.0),
83
+ cornerRadiusType: BottomSheetController.Theme.Grabber.CornerRadiusType = .rounded,
84
+ maskedCorners: CACornerMask = .lbbsAll,
85
+ color: UIColor = .lbbsDefaultGrabberColor,
86
+ topMargin: CGFloat = 20.0,
87
+ canTouchToDismiss: Bool = false,
88
+ background: BottomSheetController.Theme.Grabber.Background = .color()) {
89
+ self.size = size
90
+ self.cornerRadiusType = cornerRadiusType
91
+ self.maskedCorners = maskedCorners
92
+ self.color = color
93
+ self.topMargin = topMargin
94
+ self.canTouchToDismiss = canTouchToDismiss
95
+ self.background = background
96
+ }
97
+ }
98
+
99
+ /// Struct used to represent a shadow that can be added to a BottomSheetControllerTheme.
100
+ /// It will then appear behind the top of the BottomSheetController.
101
+ /// ![Shadow](Shadow)
102
+ public struct Shadow {
103
+ /// The color of the shadow.
104
+ public var color: UIColor
105
+ /// The opacity of the shadow. Specifying a value outside the [0,1] range will give undefined results.
106
+ public var opacity: Float
107
+ /// The shadow offset.
108
+ public var offset: CGSize
109
+ /// The blur radius used to create the shadow.
110
+ public var radius: CGFloat
111
+
112
+ /// Initializes a new Shadow.
113
+ public init(color: UIColor = .lbbsDefaultShadowColor,
114
+ opacity: Float = 0.3,
115
+ offset: CGSize = .zero,
116
+ radius: CGFloat = 5) {
117
+ self.color = color
118
+ self.opacity = opacity
119
+ self.offset = offset
120
+ self.radius = radius
121
+ }
122
+ }
123
+
124
+ /// The BottomSheetController grabber.
125
+ public var grabber: Grabber?
126
+ /// This is the corner radius used for the masked corners of the BottomSheetController view.
127
+ public var cornerRadius: CGFloat
128
+ /// These are the corners to apply the radius to.
129
+ public var maskedCorners: CACornerMask
130
+ /// This is the background color to use all around the BottomSheetController view.
131
+ public var dimmingBackgroundColor: UIColor
132
+ /// The BottomSheetController shadow.
133
+ public var shadow: Shadow?
134
+ /// Leading margin to apply to the bottom sheet in case we don't want it being attached to the left screen edge.
135
+ public var leadingMargin: CGFloat
136
+ /// Trailing margin to apply to the bottom sheet in case we don't want it being attached to the right screen edge.
137
+ public var trailingMargin: CGFloat
138
+
139
+ /// Initializes a new Theme.
140
+ public init(grabber: BottomSheetController.Theme.Grabber? = Grabber(),
141
+ cornerRadius: CGFloat = 12.0,
142
+ maskedCorners: CACornerMask = .lbbsTop,
143
+ dimmingBackgroundColor: UIColor = .lbbsDefaultDimmingBackgroundColor,
144
+ shadow: BottomSheetController.Theme.Shadow? = Shadow(),
145
+ leadingMargin: CGFloat = 0.0,
146
+ trailingMargin: CGFloat = 0.0) {
147
+ self.grabber = grabber
148
+ self.cornerRadius = cornerRadius
149
+ self.maskedCorners = maskedCorners
150
+ self.dimmingBackgroundColor = dimmingBackgroundColor
151
+ self.shadow = shadow
152
+ self.leadingMargin = leadingMargin
153
+ self.trailingMargin = trailingMargin
154
+ }
155
+ }
156
+ }
@@ -0,0 +1,29 @@
1
+ // Copyright © 2021 Lunabee Studio
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // BottomSheetInteractionDelegate.swift
16
+ // LBBottomSheet
17
+ //
18
+ // Created by Lunabee Studio / Date - 12/05/2022 - for the LBBottomSheet Swift Package.
19
+ //
20
+
21
+ import UIKit
22
+
23
+ /// Implement this protocol to get bottom sheet user's interactions.
24
+ /// Only view controllers can implement this protocol.
25
+ public protocol BottomSheetInteractionDelegate: UIViewController {
26
+ /// This method is called when a tap is detected outside the bottom sheet (which makes it dimsissing).
27
+ /// This way you can run some custom actions when this will happen.
28
+ func bottomSheetInteractionDidTapOutside()
29
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright © 2021 Lunabee Studio
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // BottomSheetPositionDelegate.swift
16
+ // LBBottomSheet
17
+ //
18
+ // Created by Lunabee Studio / Date - 12/10/2021 - for the LBBottomSheet Swift Package.
19
+ //
20
+
21
+ import UIKit
22
+
23
+ /// Implement this protocol to dynamically get bottom sheet offset changes.
24
+ /// Only view controllers can implement this protocol.
25
+ public protocol BottomSheetPositionDelegate: UIViewController {
26
+ /// This method is called at each bottom sheet offset change during the layout process.
27
+ /// This way you can dynamically align the components being at the bottom of the controller behind the bottom sheet.
28
+ /// - Parameters:
29
+ /// - y: This is the vertical bottom sheet coordinate (0.0 behing the top of the screen).
30
+ func bottomSheetPositionDidUpdate(y: CGFloat)
31
+ }
@@ -0,0 +1,105 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="WvP-RB-0x8">
3
+ <device id="retina6_1" orientation="portrait" appearance="light"/>
4
+ <dependencies>
5
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
6
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
7
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
8
+ </dependencies>
9
+ <scenes>
10
+ <!--Bottom Sheet Controller-->
11
+ <scene sceneID="DZ3-Dd-2Gc">
12
+ <objects>
13
+ <viewController id="WvP-RB-0x8" customClass="BottomSheetController" customModule="react_native_sheet" sceneMemberID="viewController">
14
+ <view key="view" contentMode="scaleToFill" id="jPW-YG-3lE" customClass="ForwardingEventsView" customModule="react_native_sheet">
15
+ <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
16
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
17
+ <subviews>
18
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Urg-q5-UOH">
19
+ <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
20
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
21
+ <connections>
22
+ <action selector="dismissButtonPressed:" destination="WvP-RB-0x8" eventType="touchUpInside" id="5Ja-ZA-NGx"/>
23
+ </connections>
24
+ </button>
25
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gph-53-hRB">
26
+ <rect key="frame" x="0.0" y="796" width="414" height="100"/>
27
+ <subviews>
28
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Lbk-0u-Vbh">
29
+ <rect key="frame" x="0.0" y="0.0" width="414" height="100"/>
30
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
31
+ </view>
32
+ <view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Aad-Ol-Ucq">
33
+ <rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
34
+ <subviews>
35
+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ozq-tn-8fe" userLabel="Grabber">
36
+ <rect key="frame" x="192" y="20" width="30" height="4"/>
37
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
38
+ <constraints>
39
+ <constraint firstAttribute="height" constant="4" id="HZ4-dC-SVV"/>
40
+ <constraint firstAttribute="width" constant="30" id="wZB-x7-Nnc"/>
41
+ </constraints>
42
+ <userDefinedRuntimeAttributes>
43
+ <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
44
+ <integer key="value" value="2"/>
45
+ </userDefinedRuntimeAttribute>
46
+ </userDefinedRuntimeAttributes>
47
+ </view>
48
+ </subviews>
49
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
50
+ <constraints>
51
+ <constraint firstItem="Ozq-tn-8fe" firstAttribute="centerX" secondItem="Aad-Ol-Ucq" secondAttribute="centerX" id="FIN-KI-x2K"/>
52
+ <constraint firstItem="Ozq-tn-8fe" firstAttribute="centerY" secondItem="Aad-Ol-Ucq" secondAttribute="centerY" id="Wka-Kc-k9R"/>
53
+ <constraint firstItem="Ozq-tn-8fe" firstAttribute="top" secondItem="Aad-Ol-Ucq" secondAttribute="top" constant="20" id="n83-lS-sF2"/>
54
+ </constraints>
55
+ </view>
56
+ </subviews>
57
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
58
+ <constraints>
59
+ <constraint firstItem="Aad-Ol-Ucq" firstAttribute="top" secondItem="gph-53-hRB" secondAttribute="top" id="6qS-Ig-qCw"/>
60
+ <constraint firstItem="Lbk-0u-Vbh" firstAttribute="leading" secondItem="gph-53-hRB" secondAttribute="leading" id="Jdq-NA-1R9"/>
61
+ <constraint firstItem="Lbk-0u-Vbh" firstAttribute="top" secondItem="gph-53-hRB" secondAttribute="top" id="OkI-rN-h0g"/>
62
+ <constraint firstAttribute="bottom" secondItem="Lbk-0u-Vbh" secondAttribute="bottom" id="QDg-Ds-Adn"/>
63
+ <constraint firstAttribute="trailing" secondItem="Lbk-0u-Vbh" secondAttribute="trailing" id="RXX-FO-m5b"/>
64
+ <constraint firstAttribute="height" constant="100" id="d53-xy-0R6"/>
65
+ <constraint firstItem="Lbk-0u-Vbh" firstAttribute="top" secondItem="Aad-Ol-Ucq" secondAttribute="bottom" priority="999" id="p2y-aI-Ugk"/>
66
+ <constraint firstItem="Aad-Ol-Ucq" firstAttribute="leading" secondItem="gph-53-hRB" secondAttribute="leading" id="rdK-B7-BJF"/>
67
+ <constraint firstAttribute="trailing" secondItem="Aad-Ol-Ucq" secondAttribute="trailing" id="xVb-F7-EdN"/>
68
+ </constraints>
69
+ </view>
70
+ </subviews>
71
+ <viewLayoutGuide key="safeArea" id="Jqr-9a-dVD"/>
72
+ <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
73
+ <constraints>
74
+ <constraint firstAttribute="trailing" secondItem="Urg-q5-UOH" secondAttribute="trailing" id="6LG-DB-ijh"/>
75
+ <constraint firstAttribute="bottom" secondItem="gph-53-hRB" secondAttribute="bottom" id="SOl-oR-WRa"/>
76
+ <constraint firstItem="gph-53-hRB" firstAttribute="leading" secondItem="Jqr-9a-dVD" secondAttribute="leading" id="fMd-B3-vcy"/>
77
+ <constraint firstItem="Jqr-9a-dVD" firstAttribute="trailing" secondItem="gph-53-hRB" secondAttribute="trailing" id="gaY-pS-A5h"/>
78
+ <constraint firstItem="Urg-q5-UOH" firstAttribute="top" secondItem="jPW-YG-3lE" secondAttribute="top" id="mva-dB-CJJ"/>
79
+ <constraint firstItem="Urg-q5-UOH" firstAttribute="leading" secondItem="jPW-YG-3lE" secondAttribute="leading" id="oeg-zj-tAJ"/>
80
+ <constraint firstAttribute="bottom" secondItem="Urg-q5-UOH" secondAttribute="bottom" id="xF3-9L-edy"/>
81
+ </constraints>
82
+ </view>
83
+ <connections>
84
+ <outlet property="bottomContainerBottomConstraint" destination="SOl-oR-WRa" id="3F2-j2-2YO"/>
85
+ <outlet property="bottomContainerHeightConstraint" destination="d53-xy-0R6" id="cE7-JZ-J6r"/>
86
+ <outlet property="bottomContainerInnerView" destination="Lbk-0u-Vbh" id="K2p-Gq-Bwv"/>
87
+ <outlet property="bottomContainerInnerViewTopConstraint" destination="p2y-aI-Ugk" id="4nZ-9A-i9i"/>
88
+ <outlet property="bottomContainerInnerViewTranslucentTopConstraint" destination="OkI-rN-h0g" id="jql-Fj-xcz"/>
89
+ <outlet property="bottomContainerLeadingConstraint" destination="fMd-B3-vcy" id="nTs-0D-jfb"/>
90
+ <outlet property="bottomContainerTrailingConstraint" destination="gaY-pS-A5h" id="4C1-Uc-5uC"/>
91
+ <outlet property="bottomContainerView" destination="gph-53-hRB" id="Gb1-66-8bK"/>
92
+ <outlet property="gestureView" destination="Aad-Ol-Ucq" id="F55-8O-FzE"/>
93
+ <outlet property="grabberView" destination="Ozq-tn-8fe" id="HSc-IF-hwj"/>
94
+ <outlet property="heightGrabberConstraint" destination="HZ4-dC-SVV" id="ewb-6T-jb1"/>
95
+ <outlet property="mainDismissButton" destination="Urg-q5-UOH" id="7FZ-ow-i7r"/>
96
+ <outlet property="topGrabberConstraint" destination="n83-lS-sF2" id="Lpy-jd-zc3"/>
97
+ <outlet property="widthGrabberConstraint" destination="wZB-x7-Nnc" id="nNE-fq-dha"/>
98
+ </connections>
99
+ </viewController>
100
+ <placeholder placeholderIdentifier="IBFirstResponder" id="Lfa-Wz-4Iz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
101
+ </objects>
102
+ <point key="canvasLocation" x="-33.333333333333336" y="157.36607142857142"/>
103
+ </scene>
104
+ </scenes>
105
+ </document>