Skip to content

Commit 4fe7e52

Browse files
committed
Add header view to ActionSheetViewController
1 parent c1605ee commit 4fe7e52

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

WordPress/Classes/ViewRelated/System/Action Sheet/ActionSheetViewController.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ class ActionSheetViewController: UIViewController {
4545
}
4646
}
4747

48+
let headerView: UIView?
4849
let buttons: [ActionSheetButton]
49-
let headerTitle: String
50+
let buttonHeaderTitle: String
5051

51-
init(headerTitle: String, buttons: [ActionSheetButton]) {
52-
self.headerTitle = headerTitle
52+
init(headerView: UIView? = nil, buttonHeaderTitle: String, buttons: [ActionSheetButton]) {
53+
self.headerView = headerView
54+
self.buttonHeaderTitle = buttonHeaderTitle
5355
self.buttons = buttons
5456
super.init(nibName: nil, bundle: nil)
5557
}
@@ -83,7 +85,7 @@ class ActionSheetViewController: UIViewController {
8385
headerLabelView.pinSubviewToAllEdges(headerLabel, insets: Constants.Header.insets)
8486

8587
headerLabel.font = WPStyleGuide.fontForTextStyle(.headline)
86-
headerLabel.text = headerTitle
88+
headerLabel.text = buttonHeaderTitle
8789
headerLabel.translatesAutoresizingMaskIntoConstraints = false
8890

8991
let buttonViews = buttons.map({ (buttonInfo) -> UIButton in
@@ -100,10 +102,13 @@ class ActionSheetViewController: UIViewController {
100102

101103
NSLayoutConstraint.activate(buttonConstraints)
102104

103-
let stackView = UIStackView(arrangedSubviews: [
104-
gripButton,
105-
headerLabelView
106-
] + buttonViews)
105+
let stackView = UIStackView(arrangedSubviews: [gripButton])
106+
107+
if let headerView = headerView {
108+
stackView.addArrangedSubview(headerView)
109+
}
110+
111+
stackView.addArrangedSubviews([headerLabelView] + buttonViews)
107112

108113
stackView.setCustomSpacing(Constants.Header.spacing, after: gripButton)
109114
stackView.setCustomSpacing(Constants.Header.spacing, after: headerLabelView)

WordPress/Classes/ViewRelated/System/Floating Create Button/CreateButtonActionSheet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CreateButtonActionSheet: ActionSheetViewController {
1212

1313
init(actions: [ActionSheetItem]) {
1414
let buttons = actions.map { $0.makeButton() }
15-
super.init(headerTitle: Constants.title, buttons: buttons)
15+
super.init(buttonHeaderTitle: Constants.title, buttons: buttons)
1616
}
1717

1818
required init?(coder: NSCoder) {

0 commit comments

Comments
 (0)