Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ba0c1ec
Author: Dario Carlomagno <dario.carlomagno@ecosia.org>
Date:   Thu May 16 16:19:22 2024 +0200

    Add News Items locators

commit e3503f4
Author: Dario Carlomagno <dario.carlomagno@ecosia.org>
Date:   Thu May 16 16:13:43 2024 +0200

    Add NTP imageView's accessibilityIdentifier
  • Loading branch information
d4r1091 committed May 16, 2024
1 parent 7c4a42d commit 8b7c87d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Client/Ecosia/UI/NTP/Impact/ClimateImpactInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ enum ClimateImpactInfo: Equatable {
}
}

var imageAccessibilityIdentifier: String? {
switch self {
case .search:
"search_image"
case .referral:
"referral_image"
case .totalTrees:
"total_trees_image"
case .totalInvested:
"total_invested_image"
}
}

var progressIndicatorValue: Double? {
switch self {
case .search:
Expand Down
1 change: 1 addition & 0 deletions Client/Ecosia/UI/NTP/Impact/NTPImpactRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ final class NTPImpactRowView: UIView, Themeable {
var info: ClimateImpactInfo {
didSet {
imageView.image = info.image
imageView.accessibilityIdentifier = info.imageAccessibilityIdentifier
titleLabel.text = info.title
subtitleLabel.text = info.subtitle
actionButton.isHidden = forceHideActionButton ? true : info.buttonTitle == nil
Expand Down
4 changes: 4 additions & 0 deletions Client/Ecosia/UI/NTP/News/NTPNewsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,16 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell {
func configure(_ model: NewsModel, images: Images, row: Int, totalCount: Int) {
let titleString = model.text.replacingOccurrences(of: "<[^>]+>", with: "", options: .regularExpression)
title.text = titleString
title.accessibilityIdentifier = "news_item_title_\(row)"
let publishDateString = RelativeDateTimeFormatter().localizedString(for: model.publishDate, relativeTo: .init())
bottomLabel.text = publishDateString
bottomLabel.accessibilityIdentifier = "news_item_published_date_\(row)"
bottomIcon.isHidden = true
highlightLabel.isHidden = true

imageUrl = model.imageUrl
image.image = nil
image.accessibilityIdentifier = "news_item_image_\(row)"
images.load(self, url: model.imageUrl) { [weak self] in
guard self?.imageUrl == $0.url else { return }
self?.updateImage($0.data)
Expand All @@ -200,6 +203,7 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell {
applyTheme()

isAccessibilityElement = true
accessibilityIdentifier = "news_item"
accessibilityLabel = "\(titleString); \(publishDateString)"
accessibilityTraits = .link
shouldGroupAccessibilityChildren = true
Expand Down

0 comments on commit 8b7c87d

Please sign in to comment.