File tree 3 files changed +15
-9
lines changed
3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ final class BottomSheetPresentationController: UIPresentationController {
46
46
// MARK: - Private properties
47
47
48
48
private var contentHeights : [ CGFloat ]
49
- private let startTargetIndex : Int
49
+ private var startTargetIndex : Int
50
50
private let handleBackground : BottomSheetView . HandleBackground
51
51
private let useSafeAreaInsets : Bool
52
52
private let draggableHeight : CGFloat ?
@@ -93,9 +93,12 @@ final class BottomSheetPresentationController: UIPresentationController {
93
93
bottomSheetView? . reset ( )
94
94
}
95
95
96
- func reload( with contentHeights: [ CGFloat ] ) {
96
+ func reload( with contentHeights: [ CGFloat ] , targetIndex : Int ? ) {
97
97
self . contentHeights = contentHeights
98
- bottomSheetView? . reload ( with: contentHeights)
98
+ if let targetIndex = targetIndex {
99
+ startTargetIndex = targetIndex
100
+ }
101
+ bottomSheetView? . reload ( with: contentHeights, targetIndex: targetIndex)
99
102
}
100
103
101
104
func hideDimView( ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import UIKit
6
6
7
7
public final class BottomSheetTransitioningDelegate : NSObject {
8
8
public private( set) var contentHeights : [ CGFloat ]
9
- private let startTargetIndex : Int
9
+ private var startTargetIndex : Int
10
10
private let handleBackground : BottomSheetView . HandleBackground
11
11
private let draggableHeight : CGFloat ?
12
12
private let useSafeAreaInsets : Bool
@@ -62,8 +62,11 @@ public final class BottomSheetTransitioningDelegate: NSObject {
62
62
}
63
63
64
64
public func reload( with contentHeights: [ CGFloat ] ) {
65
+ let previousHeight = self . contentHeights [ safe: startTargetIndex] ?? 0
66
+ let indexOfPreviousHeightInNewHeights = contentHeights. firstIndex ( of: previousHeight) ?? 0
65
67
self . contentHeights = contentHeights
66
- presentationController? . reload ( with: contentHeights)
68
+ startTargetIndex = indexOfPreviousHeightInNewHeights
69
+ presentationController? . reload ( with: contentHeights, targetIndex: startTargetIndex)
67
70
}
68
71
69
72
public func hideBackgroundOverlay( ) {
Original file line number Diff line number Diff line change @@ -249,11 +249,11 @@ public final class BottomSheetView: UIView {
249
249
}
250
250
}
251
251
252
- public func reload( with contentHeights: [ CGFloat ] ) {
253
- let previousHeight = self . contentHeights [ safe: currentTargetOffsetIndex] ?? 0
254
- let indexOfPreviousHeightInNewHeights = contentHeights. firstIndex ( of: previousHeight) ?? 0
252
+ public func reload( with contentHeights: [ CGFloat ] , targetIndex: Int ? ) {
255
253
self . contentHeights = contentHeights
256
- currentTargetOffsetIndex = indexOfPreviousHeightInNewHeights
254
+ if let targetIndex = targetIndex {
255
+ currentTargetOffsetIndex = targetIndex
256
+ }
257
257
reset ( )
258
258
}
259
259
You can’t perform that action at this time.
0 commit comments