Skip to content

Commit f752e43

Browse files
authored
Merge pull request #8728 from woocommerce/issue/8674-IPP-banner-UI
[IPPInAppFeedback] UI banner component design tweaks
2 parents 06b31b8 + 4579e44 commit f752e43

File tree

6 files changed

+81
-6
lines changed

6 files changed

+81
-6
lines changed

WooCommerce/Classes/Extensions/UIImage+Woo.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ extension UIImage {
210210
return UIImage.gridicon(.comment)
211211
}
212212

213+
/// Comment Content Icon
214+
///
215+
static var commentContent: UIImage {
216+
return UIImage(named: "icon-comment-content") ?? UIImage.gridicon(.comment)
217+
}
218+
213219
/// Credit Card Icon
214220
///
215221
static var creditCardImage: UIImage {

WooCommerce/Classes/Extensions/UIView+Border.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import UIKit
22

33
extension UIView {
4-
/// Creates a border view with the given height and color.
4+
/// Creates a border view with the given height, and color.
55
/// - Parameter height: height of the border. Default to be 0.5px.
66
/// - Parameter color: background color of the border. Default to be the divider color.
7+
///
78
static func createBorderView(height: CGFloat = 0.5,
89
color: UIColor = .systemColor(.separator)) -> UIView {
910
let view = UIView(frame: .zero)
@@ -14,4 +15,22 @@ extension UIView {
1415
])
1516
return view
1617
}
18+
19+
/// Creates an empty view with the given height, width, and color
20+
/// - Parameter height: height of the separator. Default to be 0.5px.
21+
/// - Parameter width: width of the separator. Default to be 0.5px.
22+
/// - Parameter color: background color of the separator. Default to be `.clear`
23+
///
24+
static func createSeparatorView(height: CGFloat = 0.5,
25+
width: CGFloat = 0.5,
26+
color: UIColor = .clear) -> UIView {
27+
let view = UIView(frame: .zero)
28+
view.translatesAutoresizingMaskIntoConstraints = false
29+
view.backgroundColor = color
30+
NSLayoutConstraint.activate([
31+
view.heightAnchor.constraint(equalToConstant: height),
32+
view.widthAnchor.constraint(equalToConstant: width)
33+
])
34+
return view
35+
}
1736
}

WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ private extension OrderListViewController {
836836
let viewModel = TopBannerViewModel(
837837
title: bannerTitle,
838838
infoText: bannerText,
839-
icon: UIImage.gridicon(.comment),
839+
icon: UIImage.commentContent,
840840
isExpanded: true,
841841
topButton: .dismiss(handler: {
842842
self.showIPPFeedbackDismissAlert(survey: survey, campaign: campaign)

WooCommerce/Classes/ViewRelated/Top Banner/TopBannerView.swift

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ final class TopBannerView: UIView {
5050
return stackView
5151
}()
5252

53+
private let labelHolderStackView: UIStackView = {
54+
let stackView = UIStackView()
55+
stackView.axis = .horizontal
56+
return stackView
57+
}()
58+
5359
// StackView to hold the action buttons. Needed to change the axis on larger accessibility traits
5460
private let buttonsStackView = UIStackView()
5561

@@ -114,6 +120,10 @@ private extension TopBannerView {
114120

115121
zip(viewModel.actionButtons, actionButtons).forEach { buttonInfo, button in
116122
button.setTitle(buttonInfo.title, for: .normal)
123+
button.titleLabel?.font = .boldSystemFont(ofSize: titleLabel.font.pointSize)
124+
// Overrides the general .applyLinkButtonStyle() with pink color
125+
// pecCkj-fa-p2
126+
button.setTitleColor(UIColor.withColorStudio(.pink), for: .normal)
117127
button.on(.touchUpInside, call: { _ in buttonInfo.action(button) })
118128
}
119129
}
@@ -141,7 +151,7 @@ private extension TopBannerView {
141151

142152
func createMainStackView(with viewModel: TopBannerViewModel) -> UIStackView {
143153
let iconInformationStackView = createIconInformationStackView(with: viewModel)
144-
let mainStackView = UIStackView(arrangedSubviews: [iconInformationStackView, createBorderView()])
154+
let mainStackView = UIStackView(arrangedSubviews: [createBorderView(), iconInformationStackView, createBorderView()])
145155
if isActionEnabled {
146156
configureActionStackView(with: viewModel)
147157
mainStackView.addArrangedSubview(actionStackView)
@@ -167,6 +177,18 @@ private extension TopBannerView {
167177
return iconInformationStackView
168178
}
169179

180+
func createLabelHolderStackView() -> UIStackView {
181+
labelHolderStackView.addArrangedSubviews([
182+
createSeparatorView(height: Constants.labelHolderHeight, width: Constants.labelHolderLeftMargin),
183+
infoLabel,
184+
createSeparatorView(height: Constants.labelHolderHeight, width: Constants.labelHolderRightMargin)
185+
])
186+
labelHolderStackView.spacing = Constants.labelHolderSpacing
187+
infoLabel.adjustsFontSizeToFitWidth = true
188+
189+
return labelHolderStackView
190+
}
191+
170192
func createInformationStackView(with viewModel: TopBannerViewModel) -> UIStackView {
171193
let topActionButton = topButton(for: viewModel.topButton)
172194
titleStackView.addArrangedSubviews([titleLabel, topActionButton].compactMap { $0 })
@@ -179,7 +201,8 @@ private extension TopBannerView {
179201
// titleStackView will hidden if there is no title
180202
titleStackView.isHidden = viewModel.title == nil || viewModel.title?.isEmpty == true
181203

182-
let informationStackView = UIStackView(arrangedSubviews: [titleStackView, infoLabel])
204+
let informationStackView = UIStackView(arrangedSubviews: [titleStackView, createLabelHolderStackView()])
205+
183206
informationStackView.axis = .vertical
184207
informationStackView.spacing = 9
185208

@@ -225,6 +248,10 @@ private extension TopBannerView {
225248
return UIView.createBorderView()
226249
}
227250

251+
func createSeparatorView(height: CGFloat, width: CGFloat) -> UIView {
252+
return UIView.createSeparatorView(height: height, width: width)
253+
}
254+
228255
func topButton(for buttonType: TopBannerViewModel.TopButtonType) -> UIButton? {
229256
switch buttonType {
230257
case .chevron:
@@ -293,14 +320,14 @@ private extension TopBannerView {
293320
func updateExpandCollapseState(isExpanded: Bool) {
294321
let image = isExpanded ? UIImage.chevronUpImage: UIImage.chevronDownImage
295322
expandCollapseButton.setImage(image, for: .normal)
296-
infoLabel.isHidden = !isExpanded
323+
labelHolderStackView.isHidden = !isExpanded
297324
if isActionEnabled {
298325
actionStackView.isHidden = !isExpanded
299326
}
300327
titleStackView.accessibilityHint = isExpanded ? Localization.collapseHint : Localization.expandHint
301328
titleStackView.accessibilityValue = isExpanded ? Localization.expanded : Localization.collapsed
302329

303-
let accessibleView = isExpanded ? infoLabel : nil
330+
let accessibleView = isExpanded ? labelHolderStackView : nil
304331
UIAccessibility.post(notification: .layoutChanged, argument: accessibleView)
305332
}
306333
}
@@ -316,3 +343,14 @@ private extension TopBannerView {
316343
static let dismissHint = NSLocalizedString("Double-tap to dismiss", comment: "Accessibility hint to dismiss a banner")
317344
}
318345
}
346+
347+
// MARK: - Constants
348+
//
349+
private extension TopBannerView {
350+
enum Constants {
351+
static let labelHolderHeight: CGFloat = 48.0
352+
static let labelHolderLeftMargin: CGFloat = 0.0
353+
static let labelHolderRightMargin: CGFloat = 24.0
354+
static let labelHolderSpacing: CGFloat = 1.0
355+
}
356+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "icon-comment-content.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Binary file not shown.

0 commit comments

Comments
 (0)