Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions WooCommerce/Classes/Extensions/UIImage+Woo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ extension UIImage {
return UIImage.gridicon(.comment)
}

/// Comment Content Icon
///
static var commentContent: UIImage {
return UIImage(named: "icon-comment-content") ?? UIImage.gridicon(.comment)
}

/// Credit Card Icon
///
static var creditCardImage: UIImage {
Expand Down
21 changes: 20 additions & 1 deletion WooCommerce/Classes/Extensions/UIView+Border.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import UIKit

extension UIView {
/// Creates a border view with the given height and color.
/// Creates a border view with the given height, and color.
/// - Parameter height: height of the border. Default to be 0.5px.
/// - Parameter color: background color of the border. Default to be the divider color.
///
static func createBorderView(height: CGFloat = 0.5,
color: UIColor = .systemColor(.separator)) -> UIView {
let view = UIView(frame: .zero)
Expand All @@ -14,4 +15,22 @@ extension UIView {
])
return view
}

/// Creates an empty view with the given height, width, and color
/// - Parameter height: height of the separator. Default to be 0.5px.
/// - Parameter width: width of the separator. Default to be 0.5px.
/// - Parameter color: background color of the separator. Default to be `.clear`
///
static func createSeparatorView(height: CGFloat = 0.5,
width: CGFloat = 0.5,
color: UIColor = .clear) -> UIView {
let view = UIView(frame: .zero)
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = color
NSLayoutConstraint.activate([
view.heightAnchor.constraint(equalToConstant: height),
view.widthAnchor.constraint(equalToConstant: width)
])
return view
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ private extension OrderListViewController {
let viewModel = TopBannerViewModel(
title: bannerTitle,
infoText: bannerText,
icon: UIImage.gridicon(.comment),
icon: UIImage.commentContent,
isExpanded: true,
topButton: .dismiss(handler: {
self.showIPPFeedbackDismissAlert()
Expand Down
34 changes: 30 additions & 4 deletions WooCommerce/Classes/ViewRelated/Top Banner/TopBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ final class TopBannerView: UIView {
return stackView
}()

private let labelHolderStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .horizontal
return stackView
}()

// StackView to hold the action buttons. Needed to change the axis on larger accessibility traits
private let buttonsStackView = UIStackView()

Expand Down Expand Up @@ -114,6 +120,9 @@ private extension TopBannerView {

zip(viewModel.actionButtons, actionButtons).forEach { buttonInfo, button in
button.setTitle(buttonInfo.title, for: .normal)
// Overrides the general .applyLinkButtonStyle() with pink color
// pecCkj-fa-p2
button.setTitleColor(UIColor.withColorStudio(.pink), for: .normal)
button.on(.touchUpInside, call: { _ in buttonInfo.action(button) })
}
}
Expand Down Expand Up @@ -141,7 +150,7 @@ private extension TopBannerView {

func createMainStackView(with viewModel: TopBannerViewModel) -> UIStackView {
let iconInformationStackView = createIconInformationStackView(with: viewModel)
let mainStackView = UIStackView(arrangedSubviews: [iconInformationStackView, createBorderView()])
let mainStackView = UIStackView(arrangedSubviews: [createBorderView(), iconInformationStackView, createBorderView()])
if isActionEnabled {
configureActionStackView(with: viewModel)
mainStackView.addArrangedSubview(actionStackView)
Expand All @@ -167,6 +176,18 @@ private extension TopBannerView {
return iconInformationStackView
}

func createLabelHolderStackView() -> UIStackView {
labelHolderStackView.addArrangedSubviews([
createSeparatorView(height: 48, width: 0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add these values into constants? That way we can reuse them, and we know what they stand for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! 4579e44

infoLabel,
createSeparatorView(height: 48, width: 24)
])
labelHolderStackView.spacing = 1
infoLabel.adjustsFontSizeToFitWidth = true

return labelHolderStackView
}

func createInformationStackView(with viewModel: TopBannerViewModel) -> UIStackView {
let topActionButton = topButton(for: viewModel.topButton)
titleStackView.addArrangedSubviews([titleLabel, topActionButton].compactMap { $0 })
Expand All @@ -179,7 +200,8 @@ private extension TopBannerView {
// titleStackView will hidden if there is no title
titleStackView.isHidden = viewModel.title == nil || viewModel.title?.isEmpty == true

let informationStackView = UIStackView(arrangedSubviews: [titleStackView, infoLabel])
let informationStackView = UIStackView(arrangedSubviews: [titleStackView, createLabelHolderStackView()])

informationStackView.axis = .vertical
informationStackView.spacing = 9

Expand Down Expand Up @@ -225,6 +247,10 @@ private extension TopBannerView {
return UIView.createBorderView()
}

func createSeparatorView(height: CGFloat, width: CGFloat) -> UIView {
return UIView.createSeparatorView(height: height, width: width)
}

func topButton(for buttonType: TopBannerViewModel.TopButtonType) -> UIButton? {
switch buttonType {
case .chevron:
Expand Down Expand Up @@ -293,14 +319,14 @@ private extension TopBannerView {
func updateExpandCollapseState(isExpanded: Bool) {
let image = isExpanded ? UIImage.chevronUpImage: UIImage.chevronDownImage
expandCollapseButton.setImage(image, for: .normal)
infoLabel.isHidden = !isExpanded
labelHolderStackView.isHidden = !isExpanded
if isActionEnabled {
actionStackView.isHidden = !isExpanded
}
titleStackView.accessibilityHint = isExpanded ? Localization.collapseHint : Localization.expandHint
titleStackView.accessibilityValue = isExpanded ? Localization.expanded : Localization.collapsed

let accessibleView = isExpanded ? infoLabel : nil
let accessibleView = isExpanded ? labelHolderStackView : nil
UIAccessibility.post(notification: .layoutChanged, argument: accessibleView)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can apply here a single scale with the pdf file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Switched from SVG to PDF and universal size here: 26d3d06

"filename" : "icon-comment-content.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.