Skip to content

Commit

Permalink
chore: refactor code and fix alignment (RMCCX-7619)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoumenRautray committed Dec 18, 2024
1 parent 792fc43 commit 4fddba0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 4 additions & 8 deletions Sources/RInAppMessaging/Views/CarouselCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,10 @@ final class CarouselCell: UICollectionViewCell {
}

func configure(with image: UIImage?, altText: String?) {
if let image = image {
imageView.image = image
textLabel.isHidden = true
} else {
imageView.image = image
imageView.isHidden = true
textLabel.isHidden = false
}
let hasImage = (image != nil)
imageView.isHidden = !hasImage
imageView.image = image
textLabel.isHidden = hasImage
textLabel.text = altText ?? "carousel_image_load_error".localized
setNeedsLayout()
}
Expand Down
7 changes: 6 additions & 1 deletion Tests/Tests/ReadyCampaignDispatcherSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ class ReadyCampaignDispatcherSpec: QuickSpec {

// swiftlint:disable line_length
let campaign =
TestHelpers.generateCampaign(id: "test", title: "title", type: .modal, test: false, hasImage: false, customJson: CustomJson(carousel: Carousel(images: ["1": ImageDetails(imgUrl: "https://static.id.rakuten.co.jp/static/com/img/id/[email protected]", link: "https://www.google.com", altText: "error loading image")])))
TestHelpers.generateCampaign(id: "test",
title: "title",
type: .modal,
test: false,
hasImage: false,
customJson: CustomJson(carousel: Carousel(images: ["1": ImageDetails(imgUrl: "https://static.id.rakuten.co.jp/static/com/img/id/[email protected]", link: "https://www.google.com", altText: "error loading image")])))
// swiftlint:enable line_length

campaignRepository.list = [campaign]
Expand Down

0 comments on commit 4fddba0

Please sign in to comment.