Skip to content

Commit f1001b6

Browse files
lukas-capLukas Capkovicclaude
authored
Deprecate sheet prepareInteractiveIsHiddenChange (#2248)
* Deprecate prepareInteractiveIsHiddenChange on BottomSheetController and BottomCommandingController Remove scroll-to-hide demo feature that was the sole consumer of this API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix BottomSheetControllerTest cell indices and remove testScrollToHide The removal of the "Scroll to hide" toggle shifted cell indices, breaking testCollapsedContent. Update the index and remove the now-defunct testScrollToHide test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Lukas Capkovic <lucapkov@microsoft.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent acf6b79 commit f1001b6

File tree

5 files changed

+3
-123
lines changed

5 files changed

+3
-123
lines changed

Demos/FluentUIDemo_iOS/FluentUI.Demo/Demos/BottomCommandingDemoController.swift

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class BottomCommandingDemoController: DemoController {
9494
return [
9595
[
9696
DemoItem(title: "Hidden", type: .boolean, action: #selector(toggleHidden), isOn: bottomCommandingController?.isHidden ?? false),
97-
DemoItem(title: "Scroll to hide", type: .boolean, action: #selector(toggleScrollHiding), isOn: scrollHidingEnabled),
9897
DemoItem(title: "Sheet more button", type: .boolean, action: #selector(toggleSheetMoreButton), isOn: bottomCommandingController?.prefersSheetMoreButtonVisible ?? true),
9998
DemoItem(title: "Sheet should always fill width", type: .boolean, action: #selector(toggleFillWidth), isOn: bottomCommandingController?.sheetShouldAlwaysFillWidth ?? true)
10099
],
@@ -122,10 +121,6 @@ class BottomCommandingDemoController: DemoController {
122121
bottomCommandingController?.isHidden = sender.isOn
123122
}
124123

125-
@objc private func toggleScrollHiding(_ sender: BooleanCell) {
126-
scrollHidingEnabled = sender.isOn
127-
}
128-
129124
@objc private func toggleSheetMoreButton(_ sender: BooleanCell) {
130125
bottomCommandingController?.prefersSheetMoreButtonVisible = sender.isOn
131126
}
@@ -323,14 +318,6 @@ class BottomCommandingDemoController: DemoController {
323318

324319
private var additionalExpandedItemsVisible: Bool = false
325320

326-
private var previousScrollOffset: CGFloat = 0
327-
328-
private var isHiding: Bool = false
329-
330-
private var interactiveHidingAnimator: UIViewAnimating?
331-
332-
private var scrollHidingEnabled: Bool = false
333-
334321
private enum DemoItemType {
335322
case action
336323
case boolean
@@ -415,48 +402,6 @@ extension BottomCommandingDemoController: UITableViewDataSource {
415402
}
416403
}
417404

418-
extension BottomCommandingDemoController: UIScrollViewDelegate {
419-
func scrollViewDidScroll(_ scrollView: UIScrollView) {
420-
let contentOffset = scrollView.contentOffset.y
421-
422-
if scrollView.isTracking && scrollHidingEnabled {
423-
var delta = contentOffset - previousScrollOffset
424-
if interactiveHidingAnimator == nil {
425-
isHiding = delta > 0 ? true : false
426-
interactiveHidingAnimator = bottomCommandingController?.prepareInteractiveIsHiddenChange(isHiding) { [weak self] _ in
427-
self?.mainTableViewController?.tableView?.reloadData()
428-
self?.mainTableViewController?.tableView?.layoutIfNeeded()
429-
self?.interactiveHidingAnimator = nil
430-
}
431-
}
432-
if let animator = interactiveHidingAnimator {
433-
if animator.isRunning {
434-
animator.pauseAnimation()
435-
}
436-
437-
// fractionComplete either represents progress to hidden or unhidden,
438-
// so we need to adjust the delta to account for this
439-
delta *= isHiding ? 1 : -1
440-
animator.fractionComplete += delta / 100
441-
}
442-
}
443-
444-
previousScrollOffset = contentOffset
445-
}
446-
447-
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
448-
if let animator = interactiveHidingAnimator {
449-
if animator.fractionComplete > 0.5 {
450-
animator.startAnimation()
451-
} else {
452-
animator.isReversed.toggle()
453-
isHiding.toggle()
454-
animator.startAnimation()
455-
}
456-
}
457-
}
458-
}
459-
460405
extension BottomCommandingDemoController: BottomCommandingControllerDelegate {
461406
func bottomCommandingControllerCollapsedHeightInSafeAreaDidChange(_ bottomCommandingController: BottomCommandingController) {
462407
if let tableView = mainTableViewController?.tableView {

Demos/FluentUIDemo_iOS/FluentUI.Demo/Demos/BottomSheetDemoController.swift

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ class BottomSheetDemoController: DemoController {
7373
bottomSheetViewController?.shouldAlwaysFillWidth = sender.isOn
7474
}
7575

76-
@objc private func toggleScrollHiding(_ sender: BooleanCell) {
77-
scrollHidingEnabled = sender.isOn
78-
}
79-
8076
@objc private func toggleCollapsedContentHiding(_ sender: BooleanCell) {
8177
bottomSheetViewController?.shouldHideCollapsedContent.toggle()
8278
}
@@ -253,25 +249,16 @@ class BottomSheetDemoController: DemoController {
253249

254250
private var bottomSheetViewController: BottomSheetController?
255251

256-
private var previousScrollOffset: CGFloat = 0
257-
258-
private var scrollHidingEnabled: Bool = false
259-
260252
private var collapsedContentHidingEnabled: Bool = true
261253

262254
private var isHandleUsingCustomAccessibilityLabel: Bool = false
263255

264-
private var isHiding: Bool = false
265-
266-
private var interactiveHidingAnimator: UIViewAnimating?
267-
268256
private var demoOptionItems: [[DemoItem]] {
269257
[
270258
[
271259
DemoItem(title: "Expandable", type: .boolean, action: #selector(toggleExpandable), isOn: bottomSheetViewController?.isExpandable ?? true),
272260
DemoItem(title: "Hidden", type: .boolean, action: #selector(toggleHidden), isOn: bottomSheetViewController?.isHidden ?? false),
273261
DemoItem(title: "Should always fill width", type: .boolean, action: #selector(toggleFillWidth), isOn: bottomSheetViewController?.shouldAlwaysFillWidth ?? false),
274-
DemoItem(title: "Scroll to hide", type: .boolean, action: #selector(toggleScrollHiding), isOn: scrollHidingEnabled),
275262
DemoItem(title: "Hide collapsed content", type: .boolean, action: #selector(toggleCollapsedContentHiding), isOn: collapsedContentHidingEnabled),
276263
DemoItem(title: "Flexible sheet height", type: .boolean, action: #selector(toggleFlexibleSheetHeight), isOn: bottomSheetViewController?.isFlexibleHeight ?? false),
277264
DemoItem(title: "Use custom handle accessibility label", type: .boolean, action: #selector(toggleHandleUsingCustomAccessibilityLabel), isOn: isHandleUsingCustomAccessibilityLabel),
@@ -386,48 +373,6 @@ extension BottomSheetDemoController: UITableViewDataSource {
386373
}
387374
}
388375

389-
extension BottomSheetDemoController: UIScrollViewDelegate {
390-
func scrollViewDidScroll(_ scrollView: UIScrollView) {
391-
let contentOffset = scrollView.contentOffset.y
392-
393-
if scrollView.isTracking && scrollHidingEnabled {
394-
var delta = contentOffset - previousScrollOffset
395-
if interactiveHidingAnimator == nil {
396-
isHiding = delta > 0 ? true : false
397-
interactiveHidingAnimator = bottomSheetViewController?.prepareInteractiveIsHiddenChange(isHiding) { [weak self] _ in
398-
self?.mainTableView?.reloadData()
399-
self?.mainTableView?.layoutIfNeeded()
400-
self?.interactiveHidingAnimator = nil
401-
}
402-
}
403-
if let animator = interactiveHidingAnimator {
404-
if animator.isRunning {
405-
animator.pauseAnimation()
406-
}
407-
408-
// fractionComplete either represents progress to hidden or unhidden,
409-
// so we need to adjust the delta to account for this
410-
delta *= isHiding ? 1 : -1
411-
animator.fractionComplete += delta / 100
412-
}
413-
}
414-
415-
previousScrollOffset = contentOffset
416-
}
417-
418-
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
419-
if let animator = interactiveHidingAnimator {
420-
if animator.fractionComplete > 0.5 {
421-
animator.startAnimation()
422-
} else {
423-
animator.isReversed.toggle()
424-
isHiding.toggle()
425-
animator.startAnimation()
426-
}
427-
}
428-
}
429-
}
430-
431376
extension BottomSheetDemoController: BottomSheetControllerDelegate {
432377
func bottomSheetControllerCollapsedHeightInSafeAreaDidChange(_ bottomSheetController: BottomSheetController) {
433378
if let tableView = mainTableView {

Demos/FluentUIDemo_iOS/FluentUIDemoTests/BottomSheetControllerTest.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,8 @@ class BottomSheetControllerTest: BaseTest {
4141
XCTAssert(!app.otherElements.containing(NSPredicate(format: "identifier MATCHES %@", "Bottom Sheet View.*filled width.*")).element.exists)
4242
}
4343

44-
func testScrollToHide() throws {
45-
let bottomSheet: XCUIElement = app.otherElements.containing(bottomSheetPredicate).element
46-
let scrollToHideSwitch: XCUIElement = app.tables.element(boundBy: 0).cells.element(boundBy: 3)
47-
48-
XCTAssert(bottomSheet.exists)
49-
scrollToHideSwitch.tap()
50-
sleep(1)
51-
app.swipeUp()
52-
sleep(1)
53-
XCTAssert(!bottomSheet.isHittable)
54-
}
55-
5644
func testCollapsedContent() throws {
57-
let hideCollapsedContentSwitch: XCUIElement = app.tables.element(boundBy: 0).cells.element(boundBy: 4)
45+
let hideCollapsedContentSwitch: XCUIElement = app.tables.element(boundBy: 0).cells.element(boundBy: 3)
5846

5947
hideCollapsedContentSwitch.tap()
6048
sleep(1)

Sources/FluentUI_iOS/Components/BottomCommanding/BottomCommandingController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ open class BottomCommandingController: UIViewController, TokenizedControl {
215215
/// - isHidden: The target state.
216216
/// - completion: Closure to be called when the state change completes.
217217
/// - Returns: A `UIViewPropertyAnimator`. The associated animations start in a paused state.
218+
@available(*, deprecated, message: "prepareInteractiveIsHiddenChange is deprecated.")
218219
@objc public func prepareInteractiveIsHiddenChange(_ isHidden: Bool, completion: ((_ finalPosition: UIViewAnimatingPosition) -> Void)? = nil) -> UIViewPropertyAnimator? {
219220
guard isViewLoaded else {
220221
return nil

Sources/FluentUI_iOS/Components/BottomSheet/BottomSheetController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
429429
/// - isHidden: The target state.
430430
/// - completion: Closure to be called when the state change completes.
431431
/// - Returns: A `UIViewPropertyAnimator`. The associated animations start in a paused state.
432+
@available(*, deprecated, message: "prepareInteractiveIsHiddenChange is deprecated.")
432433
@objc public func prepareInteractiveIsHiddenChange(_ isHidden: Bool, completion: ((_ finalPosition: UIViewAnimatingPosition) -> Void)? = nil) -> UIViewPropertyAnimator? {
433434
guard isViewLoaded else {
434435
return nil

0 commit comments

Comments
 (0)