mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-12 08:36:02 +01:00
fix: notification badge image color issue
This commit is contained in:
parent
7b8500e120
commit
7aaafcdc10
@ -44,14 +44,26 @@ extension NotificationSection {
|
|||||||
avatarImageURL: notification.account.avatarImageURL()
|
avatarImageURL: notification.account.avatarImageURL()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
cell.actionImageView.image = UIImage(
|
|
||||||
|
func createActionImage() -> UIImage? {
|
||||||
|
return UIImage(
|
||||||
systemName: notification.notificationType.actionImageName,
|
systemName: notification.notificationType.actionImageName,
|
||||||
withConfiguration: UIImage.SymbolConfiguration(
|
withConfiguration: UIImage.SymbolConfiguration(
|
||||||
pointSize: 12, weight: .semibold
|
pointSize: 12, weight: .semibold
|
||||||
)
|
)
|
||||||
)?
|
)?
|
||||||
.withRenderingMode(.alwaysTemplate)
|
.withTintColor(.systemBackground)
|
||||||
.af.imageAspectScaled(toFit: CGSize(width: 14, height: 14))
|
.af.imageAspectScaled(toFit: CGSize(width: 14, height: 14))
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.actionImageView.image = createActionImage()
|
||||||
|
cell.traitCollectionDidChange
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { [weak cell] in
|
||||||
|
guard let cell = cell else { return }
|
||||||
|
cell.actionImageView.image = createActionImage()
|
||||||
|
}
|
||||||
|
.store(in: &cell.disposeBag)
|
||||||
|
|
||||||
cell.actionImageView.backgroundColor = notification.notificationType.color
|
cell.actionImageView.backgroundColor = notification.notificationType.color
|
||||||
|
|
||||||
|
@ -51,16 +51,17 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
|
|||||||
return imageView
|
return imageView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
||||||
|
let traitCollectionDidChange = PassthroughSubject<Void, Never>()
|
||||||
|
|
||||||
let actionImageView: UIImageView = {
|
let actionImageView: UIImageView = {
|
||||||
let imageView = UIImageView()
|
let imageView = UIImageView()
|
||||||
imageView.contentMode = .center
|
imageView.contentMode = .center
|
||||||
imageView.tintColor = Asset.Theme.Mastodon.systemBackground.color
|
|
||||||
imageView.isOpaque = true
|
imageView.isOpaque = true
|
||||||
imageView.layer.masksToBounds = true
|
imageView.layer.masksToBounds = true
|
||||||
imageView.layer.cornerRadius = NotificationStatusTableViewCell.actionImageViewSize.width * 0.5
|
imageView.layer.cornerRadius = NotificationStatusTableViewCell.actionImageViewSize.width * 0.5
|
||||||
imageView.layer.cornerCurve = .circular
|
imageView.layer.cornerCurve = .circular
|
||||||
imageView.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth
|
imageView.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth
|
||||||
imageView.layer.borderColor = Asset.Theme.Mastodon.systemBackground.color.cgColor
|
|
||||||
imageView.layer.shouldRasterize = true
|
imageView.layer.shouldRasterize = true
|
||||||
imageView.layer.rasterizationScale = UIScreen.main.scale
|
imageView.layer.rasterizationScale = UIScreen.main.scale
|
||||||
return imageView
|
return imageView
|
||||||
@ -197,8 +198,8 @@ extension NotificationStatusTableViewCell {
|
|||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
actionImageView.centerYAnchor.constraint(equalTo: avatarContainer.bottomAnchor),
|
actionImageView.centerYAnchor.constraint(equalTo: avatarContainer.bottomAnchor),
|
||||||
actionImageView.centerXAnchor.constraint(equalTo: avatarContainer.trailingAnchor),
|
actionImageView.centerXAnchor.constraint(equalTo: avatarContainer.trailingAnchor),
|
||||||
actionImageView.widthAnchor.constraint(equalToConstant: NotificationStatusTableViewCell.actionImageViewSize.width),
|
actionImageView.widthAnchor.constraint(equalToConstant: NotificationStatusTableViewCell.actionImageViewSize.width).priority(.required - 1),
|
||||||
actionImageView.heightAnchor.constraint(equalToConstant: NotificationStatusTableViewCell.actionImageViewSize.height),
|
actionImageView.heightAnchor.constraint(equalTo: actionImageView.widthAnchor, multiplier: 1.0),
|
||||||
])
|
])
|
||||||
|
|
||||||
containerStackView.addArrangedSubview(contentStackView)
|
containerStackView.addArrangedSubview(contentStackView)
|
||||||
@ -282,14 +283,23 @@ extension NotificationStatusTableViewCell {
|
|||||||
nameLabel.addGestureRecognizer(authorNameLabelTapGestureRecognizer)
|
nameLabel.addGestureRecognizer(authorNameLabelTapGestureRecognizer)
|
||||||
|
|
||||||
resetSeparatorLineLayout()
|
resetSeparatorLineLayout()
|
||||||
|
|
||||||
|
setupBackgroundColor(theme: ThemeService.shared.currentTheme.value)
|
||||||
|
ThemeService.shared.currentTheme
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { [weak self] theme in
|
||||||
|
guard let self = self else { return }
|
||||||
|
self.setupBackgroundColor(theme: theme)
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
||||||
resetSeparatorLineLayout()
|
resetSeparatorLineLayout()
|
||||||
avatarImageView.layer.borderColor = Asset.Theme.Mastodon.systemBackground.color.cgColor
|
setupBackgroundColor(theme: ThemeService.shared.currentTheme.value)
|
||||||
statusContainerView.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor
|
traitCollectionDidChange.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func configure(isFiltered: Bool) {
|
private func configure(isFiltered: Bool) {
|
||||||
@ -297,12 +307,14 @@ extension NotificationStatusTableViewCell {
|
|||||||
filteredLabel.isHidden = !isFiltered
|
filteredLabel.isHidden = !isFiltered
|
||||||
isUserInteractionEnabled = !isFiltered
|
isUserInteractionEnabled = !isFiltered
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NotificationStatusTableViewCell {
|
extension NotificationStatusTableViewCell {
|
||||||
|
|
||||||
private func setupBackgroundColor(theme: Theme) {
|
private func setupBackgroundColor(theme: Theme) {
|
||||||
|
actionImageView.layer.borderColor = theme.systemBackgroundColor.cgColor
|
||||||
|
avatarImageView.layer.borderColor = Asset.Theme.Mastodon.systemBackground.color.cgColor
|
||||||
|
statusContainerView.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor
|
||||||
statusContainerView.backgroundColor = UIColor(dynamicProvider: { traitCollection in
|
statusContainerView.backgroundColor = UIColor(dynamicProvider: { traitCollection in
|
||||||
return traitCollection.userInterfaceStyle == .light ? theme.systemBackgroundColor : theme.tertiarySystemGroupedBackgroundColor
|
return traitCollection.userInterfaceStyle == .light ? theme.systemBackgroundColor : theme.tertiarySystemGroupedBackgroundColor
|
||||||
})
|
})
|
||||||
|
@ -35,7 +35,7 @@ extension PickServerTitleCell {
|
|||||||
|
|
||||||
private func _init() {
|
private func _init() {
|
||||||
selectionStyle = .none
|
selectionStyle = .none
|
||||||
backgroundColor = Asset.Theme.Mastodon.systemBackground.color
|
backgroundColor = Asset.Theme.Mastodon.systemGroupedBackground.color
|
||||||
|
|
||||||
contentView.addSubview(titleLabel)
|
contentView.addSubview(titleLabel)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
|
Loading…
Reference in New Issue
Block a user