Peer star rating

This commit is contained in:
Isaac
2025-07-11 14:53:02 +04:00
parent 30ccc8017f
commit 2ed6f9616b
23 changed files with 781 additions and 200 deletions

View File

@@ -262,4 +262,63 @@ public final class TextLoadingEffectView: UIView {
self.updateAnimations(size: maskFrame.size)
}
}
public func update(color: UIColor, borderColor: UIColor, rect: CGRect, path: CGPath, transition: ContainedViewLayoutTransition) {
let maskShapeLayer: SimpleShapeLayer
if let current = self.maskShapeLayer {
maskShapeLayer = current
} else {
maskShapeLayer = SimpleShapeLayer()
maskShapeLayer.fillColor = UIColor.white.cgColor
self.maskShapeLayer = maskShapeLayer
}
let maskBorderShapeLayer: SimpleShapeLayer
if let current = self.maskBorderShapeLayer {
maskBorderShapeLayer = current
} else {
maskBorderShapeLayer = SimpleShapeLayer()
maskBorderShapeLayer.fillColor = nil
maskBorderShapeLayer.strokeColor = UIColor.white.cgColor
maskBorderShapeLayer.lineWidth = 2.0
self.maskBorderShapeLayer = maskBorderShapeLayer
}
transition.updatePath(layer: maskShapeLayer, path: path)
transition.updatePath(layer: maskBorderShapeLayer, path: path)
if self.maskContentsView.layer.mask !== maskShapeLayer {
self.maskContentsView.layer.mask = maskShapeLayer
}
if self.maskBorderContentsView.layer.mask !== maskBorderShapeLayer {
self.maskBorderContentsView.layer.mask = maskBorderShapeLayer
}
let maskFrame = CGRect(origin: CGPoint(), size: rect.size)
self.gradientWidth = 260.0
self.duration = 2.7
self.maskContentsView.backgroundColor = .clear
self.backgroundView.alpha = 0.25
self.backgroundView.isHidden = true
self.borderBackgroundView.alpha = 0.5
self.borderBackgroundView.tintColor = borderColor
transition.updateFrame(view: self.maskContentsView, frame: maskFrame)
transition.updateFrame(view: self.maskBorderContentsView, frame: maskFrame)
transition.updateFrame(layer: maskShapeLayer, frame: CGRect(origin: CGPoint(x: -maskFrame.minX, y: -maskFrame.minY), size: CGSize()))
if self.size != maskFrame.size {
self.size = maskFrame.size
transition.updateFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(x: -self.gradientWidth, y: 0.0), size: CGSize(width: self.gradientWidth, height: maskFrame.height)))
transition.updateFrame(view: self.borderBackgroundView, frame: CGRect(origin: CGPoint(x: -self.gradientWidth, y: 0.0), size: CGSize(width: self.gradientWidth, height: maskFrame.height)))
self.updateAnimations(size: maskFrame.size)
}
}
}