Render chat colors in CVC cells.
This commit is contained in:
parent
c15fb5322f
commit
fcdc7b9257
@ -6,133 +6,6 @@ import Foundation
|
||||
|
||||
@objc
|
||||
public class CVChatColorView: ManualLayoutViewWithLayer {
|
||||
//
|
||||
// private var isPreview = false
|
||||
//
|
||||
// private weak var provider: WallpaperBlurProvider?
|
||||
//
|
||||
// private let imageView = CVImageView()
|
||||
// private let maskLayer = CAShapeLayer()
|
||||
//
|
||||
// private var state: WallpaperBlurState?
|
||||
// private var maskCornerRadius: CGFloat = 0
|
||||
//
|
||||
// required init() {
|
||||
// super.init(name: "CVWallpaperBlurView")
|
||||
//
|
||||
// self.clipsToBounds = true
|
||||
// self.layer.zPosition = -1
|
||||
//
|
||||
// imageView.contentMode = .scaleAspectFill
|
||||
// imageView.layer.mask = maskLayer
|
||||
// imageView.layer.masksToBounds = true
|
||||
// addSubview(imageView)
|
||||
//
|
||||
// addLayoutBlock { [weak self] _ in
|
||||
// self?.applyLayout()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private func applyLayout() {
|
||||
// // Prevent the layers from animating changes.
|
||||
// CATransaction.begin()
|
||||
// CATransaction.setDisableActions(true)
|
||||
//
|
||||
// imageView.frame = imageViewFrame
|
||||
// maskLayer.frame = imageView.bounds
|
||||
// let maskPath = UIBezierPath(roundedRect: maskFrame, cornerRadius: maskCornerRadius)
|
||||
// maskLayer.path = maskPath.cgPath
|
||||
//
|
||||
// CATransaction.commit()
|
||||
// }
|
||||
//
|
||||
// @available(swift, obsoleted: 1.0)
|
||||
// required init(name: String) {
|
||||
// owsFail("Do not use this initializer.")
|
||||
// }
|
||||
//
|
||||
// public func configureForPreview(maskCornerRadius: CGFloat) {
|
||||
// resetContentAndConfiguration()
|
||||
//
|
||||
// self.isPreview = true
|
||||
// self.maskCornerRadius = maskCornerRadius
|
||||
//
|
||||
// updateIfNecessary()
|
||||
// }
|
||||
//
|
||||
// public func configure(provider: WallpaperBlurProvider,
|
||||
// maskCornerRadius: CGFloat) {
|
||||
// resetContentAndConfiguration()
|
||||
//
|
||||
// self.isPreview = false
|
||||
// // TODO: Observe provider changes.
|
||||
// self.provider = provider
|
||||
// self.maskCornerRadius = maskCornerRadius
|
||||
//
|
||||
// updateIfNecessary()
|
||||
// }
|
||||
//
|
||||
// public func updateIfNecessary() {
|
||||
// guard !isPreview else {
|
||||
// self.backgroundColor = Theme.backgroundColor
|
||||
// imageView.isHidden = true
|
||||
// return
|
||||
// }
|
||||
// guard let provider = provider else {
|
||||
// owsFailDebug("Missing provider.")
|
||||
// resetContentAndConfiguration()
|
||||
// return
|
||||
// }
|
||||
// guard let state = provider.wallpaperBlurState else {
|
||||
// resetContent()
|
||||
// return
|
||||
// }
|
||||
// guard state.id != self.state?.id else {
|
||||
// ensurePositioning()
|
||||
// return
|
||||
// }
|
||||
// self.state = state
|
||||
// imageView.image = state.image
|
||||
// imageView.isHidden = false
|
||||
//
|
||||
// ensurePositioning()
|
||||
// }
|
||||
//
|
||||
// private var imageViewFrame: CGRect = .zero
|
||||
// private var maskFrame: CGRect = .zero
|
||||
//
|
||||
// private func ensurePositioning() {
|
||||
// guard !isPreview else {
|
||||
// return
|
||||
// }
|
||||
// guard let state = self.state else {
|
||||
// resetContent()
|
||||
// return
|
||||
// }
|
||||
// let referenceView = state.referenceView
|
||||
// self.imageViewFrame = self.convert(referenceView.bounds, from: referenceView)
|
||||
// self.maskFrame = referenceView.convert(self.bounds, from: self)
|
||||
//
|
||||
// applyLayout()
|
||||
// }
|
||||
//
|
||||
// private func resetContent() {
|
||||
// backgroundColor = nil
|
||||
// imageView.image = nil
|
||||
// imageView.isHidden = false
|
||||
// imageViewFrame = .zero
|
||||
// maskFrame = .zero
|
||||
// state = nil
|
||||
// }
|
||||
//
|
||||
// public func resetContentAndConfiguration() {
|
||||
// isPreview = false
|
||||
// provider = nil
|
||||
// maskCornerRadius = 0
|
||||
//
|
||||
// resetContent()
|
||||
// }
|
||||
// }
|
||||
|
||||
public var chatColor: CVChatColor? {
|
||||
didSet {
|
||||
@ -171,7 +44,6 @@ public class CVChatColorView: ManualLayoutViewWithLayer {
|
||||
case .solidColor(let color):
|
||||
backgroundColor = color
|
||||
gradientLayer.removeFromSuperlayer()
|
||||
Logger.verbose("---- solid bounds: \(bounds), color: \(color.asOWSColor), ")
|
||||
case .gradient(let color1, let color2, let angleRadians):
|
||||
|
||||
if gradientLayer.superlayer != self.layer {
|
||||
@ -211,9 +83,6 @@ public class CVChatColorView: ManualLayoutViewWithLayer {
|
||||
gradientLayer.startPoint = convertToCoreGraphicsUnit(point: unitCenter + startVector * +startScale)
|
||||
// The endpoint should be "opposite" the start point, on the opposite edge of the view.
|
||||
gradientLayer.endPoint = convertToCoreGraphicsUnit(point: unitCenter + startVector * -startScale)
|
||||
|
||||
Logger.verbose("---- gradientLayer.frame: \(gradientLayer.frame), color1: \(color1.asOWSColor), color2: \(color2.asOWSColor), ")
|
||||
Logger.verbose("---- gradientLayer.startPoint: \(gradientLayer.startPoint), gradientLayer.endPoint: \(gradientLayer.endPoint), ")
|
||||
}
|
||||
|
||||
CATransaction.commit()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user