Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ final class JetpackBrandingMenuCardPresenterTests: CoreDataTestCase {
config.description,
"Unlock your site’s full potential. Get Stats, Reader, Notifications and more with Jetpack."
)
XCTAssertEqual(config.type, .expanded)
}

func testNoCardConfigOutsideSelfHostedPhase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ class BlogDashboardCardFrameView: UIView {
if !ellipsisButton.isHidden {
mainStackViewTrailingConstraint?.constant = -Constants.mainStackViewTrailingPadding
if #available(iOS 26, *) {
buttonContainerStackView.directionalLayoutMargins = NSDirectionalEdgeInsets(top: 5, leading: 0, bottom: 0, trailing: 0)
buttonContainerStackView.directionalLayoutMargins = NSDirectionalEdgeInsets(
top: 5,
leading: 0,
bottom: 0,
trailing: 0
)
buttonContainerStackView.isLayoutMarginsRelativeArrangement = true
}
}
Expand Down Expand Up @@ -182,19 +187,21 @@ class BlogDashboardCardFrameView: UIView {
addSubview(buttonContainerStackView)

NSLayoutConstraint.activate([
buttonContainerStackView.topAnchor.constraint(equalTo: topAnchor, constant: Constants.buttonContainerStackViewPadding),
buttonContainerStackView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -Constants.buttonContainerStackViewPadding)
buttonContainerStackView.topAnchor.constraint(
equalTo: topAnchor,
constant: Constants.buttonContainerStackViewPadding
),
buttonContainerStackView.trailingAnchor.constraint(
equalTo: trailingAnchor,
constant: -Constants.buttonContainerStackViewPadding
)
])

buttonContainerStackView.addArrangedSubviews([
ellipsisButton
])
}

func removeButtonContainerStackView() {
buttonContainerStackView.removeFromSuperview()
}

/// Adds the "more" button with the given actions to the corner of the cell.
func addMoreMenu(items: [UIMenuElement], card: DashboardCard) {
self.addMoreMenu(items: items, card: card as BlogDashboardAnalyticPropertiesProviding)
Expand All @@ -211,9 +218,9 @@ class BlogDashboardCardFrameView: UIView {

private func updateEllipsisButtonState() {
ellipsisButton.isHidden = onEllipsisButtonTap == nil
let headerPadding = ellipsisButton.isHidden ?
Constants.headerPaddingWithEllipsisButtonHidden :
Constants.headerPaddingWithEllipsisButtonShown
let headerPadding =
ellipsisButton.isHidden
? Constants.headerPaddingWithEllipsisButtonHidden : Constants.headerPaddingWithEllipsisButtonShown
headerStackView.directionalLayoutMargins = headerPadding
}

Expand Down Expand Up @@ -246,34 +253,49 @@ class BlogDashboardCardFrameView: UIView {
@objc private func headerTapped() {
if let onHeaderTap {
onHeaderTap()
}
else {
} else {
onViewTap?()
}
}

private static func titleAttributedText(title: String, hint: String?, font: UIFont?) -> NSAttributedString {
let titleString = NSMutableAttributedString(string: title)
if let hint, let range = title.nsRange(of: hint) {
titleString.addAttributes([
.foregroundColor: UIAppColor.primary,
.font: font as Any
], range: range)
titleString.addAttributes(
[
.foregroundColor: UIAppColor.primary,
.font: font as Any
],
range: range
)
}
return titleString
}

private enum Constants {
static let bottomPadding: CGFloat = 8
static let headerPaddingWithEllipsisButtonHidden = NSDirectionalEdgeInsets(top: 12, leading: 16, bottom: 8, trailing: 16)
static let headerPaddingWithEllipsisButtonShown = NSDirectionalEdgeInsets(top: 12, leading: 16, bottom: 8, trailing: 8)
static let headerPaddingWithEllipsisButtonHidden = NSDirectionalEdgeInsets(
top: 12,
leading: 16,
bottom: 8,
trailing: 16
)
static let headerPaddingWithEllipsisButtonShown = NSDirectionalEdgeInsets(
top: 12,
leading: 16,
bottom: 8,
trailing: 8
)
static let headerHorizontalSpacing: CGFloat = 5
static let cornerRadius = DesignConstants.radius(.large)
static let buttonContainerStackViewPadding: CGFloat = 8
static let mainStackViewTrailingPadding: CGFloat = 32
}

private enum Strings {
static let ellipsisButtonAccessibilityLabel = NSLocalizedString("More", comment: "Accessibility label for more button in dashboard quick start card.")
static let ellipsisButtonAccessibilityLabel = NSLocalizedString(
"More",
comment: "Accessibility label for more button in dashboard quick start card."
)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import Foundation

protocol JetpackBrandedScreen {

/// Name to use when constructing phase three branding text.
/// Set to `nil` to fallback to the default branding text.
var featureName: String? { get }

/// Whether the feature is in plural form.
/// Used to decide on using "is" or "are" when constructing the branding text.
var isPlural: Bool { get }
}

enum JetpackBannerScreen: String, JetpackBrandedScreen {
enum JetpackBannerScreen: String {
case activityLog = "activity_log"
case backup
case menus
Expand All @@ -22,59 +11,9 @@ enum JetpackBannerScreen: String, JetpackBrandedScreen {
case scan
case stats
case themes

var featureName: String? {
switch self {
case .activityLog:
return NSLocalizedString("Activity", comment: "Noun. Name of the Activity Log feature")
case .backup:
return NSLocalizedString("Backup", comment: "Noun. Name of the Backup feature")
case .menus:
return NSLocalizedString("Menus", comment: "Noun. Name of the Menus feature")
case .notifications:
return NSLocalizedString("Notifications", comment: "Noun. Name of the Notifications feature")
case .people:
return nil
case .reader:
return NSLocalizedString("Reader", comment: "Noun. Name of the Reader feature")
case .readerSearch:
return NSLocalizedString("Reader", comment: "Noun. Name of the Reader feature")
case .scan:
return NSLocalizedString("Scan", comment: "Noun. Name of the Scan feature")
case .stats:
return NSLocalizedString("Stats", comment: "Noun. Abbreviation of Statistics. Name of the Stats feature")
case .themes:
return NSLocalizedString("Themes", comment: "Noun. Name of the Themes feature")
}
}

var isPlural: Bool {
switch self {
case .activityLog:
fallthrough
case .backup:
fallthrough
case .reader:
fallthrough
case .people:
fallthrough
case .scan:
fallthrough
case .readerSearch:
return false
case .notifications:
fallthrough
case .menus:
fallthrough
case .themes:
fallthrough
case .stats:
return true
}
}
}

enum JetpackBadgeScreen: String, JetpackBrandedScreen {
enum JetpackBadgeScreen: String {
case activityDetail = "activity_detail"
case appSettings = "app_settings"
case home
Expand All @@ -83,46 +22,4 @@ enum JetpackBadgeScreen: String, JetpackBrandedScreen {
case person
case readerDetail = "reader_detail"
case sharing

var featureName: String? {
switch self {
case .appSettings:
fallthrough
case .home:
fallthrough
case .person:
fallthrough
case .me:
return nil
case .activityDetail:
return NSLocalizedString("Activity", comment: "Noun. Name of the Activity Log feature")
case .notificationsSettings:
return NSLocalizedString("Notifications", comment: "Noun. Name of the Notifications feature")
case .readerDetail:
return NSLocalizedString("Reader", comment: "Noun. Name of the Reader feature")
case .sharing:
return NSLocalizedString("Sharing", comment: "Noun. Name of the Social Sharing feature")
}
}

var isPlural: Bool {
switch self {
case .appSettings:
fallthrough
case .home:
fallthrough
case .me:
fallthrough
case .activityDetail:
fallthrough
case .readerDetail:
fallthrough
case .person:
fallthrough
case .sharing:
return false
case .notificationsSettings:
return true
}
}
}
Loading