mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various improvements
This commit is contained in:
@@ -142,8 +142,6 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
return image
|
||||
} else if case .message = self.stickerEntity.content {
|
||||
return self.animatedImageView?.image
|
||||
} else if case .link = self.stickerEntity.content {
|
||||
return self.animatedImageView?.image
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@@ -171,13 +169,6 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
return CGSize(width: 512.0, height: 512.0)
|
||||
case let .message(_, size, _, _, _):
|
||||
return size
|
||||
case let .link(_, _, _, _, size, compactSize, style):
|
||||
switch style {
|
||||
case .white, .black:
|
||||
return size ?? compactSize
|
||||
case .whiteCompact, .blackCompact:
|
||||
return compactSize
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,10 +296,6 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
if let file, let _ = mediaRect {
|
||||
self.setupWithVideo(file)
|
||||
}
|
||||
} else if case .link = self.stickerEntity.content {
|
||||
if let image = self.stickerEntity.renderImage {
|
||||
self.setupWithImage(image, overlayImage: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,37 +681,7 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
func onDeselection() {
|
||||
|
||||
}
|
||||
|
||||
override func selectedTapAction() -> Bool {
|
||||
if case let .link(url, name, positionBelowText, largeMedia, size, compactSize, style) = self.stickerEntity.content {
|
||||
let values = [self.entity.scale, self.entity.scale * 0.93, self.entity.scale]
|
||||
let keyTimes = [0.0, 0.33, 1.0]
|
||||
self.layer.animateKeyframes(values: values as [NSNumber], keyTimes: keyTimes as [NSNumber], duration: 0.3, keyPath: "transform.scale")
|
||||
|
||||
let updatedStyle: DrawingStickerEntity.Content.LinkStyle
|
||||
switch style {
|
||||
case .white:
|
||||
updatedStyle = .black
|
||||
case .black:
|
||||
updatedStyle = .whiteCompact
|
||||
case .whiteCompact:
|
||||
updatedStyle = .blackCompact
|
||||
case .blackCompact:
|
||||
if let _ = size {
|
||||
updatedStyle = .white
|
||||
} else {
|
||||
updatedStyle = .whiteCompact
|
||||
}
|
||||
}
|
||||
self.stickerEntity.content = .link(url, name, positionBelowText, largeMedia, size, compactSize, updatedStyle)
|
||||
self.animatedImageView?.image = nil
|
||||
self.update(animated: false)
|
||||
return true
|
||||
} else {
|
||||
return super.selectedTapAction()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func innerLayoutSubview(boundingSize: CGSize) -> CGSize {
|
||||
return boundingSize
|
||||
}
|
||||
@@ -744,21 +701,6 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
if let image {
|
||||
self.setupWithImage(image)
|
||||
}
|
||||
} else if case let .link(_, _, _, _, _, _, style) = self.stickerEntity.content, self.animatedImageView?.image == nil {
|
||||
let image: UIImage?
|
||||
switch style {
|
||||
case .white:
|
||||
image = self.stickerEntity.renderImage
|
||||
case .black:
|
||||
image = self.stickerEntity.secondaryRenderImage
|
||||
case .whiteCompact:
|
||||
image = self.stickerEntity.tertiaryRenderImage
|
||||
case .blackCompact:
|
||||
image = self.stickerEntity.quaternaryRenderImage
|
||||
}
|
||||
if let image {
|
||||
self.setupWithImage(image)
|
||||
}
|
||||
}
|
||||
|
||||
self.updateMirroring(animated: animated)
|
||||
@@ -811,7 +753,7 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
}
|
||||
|
||||
override func updateSelectionView() {
|
||||
guard let selectionView = self.selectionView as? DrawingStickerEntititySelectionView else {
|
||||
guard let selectionView = self.selectionView as? DrawingStickerEntitySelectionView else {
|
||||
return
|
||||
}
|
||||
self.pushIdentityTransformForMeasurement()
|
||||
@@ -834,7 +776,7 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
if let selectionView = self.selectionView {
|
||||
return selectionView
|
||||
}
|
||||
let selectionView = DrawingStickerEntititySelectionView()
|
||||
let selectionView = DrawingStickerEntitySelectionView()
|
||||
selectionView.entityView = self
|
||||
return selectionView
|
||||
}
|
||||
@@ -880,7 +822,7 @@ public class DrawingStickerEntityView: DrawingEntityView {
|
||||
}
|
||||
}
|
||||
|
||||
final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView {
|
||||
final class DrawingStickerEntitySelectionView: DrawingEntitySelectionView {
|
||||
private let border = SimpleShapeLayer()
|
||||
private let leftHandle = SimpleShapeLayer()
|
||||
private let rightHandle = SimpleShapeLayer()
|
||||
@@ -1160,14 +1102,6 @@ final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView {
|
||||
if case .message = entity.content {
|
||||
cornerRadius *= 2.1
|
||||
count = 24
|
||||
} else if case .link = entity.content {
|
||||
count = 24
|
||||
if height > 0.0 && width / height > 5.0 {
|
||||
height *= 1.6
|
||||
} else {
|
||||
cornerRadius *= 2.1
|
||||
height *= 1.2
|
||||
}
|
||||
} else if case .image = entity.content {
|
||||
count = 24
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user