Skip to content

Commit cb031d1

Browse files
authored
Add ability for resizing handle to hide bottom sheet (#2246)
1 parent 29dc07d commit cb031d1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ class BottomSheetDemoController: DemoController {
107107
bottomSheetViewController?.shouldResizingHandleOverlayContent = sender.isOn
108108
}
109109

110+
@objc private func toggleResizingHandleTapToHide(_ sender: BooleanCell) {
111+
bottomSheetViewController?.allowsResizingHandleTapToHide = sender.isOn
112+
}
113+
110114
@objc private func showTransientSheet() {
111115
let hostingVC = UIHostingController(rootView: BottomSheetDemoListContentView())
112116

@@ -283,7 +287,11 @@ class BottomSheetDemoController: DemoController {
283287
DemoItem(title: "Resizing handle overlaps content",
284288
type: .boolean,
285289
action: #selector(toggleResizingHandleOverlayContent),
286-
isOn: bottomSheetViewController?.shouldResizingHandleOverlayContent ?? false)
290+
isOn: bottomSheetViewController?.shouldResizingHandleOverlayContent ?? false),
291+
DemoItem(title: "Tap handle to dismiss sheet when expanded",
292+
type: .boolean,
293+
action: #selector(toggleResizingHandleTapToHide),
294+
isOn: bottomSheetViewController?.allowsResizingHandleTapToHide ?? false)
287295
],
288296
[
289297
DemoItem(title: "Show transient sheet", type: .action, action: #selector(showTransientSheet))

Sources/FluentUI_iOS/Components/BottomSheet/BottomSheetController.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
297297
/// When enabled, users will be able to move the sheet to the hidden state by swiping down.
298298
@objc open var allowsSwipeToHide: Bool = false
299299

300+
/// When enabled, tapping the resizing handle while the sheet is expanded will move it to the hidden state instead of collapsed.
301+
@objc open var allowsResizingHandleTapToHide: Bool = false
302+
300303
/// Indicates whether the resizing handle should overlay the content.
301304
///
302305
/// The default value is false.
@@ -803,7 +806,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
803806
return
804807
}
805808

806-
if nextState == .collapsed {
809+
if nextState == .collapsed || nextState == .hidden {
807810
resizingHandleView.accessibilityLabel = handleCollapseCustomAccessibilityLabel ?? "Accessibility.BottomSheet.ResizingHandle.Label.CollapseSheet".localized
808811
resizingHandleView.accessibilityHint = "Accessibility.Drawer.ResizingHandle.Hint.Collapse".localized
809812
resizingHandleView.accessibilityValue = "Accessibility.Drawer.ResizingHandle.Value.Expanded".localized
@@ -825,7 +828,7 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr
825828
case .partial:
826829
.expanded
827830
case .expanded:
828-
.collapsed
831+
allowsResizingHandleTapToHide ? .hidden : .collapsed
829832
default:
830833
nil
831834
}

0 commit comments

Comments
 (0)