Skip to content

Commit 4f8771a

Browse files
author
Momo Ozawa
committed
Refactor: move quick actions related logic to Quick Action extension
1 parent f398e4f commit 4f8771a

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+QuickActions.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import UIKit
22

33
extension BlogDetailsViewController {
4+
45
@objc func quickActionsSectionViewModel() -> BlogDetailsSection {
56
let row = BlogDetailsRow()
67
row.callback = {}
@@ -13,6 +14,35 @@ extension BlogDetailsViewController {
1314
@objc func isAccessibilityCategoryEnabled() -> Bool {
1415
tableView.traitCollection.preferredContentSizeCategory.isAccessibilityCategory
1516
}
17+
18+
@objc func configureQuickActions(cell: QuickActionsCell) {
19+
let actionItems = createActionItems()
20+
21+
cell.configure(with: actionItems)
22+
}
23+
24+
private func createActionItems() -> [ActionRow.Item] {
25+
let actionItems: [ActionRow.Item] = [
26+
.init(image: .gridicon(.statsAlt), title: NSLocalizedString("Stats", comment: "Noun. Abbv. of Statistics. Links to a blog's Stats screen.")) { [weak self] in
27+
self?.tableView.deselectSelectedRowWithAnimation(false)
28+
self?.showStats(from: .button)
29+
},
30+
.init(image: .gridicon(.posts), title: NSLocalizedString("Posts", comment: "Noun. Title. Links to the blog's Posts screen.")) { [weak self] in
31+
self?.tableView.deselectSelectedRowWithAnimation(false)
32+
self?.showPostList(from: .button)
33+
},
34+
.init(image: .gridicon(.image), title: NSLocalizedString("Media", comment: "Noun. Title. Links to the blog's Media library.")) { [weak self] in
35+
self?.tableView.deselectSelectedRowWithAnimation(false)
36+
self?.showMediaLibrary(from: .button)
37+
},
38+
.init(image: .gridicon(.pages), title: NSLocalizedString("Pages", comment: "Noun. Title. Links to the blog's Pages screen.")) { [weak self] in
39+
self?.tableView.deselectSelectedRowWithAnimation(false)
40+
self?.showPageList(from: .button)
41+
}
42+
]
43+
44+
return actionItems
45+
}
1646
}
1747

1848
@objc class QuickActionsCell: UITableViewCell {

0 commit comments

Comments
 (0)