This commit is contained in:
ddisfriend
2025-09-18 17:18:22 +08:00
parent f1c64d57f3
commit a3c631806d

View File

@@ -438,6 +438,24 @@ open class ReviewFailedView : DDView {
} }
} }
// Gradient button subclass for ReviewFailedCell buttons
public final class DDGradientButton: DDButton {
public override class var layerClass: AnyClass { CAGradientLayer.self }
var gradientLayer: CAGradientLayer { return self.layer as! CAGradientLayer }
func configureGradient(start: CGPoint = CGPoint(x: 0, y: 0),
end: CGPoint = CGPoint(x: 1, y: 1),
locations: [NSNumber] = [0.0, 1.0],
colors: [CGColor]) {
gradientLayer.startPoint = start
gradientLayer.endPoint = end
gradientLayer.locations = locations
gradientLayer.colors = colors
gradientLayer.masksToBounds = true
gradientLayer.needsDisplayOnBoundsChange = true
}
}
open class ReviewFailedCell : DDTableViewCell { open class ReviewFailedCell : DDTableViewCell {
public let radiusView : DDView public let radiusView : DDView
public let typeLabel : DDLabel public let typeLabel : DDLabel
@@ -447,28 +465,8 @@ open class ReviewFailedCell : DDTableViewCell {
public let descLabel : DDLabel public let descLabel : DDLabel
public let dateLabel : DDLabel public let dateLabel : DDLabel
public let stackView : UIStackView public let stackView : UIStackView
public let appealButton : DDButton public let appealButton : DDGradientButton
public var appealLayer : CAGradientLayer = { public let additionalButton : DDGradientButton
var layer = CAGradientLayer.init()
layer.startPoint = CGPoint(x: 0, y: 0)
layer.endPoint = CGPoint(x: 1, y: 1)
layer.locations = [0.0,1.0]
layer.colors = [UIColor.hex("FF5A2C").cgColor,UIColor.hex("FE9D4D").cgColor]
layer.cornerRadius = auto(4)
layer.masksToBounds = true
return layer
}()
public let additionalButton : DDButton
public var additionalLayer : CAGradientLayer = {
var layer = CAGradientLayer.init()
layer.startPoint = CGPoint(x: 0, y: 0)
layer.endPoint = CGPoint(x: 1, y: 1)
layer.locations = [0.0,1.0]
layer.colors = [UIColor.hex("FF5A2C").cgColor,UIColor.hex("FE9D4D").cgColor]
layer.cornerRadius = auto(4)
layer.masksToBounds = true
return layer
}()
public var disposeBag = DisposeBag() public var disposeBag = DisposeBag()
public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
@@ -480,8 +478,8 @@ open class ReviewFailedCell : DDTableViewCell {
descLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("FF8F37")) descLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("FF8F37"))
dateLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000").alpha(0.55)) dateLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000").alpha(0.55))
stackView = UIStackView() stackView = UIStackView()
additionalButton = DDButton.dd_initCustom() additionalButton = DDGradientButton()
appealButton = DDButton.dd_initCustom() appealButton = DDGradientButton()
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
backgroundColor = .hex("F4F5F7") backgroundColor = .hex("F4F5F7")
@@ -513,16 +511,16 @@ open class ReviewFailedCell : DDTableViewCell {
appealButton.layer.cornerRadius = auto(4) appealButton.layer.cornerRadius = auto(4)
appealButton.layer.masksToBounds = true appealButton.layer.masksToBounds = true
appealButton.contentEdgeInsets = UIEdgeInsets(top: auto(6), left: auto(12), bottom: auto(6), right: auto(12)) appealButton.contentEdgeInsets = UIEdgeInsets(top: auto(6), left: auto(12), bottom: auto(6), right: auto(12))
appealButton.configureGradient(colors: [UIColor.hex("FF5A2C").cgColor, UIColor.hex("FE9D4D").cgColor])
stackView.addArrangedSubview(appealButton) stackView.addArrangedSubview(appealButton)
appealButton.layer.insertSublayer(appealLayer, at: 0)
additionalButton.setTitle("补充", for: .normal) additionalButton.setTitle("补充", for: .normal)
additionalButton.setTitleColor(.white, for: .normal) additionalButton.setTitleColor(.white, for: .normal)
additionalButton.titleLabel?.font = .mediumFont(auto(13)) additionalButton.titleLabel?.font = .mediumFont(auto(13))
additionalButton.layer.cornerRadius = auto(4) additionalButton.layer.cornerRadius = auto(4)
additionalButton.layer.masksToBounds = true additionalButton.layer.masksToBounds = true
additionalButton.contentEdgeInsets = UIEdgeInsets(top: auto(6), left: auto(12), bottom: auto(6), right: auto(12)) additionalButton.contentEdgeInsets = UIEdgeInsets(top: auto(6), left: auto(12), bottom: auto(6), right: auto(12))
additionalButton.configureGradient(colors: [UIColor.hex("FF5A2C").cgColor, UIColor.hex("FE9D4D").cgColor])
stackView.addArrangedSubview(additionalButton) stackView.addArrangedSubview(additionalButton)
additionalButton.layer.insertSublayer(additionalLayer, at: 0)
radiusView.snp.makeConstraints { make in radiusView.snp.makeConstraints { make in
make.left.top.equalTo(auto(10)) make.left.top.equalTo(auto(10))
@@ -584,8 +582,5 @@ open class ReviewFailedCell : DDTableViewCell {
open override func layoutSubviews() { open override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
// Match gradient layers to button bounds
appealLayer.frame = appealButton.bounds
additionalLayer.frame = additionalButton.bounds
} }
} }