mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various fixes
This commit is contained in:
@@ -20,9 +20,11 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
}
|
||||
|
||||
func draw(context: CGContext, size: CGSize, foregroundColor: UIColor) {
|
||||
let transitionScale = max(0.01, self.transitionFraction)
|
||||
|
||||
context.saveGState()
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: max(0.01, self.transitionFraction), y: max(0.01, self.transitionFraction))
|
||||
context.scaleBy(x: transitionScale, y: transitionScale)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
|
||||
if foregroundColor.alpha.isZero {
|
||||
@@ -38,56 +40,23 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
switch self.icon {
|
||||
case .none, .secretTimeout:
|
||||
break
|
||||
case .play:
|
||||
case .play, .pause:
|
||||
let diameter = size.width
|
||||
let factor = diameter / 50.0
|
||||
|
||||
let size: CGSize
|
||||
var offset: CGFloat = 0.0
|
||||
if let iconImage = self.iconImage {
|
||||
size = iconImage.size
|
||||
offset = self.iconOffset
|
||||
} else {
|
||||
offset = 1.5
|
||||
size = CGSize(width: 15.0, height: 18.0)
|
||||
}
|
||||
context.translateBy(x: (diameter - size.width) / 2.0 + offset, y: (diameter - size.height) / 2.0)
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: factor, y: factor)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
}
|
||||
if let iconImage = self.iconImage {
|
||||
context.saveGState()
|
||||
let iconRect = CGRect(origin: CGPoint(), size: iconImage.size)
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
context.clip(to: iconRect, mask: iconImage.cgImage!)
|
||||
context.fill(iconRect)
|
||||
context.restoreGState()
|
||||
} else {
|
||||
let _ = try? drawSvgPath(context, path: "M1.71891969,0.209353049 C0.769586558,-0.350676705 0,0.0908839327 0,1.18800046 L0,16.8564753 C0,17.9569971 0.750549162,18.357187 1.67393713,17.7519379 L14.1073836,9.60224049 C15.0318735,8.99626906 15.0094718,8.04970371 14.062401,7.49100858 L1.71891969,0.209353049 ")
|
||||
context.fillPath()
|
||||
}
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0 / 0.8, y: 1.0 / 0.8)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
}
|
||||
context.translateBy(x: -(diameter - size.width) / 2.0 - offset, y: -(diameter - size.height) / 2.0)
|
||||
case .pause:
|
||||
let diameter = size.width
|
||||
let factor = diameter / 50.0
|
||||
|
||||
let size: CGSize
|
||||
let offset: CGFloat
|
||||
if let iconImage = self.iconImage {
|
||||
size = iconImage.size
|
||||
offset = self.iconOffset
|
||||
} else {
|
||||
size = CGSize(width: 15.0, height: 16.0)
|
||||
offset = 0.0
|
||||
if case .play = self.icon {
|
||||
offset = 1.5
|
||||
size = CGSize(width: 15.0, height: 18.0)
|
||||
} else {
|
||||
size = CGSize(width: 15.0, height: 16.0)
|
||||
offset = 0.0
|
||||
}
|
||||
}
|
||||
context.translateBy(x: (diameter - size.width) / 2.0 + offset, y: (diameter - size.height) / 2.0)
|
||||
if (diameter < 40.0) {
|
||||
@@ -97,7 +66,7 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
}
|
||||
if let iconImage = self.iconImage {
|
||||
context.saveGState()
|
||||
let iconRect = CGRect(origin: CGPoint(), size: iconImage.size)
|
||||
let iconRect = CGRect(origin: CGPoint(), size: iconImage.size)//.applying(CGAffineTransformMakeScale(transitionScale, transitionScale))
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
@@ -105,26 +74,22 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
|
||||
context.fill(iconRect)
|
||||
context.restoreGState()
|
||||
} else {
|
||||
let _ = try? drawSvgPath(context, path: "M0,1.00087166 C0,0.448105505 0.443716645,0 0.999807492,0 L4.00019251,0 C4.55237094,0 5,0.444630861 5,1.00087166 L5,14.9991283 C5,15.5518945 4.55628335,16 4.00019251,16 L0.999807492,16 C0.447629061,16 0,15.5553691 0,14.9991283 L0,1.00087166 Z M10,1.00087166 C10,0.448105505 10.4437166,0 10.9998075,0 L14.0001925,0 C14.5523709,0 15,0.444630861 15,1.00087166 L15,14.9991283 C15,15.5518945 14.5562834,16 14.0001925,16 L10.9998075,16 C10.4476291,16 10,15.5553691 10,14.9991283 L10,1.00087166 ")
|
||||
if case .play = self.icon {
|
||||
let _ = try? drawSvgPath(context, path: "M1.71891969,0.209353049 C0.769586558,-0.350676705 0,0.0908839327 0,1.18800046 L0,16.8564753 C0,17.9569971 0.750549162,18.357187 1.67393713,17.7519379 L14.1073836,9.60224049 C15.0318735,8.99626906 15.0094718,8.04970371 14.062401,7.49100858 L1.71891969,0.209353049 ")
|
||||
} else {
|
||||
let _ = try? drawSvgPath(context, path: "M0,1.00087166 C0,0.448105505 0.443716645,0 0.999807492,0 L4.00019251,0 C4.55237094,0 5,0.444630861 5,1.00087166 L5,14.9991283 C5,15.5518945 4.55628335,16 4.00019251,16 L0.999807492,16 C0.447629061,16 0,15.5553691 0,14.9991283 L0,1.00087166 Z M10,1.00087166 C10,0.448105505 10.4437166,0 10.9998075,0 L14.0001925,0 C14.5523709,0 15,0.444630861 15,1.00087166 L15,14.9991283 C15,15.5518945 14.5562834,16 14.0001925,16 L10.9998075,16 C10.4476291,16 10,15.5553691 10,14.9991283 L10,1.00087166 ")
|
||||
}
|
||||
context.fillPath()
|
||||
}
|
||||
if (diameter < 40.0) {
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0 / 0.8, y: 1.0 / 0.8)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
}
|
||||
context.translateBy(x: -(diameter - size.width) / 2.0, y: -(diameter - size.height) / 2.0)
|
||||
case let .custom(image):
|
||||
let diameter = size.width
|
||||
let imageRect = CGRect(origin: CGPoint(x: floor((diameter - image.size.width) / 2.0), y: floor((diameter - image.size.height) / 2.0)), size: image.size)
|
||||
|
||||
context.saveGState()
|
||||
context.translateBy(x: imageRect.midX, y: imageRect.midY)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -imageRect.midX, y: -imageRect.midY)
|
||||
context.clip(to: imageRect, mask: image.cgImage!)
|
||||
context.fill(imageRect)
|
||||
context.restoreGState()
|
||||
case .download:
|
||||
let diameter = size.width
|
||||
let factor = diameter / 50.0
|
||||
|
||||
Reference in New Issue
Block a user