Skip to content

Commit a49ad5d

Browse files
authored
Merge pull request #18504 from wordpress-mobile/feature/18473-answer-prompt-dashboard-card
Blogging Prompts: Present new post from 'Answer Prompt' tap on dashboard prompt card
2 parents 2441cf5 + b8912ac commit a49ad5d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Prompts/DashboardPromptsCardCell.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
4747
private var forExampleDisplay: Bool = false {
4848
didSet {
4949
isUserInteractionEnabled = false
50+
cardFrameView.isUserInteractionEnabled = false
5051
isAnswered = false
5152
}
5253
}
5354

55+
private var blog: Blog?
56+
5457
// Used to present the menu sheet for contextual menu.
5558
// NOTE: Remove this once we drop support for iOS 13.
5659
private weak var presenterViewController: BlogDashboardViewController? = nil
@@ -171,8 +174,7 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
171174
button.titleLabel?.font = WPStyleGuide.BloggingPrompts.buttonTitleFont
172175
button.titleLabel?.adjustsFontForContentSizeCategory = true
173176
button.titleLabel?.adjustsFontSizeToFitWidth = true
174-
175-
// TODO: Implement button tap action
177+
button.addTarget(self, action: #selector(answerButtonTapped), for: .touchUpInside)
176178

177179
return button
178180
}()
@@ -280,6 +282,7 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
280282

281283
extension DashboardPromptsCardCell: BlogDashboardCardConfigurable {
282284
func configure(blog: Blog, viewController: BlogDashboardViewController?, apiResponse: BlogDashboardRemoteEntity?) {
285+
self.blog = blog
283286
self.presenterViewController = viewController
284287
refreshStackView()
285288
}
@@ -311,6 +314,19 @@ private extension DashboardPromptsCardCell {
311314
containerStackView.addArrangedSubview((isAnswered ? answeredStateView : answerButton))
312315
}
313316

317+
// MARK: Button actions
318+
319+
@objc func answerButtonTapped() {
320+
guard let blog = blog else {
321+
return
322+
}
323+
324+
let editor = EditPostViewController(blog: blog, prompt: .examplePrompt)
325+
editor.modalPresentationStyle = .fullScreen
326+
editor.entryPoint = .dashboard
327+
presenterViewController?.present(editor, animated: true)
328+
}
329+
314330
// MARK: Context menu actions
315331

316332
func viewMoreMenuTapped() {

0 commit comments

Comments
 (0)