Skip to content

Commit 3baaf1b

Browse files
authored
Merge pull request #18470 from wordpress-mobile/feature/18440-prompt-card-avatar-train-color
Blogging Prompts Card: Fix avatar train color
2 parents 9b8ea10 + 4bf0b3f commit 3baaf1b

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Prompts/AvatarTrainView.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ final class AvatarTrainView: UIView {
4343
// redraw border when user interface style changes.
4444
if let previousTraitCollection = previousTraitCollection,
4545
previousTraitCollection.userInterfaceStyle != traitCollection.userInterfaceStyle {
46-
avatarStackView.subviews.forEach { configureBorder(for: $0) }
46+
configureAvatarBorders()
4747
}
4848
}
4949

50+
override func layoutSubviews() {
51+
configureAvatarBorders()
52+
}
53+
5054
}
5155

5256
// MARK: Private Helpers
@@ -62,7 +66,6 @@ private extension AvatarTrainView {
6266
func makeAvatarImageView(with avatarURL: URL? = nil) -> UIImageView {
6367
let imageView = CircularImageView(image: placeholderImage)
6468
imageView.translatesAutoresizingMaskIntoConstraints = false
65-
configureBorder(for: imageView)
6669

6770
NSLayoutConstraint.activate([
6871
imageView.heightAnchor.constraint(equalToConstant: imageHeight),
@@ -76,9 +79,12 @@ private extension AvatarTrainView {
7679
return imageView
7780
}
7881

79-
func configureBorder(for view: UIView) {
80-
view.layer.borderWidth = Constants.borderWidth
81-
view.layer.borderColor = UIColor.listForeground.cgColor
82+
func configureAvatarBorders() {
83+
avatarStackView.arrangedSubviews.forEach { view in
84+
view.layer.masksToBounds = true
85+
view.layer.borderWidth = Constants.borderWidth
86+
view.layer.borderColor = UIColor.listForeground.cgColor
87+
}
8288
}
8389

8490
// MARK: Constants

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Prompts/DashboardPromptsCardCell.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
260260
super.init(coder: coder)
261261
}
262262

263+
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
264+
// refresh when the appearance style changed so the placeholder images are correctly recolored.
265+
if let previousTraitCollection = previousTraitCollection,
266+
previousTraitCollection.userInterfaceStyle != traitCollection.userInterfaceStyle {
267+
refreshStackView()
268+
}
269+
}
270+
263271
// MARK: - Public Methods
264272

265273
func configureForExampleDisplay() {
@@ -353,7 +361,10 @@ private extension DashboardPromptsCardCell {
353361

354362
struct Style {
355363
static let frameIconImage = UIImage(named: "icon-lightbulb-outline")?.resizedImage(Constants.cardIconSize, interpolationQuality: .default)
356-
static let avatarPlaceholderImage = UIImage(color: .quaternarySystemFill)
364+
static var avatarPlaceholderImage: UIImage {
365+
// this needs to be computed so the color is correct depending on the user interface style.
366+
return UIImage(color: .init(light: .quaternarySystemFill, dark: .systemGray4))
367+
}
357368
}
358369

359370
struct Constants {

0 commit comments

Comments
 (0)