diff --git a/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift b/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift index 7bdb66bb0c..3c7e0a59be 100644 --- a/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift +++ b/ios/FluentUI.Demo/FluentUI.Demo/Demos/BottomCommandingDemoController.swift @@ -46,7 +46,8 @@ class BottomCommandingDemoController: DemoController { private lazy var heroItems: [CommandingItem] = { return Array(1...25).map { - let item = CommandingItem(title: "Item " + String($0), image: homeImage, action: commandAction) + let title = ($0 == 4) ? "Two line item" : "Item" + let item = CommandingItem(title: title + String($0), image: homeImage, action: commandAction) item.selectedImage = homeSelectedImage item.isOn = ($0 % 3 == 1) item.isEnabled = ($0 % 2 == 1) diff --git a/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift b/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift index 8c56d62cae..b66d3c4639 100644 --- a/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift +++ b/ios/FluentUI/Bottom Commanding/BottomCommandingController.swift @@ -402,7 +402,6 @@ open class BottomCommandingController: UIViewController, TokenizedControlInterna headerView.addSubview(heroCommandStack) let sheetController = BottomSheetController(headerContentView: headerView, expandedContentView: makeSheetExpandedContent(with: tableView)) - sheetController.headerContentHeight = Constants.BottomSheet.headerHeight sheetController.hostedScrollView = tableView sheetController.isHidden = isHidden sheetController.shouldAlwaysFillWidth = sheetShouldAlwaysFillWidth @@ -534,6 +533,7 @@ open class BottomCommandingController: UIViewController, TokenizedControlInterna } else { tableView.tableHeaderView = nil } + calculateHeaderHeight() } private func reloadHeroCommandOverflowStack() { @@ -563,6 +563,13 @@ open class BottomCommandingController: UIViewController, TokenizedControlInterna } } + @discardableResult + private func calculateHeaderHeight() -> CGFloat { + let headerHeight = heroCommandStack.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height + BottomSheetController.resizingHandleHeight + bottomSheetController?.headerContentHeight = headerHeight + return headerHeight + } + private func updateAppearance() { guard isViewLoaded else { return @@ -923,7 +930,7 @@ open class BottomCommandingController: UIViewController, TokenizedControlInterna let headerHeightWithoutBottomWhitespace = BottomCommandingTokenSet.handleHeaderHeight + maxHeroItemHeight // How much more whitespace is required at the bottom of the sheet header - let requiredBottomWhitespace = max(0, Constants.BottomSheet.headerHeight - headerHeightWithoutBottomWhitespace) + let requiredBottomWhitespace = max(0, calculateHeaderHeight() - headerHeightWithoutBottomWhitespace) // The safe area inset can fulfill some or all of our bottom whitespace requirement. // This is how much more we need, taking the inset into account. @@ -1118,10 +1125,6 @@ open class BottomCommandingController: UIViewController, TokenizedControlInterna static let moreButtonIcon: UIImage? = UIImage.staticImageNamed("more-24x24") static let moreButtonTitle: String = "CommandingBottomBar.More".localized } - - struct BottomSheet { - static let headerHeight: CGFloat = 66 - } } }