Calculate Bottom Commanding header height instead of using constant (#2041)
* calculate header height instead of using constant * remove headerHeight var * update comment
This commit is contained in:
Родитель
32d5cf1139
Коммит
d298dacb9d
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче