-
Notifications
You must be signed in to change notification settings - Fork 178
[fluentui-apple] Have resizingHandleView overlap content in BottomSheetController #2236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,6 +296,19 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr | |
| /// When enabled, users will be able to move the sheet to the hidden state by swiping down. | ||
| @objc open var allowsSwipeToHide: Bool = false | ||
|
|
||
| /// Indicates whether the `resizingHandleView` should overlay the `headerContentHeight` or `expandedContentView` | ||
| /// | ||
| /// The default value is false. | ||
| @objc open var shouldResizingViewOverlayContent: Bool = false { | ||
| didSet { | ||
| guard shouldResizingViewOverlayContent != oldValue && isViewLoaded else { | ||
| return | ||
| } | ||
| updateResizingHandleConstraints() | ||
| view.setNeedsLayout() | ||
| } | ||
| } | ||
|
|
||
| /// Current height of the portion of a collapsed sheet that's in the safe area. | ||
| @objc public private(set) var collapsedHeightInSafeArea: CGFloat = 0 { | ||
| didSet { | ||
|
|
@@ -603,6 +616,16 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr | |
| resizingHandleView.tokenSet.setOverrideValue(tokenSet[.resizingHandleMarkColor], forToken: .markColor) | ||
| } | ||
|
|
||
| private func updateResizingHandleConstraints() { | ||
| if let resizingHandleContentOverlapConstraints { | ||
| if shouldResizingViewOverlayContent { | ||
| NSLayoutConstraint.activate([resizingHandleContentOverlapConstraints]) | ||
| } else { | ||
| NSLayoutConstraint.deactivate([resizingHandleContentOverlapConstraints]) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func updateShadow() { | ||
| switch style { | ||
| case .primary: | ||
|
|
@@ -696,6 +719,14 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr | |
| stackView.bottomAnchor.constraint(equalTo: bottomSheetContentView.bottomAnchor) | ||
| ]) | ||
|
|
||
| if let headerContentView { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. combine with the if let on line 706 |
||
| resizingHandleContentOverlapConstraints = headerContentView.topAnchor.constraint(equalTo: resizingHandleView.bottomAnchor, constant: -currentResizingHandleHeight) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just constrain to top anchor instead of constraining to bottom anchor and then applying negative offset?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also the resizing view should just be added as a subview of the |
||
| } else { | ||
| resizingHandleContentOverlapConstraints = expandedContentView.topAnchor.constraint(equalTo: resizingHandleView.bottomAnchor, constant: -currentResizingHandleHeight) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we'll need to account for new height in expandedSheetHeight/collapsedSheetHeight |
||
| } | ||
| stackView.bringSubviewToFront(resizingHandleView) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe uikit works in order so if you add resizing handle last, you won't have to call bring subview to front |
||
| updateResizingHandleConstraints() | ||
|
|
||
| return makeBottomSheetByEmbedding(contentView: bottomSheetContentView) | ||
| }() | ||
|
|
||
|
|
@@ -1337,6 +1368,8 @@ public class BottomSheetController: UIViewController, Shadowable, TokenizedContr | |
|
|
||
| private var headerContentViewHeightConstraint: NSLayoutConstraint? | ||
|
|
||
| private var resizingHandleContentOverlapConstraints: NSLayoutConstraint? | ||
|
|
||
| private var currentStateChangeAnimator: UIViewPropertyAnimator? | ||
|
|
||
| private var currentExpansionState: BottomSheetExpansionState = .collapsed | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will there not be conflicting constraints now?