From 2363fc15e1fe1b9db19a9d531a21197dae6f4205 Mon Sep 17 00:00:00 2001
From: Chris McGraw <2454408+wargcm@users.noreply.github.com>
Date: Tue, 26 Apr 2022 16:57:28 -0400
Subject: [PATCH 1/2] Create prompts header view for bottom action sheet
See #18402
---
.../BloggingPromptsHeaderView.swift | 84 ++++++++++++
.../BloggingPromptsHeaderView.xib | 127 ++++++++++++++++++
.../CreateButtonActionSheet.swift | 3 +-
WordPress/WordPress.xcodeproj/project.pbxproj | 12 ++
4 files changed, 225 insertions(+), 1 deletion(-)
create mode 100644 WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift
create mode 100644 WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib
diff --git a/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift
new file mode 100644
index 000000000000..5a4bf1e1c3de
--- /dev/null
+++ b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift
@@ -0,0 +1,84 @@
+import UIKit
+
+class BloggingPromptsHeaderView: UIView, NibLoadable {
+ @IBOutlet private weak var containerStackView: UIStackView!
+ @IBOutlet private weak var titleStackView: UIStackView!
+ @IBOutlet private weak var titleLabel: UILabel!
+ @IBOutlet private weak var promptLabel: UILabel!
+ @IBOutlet private weak var answerPromptButton: UIButton!
+ @IBOutlet private weak var answeredStackView: UIStackView!
+ @IBOutlet private weak var answeredLabel: UILabel!
+ @IBOutlet private weak var shareButton: UIButton!
+
+ override func awakeFromNib() {
+ super.awakeFromNib()
+ configureView()
+ }
+
+ @IBAction private func answerPromptTapped(_ sender: Any) {
+ // TODO
+ }
+
+ @IBAction private func shareTapped(_ sender: Any) {
+ // TODO
+ }
+}
+
+// MARK: - Private methods
+
+private extension BloggingPromptsHeaderView {
+
+ func configureView() {
+ // TODO: Hide correct UI based on if prompt is answered
+ answerPromptButton.isHidden = true
+ configureSpacing()
+ configureStrings()
+ configureStyles()
+ }
+
+ func configureSpacing() {
+ containerStackView.setCustomSpacing(Constants.titleSpacing, after: titleStackView)
+ containerStackView.setCustomSpacing(Constants.answeredViewSpacing, after: answeredStackView)
+ containerStackView.setCustomSpacing(Constants.answerPromptButtonSpacing, after: answerPromptButton)
+ }
+
+ func configureStrings() {
+ titleLabel.text = Strings.title
+ // TODO: Use prompt from backend
+ promptLabel.text = Strings.examplePrompt
+ answerPromptButton.titleLabel?.text = Strings.answerButtonTitle
+ answeredLabel.text = Strings.answeredLabelTitle
+ shareButton.titleLabel?.text = Strings.shareButtonTitle
+ }
+
+ func configureStyles() {
+ titleLabel.font = WPStyleGuide.fontForTextStyle(.subheadline, fontWeight: .semibold)
+ promptLabel.font = WPStyleGuide.BloggingPrompts.promptContentFont
+ answerPromptButton.titleLabel?.font = WPStyleGuide.BloggingPrompts.buttonTitleFont
+ answerPromptButton.titleLabel?.adjustsFontForContentSizeCategory = true
+ answerPromptButton.setTitleColor(WPStyleGuide.BloggingPrompts.buttonTitleColor, for: .normal)
+ answeredLabel.font = WPStyleGuide.BloggingPrompts.buttonTitleFont
+ answeredLabel.textColor = WPStyleGuide.BloggingPrompts.answeredLabelColor
+ shareButton.titleLabel?.font = WPStyleGuide.BloggingPrompts.buttonTitleFont
+ shareButton.titleLabel?.adjustsFontForContentSizeCategory = true
+ shareButton.titleLabel?.adjustsFontSizeToFitWidth = true
+ shareButton.setTitleColor(WPStyleGuide.BloggingPrompts.buttonTitleColor, for: .normal)
+ }
+
+ // MARK: - Constants
+
+ struct Constants {
+ static let titleSpacing: CGFloat = 8.0
+ static let answeredViewSpacing: CGFloat = 9.0
+ static let answerPromptButtonSpacing: CGFloat = 9.0
+ }
+
+ struct Strings {
+ static let examplePrompt = NSLocalizedString("Cast the movie of your life.", comment: "Example prompt for blogging prompts in the create new bottom action sheet.")
+ static let title = NSLocalizedString("Prompts", comment: "Title label for blogging prompts in the create new bottom action sheet.")
+ static let answerButtonTitle = NSLocalizedString("Answer Prompt", comment: "Title for a call-to-action button in the create new bottom action sheet.")
+ static let answeredLabelTitle = NSLocalizedString("✓ Answered", comment: "Title label that indicates the prompt has been answered.")
+ static let shareButtonTitle = NSLocalizedString("Share", comment: "Title for a button that allows the user to share their answer to the prompt.")
+ }
+
+}
diff --git a/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib
new file mode 100644
index 000000000000..cf4f3a5c0dce
--- /dev/null
+++ b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WordPress/Classes/ViewRelated/System/Floating Create Button/CreateButtonActionSheet.swift b/WordPress/Classes/ViewRelated/System/Floating Create Button/CreateButtonActionSheet.swift
index 769fe02b4f19..4a85f2e7a40e 100644
--- a/WordPress/Classes/ViewRelated/System/Floating Create Button/CreateButtonActionSheet.swift
+++ b/WordPress/Classes/ViewRelated/System/Floating Create Button/CreateButtonActionSheet.swift
@@ -11,8 +11,9 @@ class CreateButtonActionSheet: ActionSheetViewController {
}
init(actions: [ActionSheetItem]) {
+ let headerView = FeatureFlag.bloggingPrompts.enabled ? BloggingPromptsHeaderView.loadFromNib() : nil
let buttons = actions.map { $0.makeButton() }
- super.init(headerTitle: Constants.title, buttons: buttons)
+ super.init(headerView: headerView, headerTitle: Constants.title, buttons: buttons)
}
required init?(coder: NSCoder) {
diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj
index 1e8de864e844..e2c7ed8ce2e6 100644
--- a/WordPress/WordPress.xcodeproj/project.pbxproj
+++ b/WordPress/WordPress.xcodeproj/project.pbxproj
@@ -1395,6 +1395,10 @@
8355D7D911D260AA00A61362 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8355D7D811D260AA00A61362 /* CoreData.framework */; };
836498C828172C5900A2C170 /* WPStyleGuide+BloggingPrompts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836498C728172C5900A2C170 /* WPStyleGuide+BloggingPrompts.swift */; };
836498C928172C5900A2C170 /* WPStyleGuide+BloggingPrompts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836498C728172C5900A2C170 /* WPStyleGuide+BloggingPrompts.swift */; };
+ 836498CB2817301800A2C170 /* BloggingPromptsHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 836498CA2817301800A2C170 /* BloggingPromptsHeaderView.xib */; };
+ 836498CC2817301800A2C170 /* BloggingPromptsHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 836498CA2817301800A2C170 /* BloggingPromptsHeaderView.xib */; };
+ 836498CE281735CC00A2C170 /* BloggingPromptsHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836498CD281735CC00A2C170 /* BloggingPromptsHeaderView.swift */; };
+ 836498CF281735CC00A2C170 /* BloggingPromptsHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 836498CD281735CC00A2C170 /* BloggingPromptsHeaderView.swift */; };
8370D10A11FA499A009D650F /* WPTableViewActivityCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8370D10911FA499A009D650F /* WPTableViewActivityCell.m */; };
839B150B2795DEE0009F5E77 /* UIView+Margins.swift in Sources */ = {isa = PBXBuildFile; fileRef = 839B150A2795DEE0009F5E77 /* UIView+Margins.swift */; };
839B150C2795DEE0009F5E77 /* UIView+Margins.swift in Sources */ = {isa = PBXBuildFile; fileRef = 839B150A2795DEE0009F5E77 /* UIView+Margins.swift */; };
@@ -6144,6 +6148,8 @@
8355D7D811D260AA00A61362 /* CoreData.framework */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
835E2402126E66E50085940B /* AssetsLibrary.framework */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
836498C728172C5900A2C170 /* WPStyleGuide+BloggingPrompts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WPStyleGuide+BloggingPrompts.swift"; sourceTree = ""; };
+ 836498CA2817301800A2C170 /* BloggingPromptsHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BloggingPromptsHeaderView.xib; sourceTree = ""; };
+ 836498CD281735CC00A2C170 /* BloggingPromptsHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BloggingPromptsHeaderView.swift; sourceTree = ""; };
8370D10811FA499A009D650F /* WPTableViewActivityCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WPTableViewActivityCell.h; sourceTree = ""; };
8370D10911FA499A009D650F /* WPTableViewActivityCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPTableViewActivityCell.m; sourceTree = ""; };
839B150A2795DEE0009F5E77 /* UIView+Margins.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Margins.swift"; sourceTree = ""; };
@@ -14820,6 +14826,8 @@
children = (
F5E032E32408D537003AF350 /* ActionSheetViewController.swift */,
F5E032E52408D537003AF350 /* BottomSheetPresentationController.swift */,
+ 836498CD281735CC00A2C170 /* BloggingPromptsHeaderView.swift */,
+ 836498CA2817301800A2C170 /* BloggingPromptsHeaderView.xib */,
);
path = "Action Sheet";
sourceTree = "";
@@ -16053,6 +16061,7 @@
9808655A203D075E00D58786 /* EpilogueUserInfoCell.xib in Resources */,
C7E5F2552799BD54009BC263 /* cool-blue-icon-app-83.5x83.5@2x.png in Resources */,
17222D92261DDDF90047B163 /* blue-classic-icon-app-83.5x83.5@2x.png in Resources */,
+ 836498CB2817301800A2C170 /* BloggingPromptsHeaderView.xib in Resources */,
17222D90261DDDF90047B163 /* blue-classic-icon-app-60x60@2x.png in Resources */,
E6D2E1611B8AA4410000ED14 /* ReaderTagStreamHeader.xib in Resources */,
577C2AB62294401800AD1F03 /* PostCompactCell.xib in Resources */,
@@ -16364,6 +16373,7 @@
FABB1FC12602FC2C00C8785C /* defaultPostTemplate.html in Resources */,
FABB1FC32602FC2C00C8785C /* defaultPostTemplate_old.html in Resources */,
FABB1FC42602FC2C00C8785C /* ReaderInterestsCollectionViewCell.xib in Resources */,
+ 836498CC2817301800A2C170 /* BloggingPromptsHeaderView.xib in Resources */,
FABB1FC52602FC2C00C8785C /* StatsGhostTopHeaderCell.xib in Resources */,
9856A38A261FC206008D6354 /* UserProfileUserInfoCell.xib in Resources */,
FABB1FC72602FC2C00C8785C /* RegisterDomainDetailsFooterView.xib in Resources */,
@@ -19020,6 +19030,7 @@
8B05D29323AA572A0063B9AA /* GutenbergMediaEditorImage.swift in Sources */,
B532D4EA199D4357006E4DF6 /* NoteBlockHeaderTableViewCell.swift in Sources */,
24ADA24C24F9A4CB001B5DAE /* RemoteFeatureFlagStore.swift in Sources */,
+ 836498CE281735CC00A2C170 /* BloggingPromptsHeaderView.swift in Sources */,
319D6E8519E44F7F0013871C /* SuggestionsTableViewCell.m in Sources */,
40A71C69220E1952002E3D25 /* LastPostStatsRecordValue+CoreDataClass.swift in Sources */,
98AA6D1126B8CE7200920C8B /* Comment+CoreDataClass.swift in Sources */,
@@ -19885,6 +19896,7 @@
FABB21132602FC2C00C8785C /* AuthenticationService.swift in Sources */,
FABB21142602FC2C00C8785C /* JetpackSiteRef.swift in Sources */,
FABB21152602FC2C00C8785C /* WPStyleGuide+Reply.swift in Sources */,
+ 836498CF281735CC00A2C170 /* BloggingPromptsHeaderView.swift in Sources */,
FABB21162602FC2C00C8785C /* WPBlogTableViewCell.m in Sources */,
FABB21172602FC2C00C8785C /* JetpackBackupOptionsViewController.swift in Sources */,
FABB21182602FC2C00C8785C /* TopViewedVideoStatsRecordValue+CoreDataProperties.swift in Sources */,
From 698d0694ed3d5814b9498e541d5f3a7e27c37cf3 Mon Sep 17 00:00:00 2001
From: Chris McGraw <2454408+wargcm@users.noreply.github.com>
Date: Wed, 27 Apr 2022 12:43:41 -0400
Subject: [PATCH 2/2] Update `BloggingPromptsHeaderView`'s divider view
Applies the following changes to the divider view:
- Add a name to the view
- Add a height constraint using `.hairlineBorderWidth`
---
.../Action Sheet/BloggingPromptsHeaderView.swift | 8 ++++++++
.../System/Action Sheet/BloggingPromptsHeaderView.xib | 10 ++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift
index 5a4bf1e1c3de..853223cd8f91 100644
--- a/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift
+++ b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.swift
@@ -9,6 +9,7 @@ class BloggingPromptsHeaderView: UIView, NibLoadable {
@IBOutlet private weak var answeredStackView: UIStackView!
@IBOutlet private weak var answeredLabel: UILabel!
@IBOutlet private weak var shareButton: UIButton!
+ @IBOutlet private weak var dividerView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
@@ -34,6 +35,7 @@ private extension BloggingPromptsHeaderView {
configureSpacing()
configureStrings()
configureStyles()
+ configureConstraints()
}
func configureSpacing() {
@@ -65,6 +67,12 @@ private extension BloggingPromptsHeaderView {
shareButton.setTitleColor(WPStyleGuide.BloggingPrompts.buttonTitleColor, for: .normal)
}
+ func configureConstraints() {
+ NSLayoutConstraint.activate([
+ dividerView.heightAnchor.constraint(equalToConstant: .hairlineBorderWidth),
+ ])
+ }
+
// MARK: - Constants
struct Constants {
diff --git a/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib
index cf4f3a5c0dce..1fd7a4f86362 100644
--- a/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib
+++ b/WordPress/Classes/ViewRelated/System/Action Sheet/BloggingPromptsHeaderView.xib
@@ -48,7 +48,7 @@
-
+
-
+
-
-
-
@@ -107,6 +104,7 @@
+