mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• Fixed a bunch of constraint violations and bugs with the VisibleMessageCell and some of it's components • Fixed a bug where some colours wouldn't be able to be resolved correctly (UIColor.black.alpha isn't a UIColor it's a UICachedDeviceWhiteColor so casting to `Self` on an extension of `UIColor` fails) • Fixed a bug where the theme preview UI had a "highlighted" state when pressed
89 lines
3.6 KiB
Swift
89 lines
3.6 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import UIKit
|
|
import Lucide
|
|
import SessionUIKit
|
|
import SignalUtilitiesKit
|
|
import SessionMessagingKit
|
|
import SessionUtilitiesKit
|
|
|
|
final class DeletedMessageView: UIView {
|
|
private static let iconSize: CGFloat = 18
|
|
private static let iconImageViewSize: CGFloat = 30
|
|
private static let horizontalInset = Values.mediumSmallSpacing
|
|
private static let verticalInset = Values.smallSpacing
|
|
|
|
// MARK: - Lifecycle
|
|
|
|
init(textColor: ThemeValue, variant: Interaction.Variant, maxWidth: CGFloat) {
|
|
super.init(frame: CGRect.zero)
|
|
accessibilityIdentifier = "Deleted message"
|
|
isAccessibilityElement = true
|
|
setUpViewHierarchy(textColor: textColor, variant: variant, maxWidth: maxWidth)
|
|
}
|
|
|
|
override init(frame: CGRect) {
|
|
preconditionFailure("Use init(textColor:) instead.")
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
preconditionFailure("Use init(textColor:) instead.")
|
|
}
|
|
|
|
private func setUpViewHierarchy(textColor: ThemeValue, variant: Interaction.Variant, maxWidth: CGFloat) {
|
|
let trashIcon = Lucide.image(icon: .trash2, size: DeletedMessageView.iconSize)?
|
|
.withRenderingMode(.alwaysTemplate)
|
|
|
|
let imageView = UIImageView(image: trashIcon)
|
|
imageView.themeTintColor = textColor
|
|
imageView.alpha = Values.highOpacity
|
|
imageView.contentMode = .scaleAspectFit
|
|
imageView.set(.width, to: DeletedMessageView.iconSize)
|
|
imageView.set(.height, to: DeletedMessageView.iconSize)
|
|
|
|
let imageViewContainer: UIView = UIView()
|
|
imageViewContainer.addSubview(imageView)
|
|
imageView.center(.vertical, in: imageViewContainer)
|
|
imageView.pin(.leading, to: .leading, of: imageViewContainer)
|
|
imageView.pin(.trailing, to: .trailing, of: imageViewContainer)
|
|
|
|
// Body label
|
|
let titleLabel = UILabel()
|
|
titleLabel.setContentHuggingPriority(.required, for: .vertical)
|
|
titleLabel.font = .italicSystemFont(ofSize: Values.mediumFontSize)
|
|
titleLabel.text = {
|
|
switch variant {
|
|
case .standardIncomingDeletedLocally, .standardOutgoingDeletedLocally:
|
|
return "deleteMessageDeletedLocally".localized()
|
|
|
|
default: return "deleteMessageDeletedGlobally".localized()
|
|
}
|
|
}()
|
|
titleLabel.themeTextColor = textColor
|
|
titleLabel.alpha = Values.highOpacity
|
|
titleLabel.lineBreakMode = .byTruncatingTail
|
|
titleLabel.numberOfLines = 2
|
|
titleLabel.setContentHugging(.vertical, to: .required)
|
|
titleLabel.setCompressionResistance(.vertical, to: .required)
|
|
|
|
// Stack view
|
|
let stackView = UIStackView(arrangedSubviews: [
|
|
imageViewContainer,
|
|
titleLabel
|
|
])
|
|
stackView.axis = .horizontal
|
|
stackView.alignment = .fill
|
|
stackView.spacing = Values.smallSpacing
|
|
stackView.isLayoutMarginsRelativeArrangement = true
|
|
stackView.layoutMargins = UIEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 6)
|
|
addSubview(stackView)
|
|
|
|
stackView.pin(.top, to: .top, of: self, withInset: Self.verticalInset)
|
|
stackView.pin(.leading, to: .leading, of: self, withInset: Self.horizontalInset)
|
|
stackView.pin(.trailing, to: .trailing, of: self, withInset: -Self.horizontalInset)
|
|
stackView.pin(.bottom, to: .bottom, of: self, withInset: -Self.verticalInset)
|
|
stackView.setContentHugging(.vertical, to: .required)
|
|
stackView.setCompressionResistance(.vertical, to: .required)
|
|
}
|
|
}
|