Various improvements

This commit is contained in:
Ilya Laktyushin
2025-09-19 22:48:59 +04:00
parent 80a7f9fcd2
commit b65a684431
15 changed files with 476 additions and 198 deletions

View File

@@ -426,11 +426,13 @@ public final class MessageInlineBlockBackgroundView: UIView {
public let context: AccountContext
public let fileId: Int64
public let file: TelegramMediaFile?
public let emptyCorner: Bool
public init(context: AccountContext, fileId: Int64, file: TelegramMediaFile?) {
public init(context: AccountContext, fileId: Int64, file: TelegramMediaFile?, emptyCorner: Bool = false) {
self.context = context
self.fileId = fileId
self.file = file
self.emptyCorner = emptyCorner
}
public static func ==(lhs: Pattern, rhs: Pattern) -> Bool {
@@ -446,7 +448,9 @@ public final class MessageInlineBlockBackgroundView: UIView {
if lhs.file?.fileId != rhs.file?.fileId {
return false
}
if lhs.emptyCorner != rhs.emptyCorner {
return false
}
return true
}
}
@@ -771,8 +775,13 @@ public final class MessageInlineBlockBackgroundView: UIView {
patternContentLayer.frame = CGRect(origin: CGPoint(x: patternOrigin.x - placement.position.x / 3.0 - itemSize.width * 0.5, y: patternOrigin.y + placement.position.y / 3.0 - itemSize.height * 0.5), size: itemSize)
var alphaFraction = abs(placement.position.x / 3.0) / min(500.0, size.width)
alphaFraction = min(1.0, max(0.0, alphaFraction))
patternContentLayer.opacity = 0.3 * Float(1.0 - alphaFraction) * Float(patternAlpha)
if maxIndex == 1 && params.pattern?.emptyCorner == true {
patternContentLayer.opacity = 0.0
} else {
patternContentLayer.opacity = 0.3 * Float(1.0 - alphaFraction) * Float(patternAlpha)
}
maxIndex += 1
}