mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Various fixes
This commit is contained in:
@@ -253,6 +253,9 @@
|
||||
"PUSH_CHAT_REACT_INVOICE" = "%2$@|%1$@ %3$@ to your invoice";
|
||||
"PUSH_CHAT_REACT_GIF" = "%2$@|%1$@ %3$@ to your GIF";
|
||||
|
||||
"PUSH_MESSAGE_SUGGEST_USERPIC" = "%1$@ suggested you new profile photo";
|
||||
|
||||
|
||||
"PUSH_REMINDER_TITLE" = "🗓 Reminder";
|
||||
"PUSH_SENDER_YOU" = "📅 You";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import SwiftSignalKit
|
||||
import AppBundle
|
||||
|
||||
final class DrawingMetalView: MTKView {
|
||||
private let size: CGSize
|
||||
let size: CGSize
|
||||
|
||||
private let commandQueue: MTLCommandQueue
|
||||
fileprivate let library: MTLLibrary
|
||||
@@ -21,11 +21,6 @@ final class DrawingMetalView: MTKView {
|
||||
private var markerBrush: Brush?
|
||||
|
||||
init?(size: CGSize) {
|
||||
var size = size
|
||||
if Int(size.width) % 16 != 0 {
|
||||
size.width = ceil(size.width / 16.0) * 16.0
|
||||
}
|
||||
|
||||
let mainBundle = Bundle(for: DrawingView.self)
|
||||
guard let path = mainBundle.path(forResource: "DrawingUIBundle", ofType: "bundle") else {
|
||||
return nil
|
||||
@@ -55,6 +50,8 @@ final class DrawingMetalView: MTKView {
|
||||
self.isOpaque = false
|
||||
self.contentScaleFactor = 1.0
|
||||
self.isPaused = true
|
||||
self.preferredFramesPerSecond = 60
|
||||
self.presentsWithTransaction = true
|
||||
|
||||
self.setup()
|
||||
}
|
||||
@@ -179,10 +176,12 @@ final class DrawingMetalView: MTKView {
|
||||
commandEncoder?.drawPrimitives(type: .triangleStrip, vertexStart: 0, vertexCount: 4)
|
||||
|
||||
commandEncoder?.endEncoding()
|
||||
if let drawable = self.currentDrawable {
|
||||
commandBuffer?.present(drawable)
|
||||
}
|
||||
commandBuffer?.commit()
|
||||
commandBuffer?.waitUntilScheduled()
|
||||
self.currentDrawable?.present()
|
||||
// if let drawable = self.currentDrawable {
|
||||
// commandBuffer?.present(drawable)
|
||||
// }
|
||||
}
|
||||
|
||||
func clear() {
|
||||
|
||||
@@ -798,9 +798,19 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
self.toolColor = brushState.color
|
||||
self.toolBrushSize = brushState.size
|
||||
|
||||
if self.metalView == nil, let metalView = DrawingMetalView(size: self.imageSize) {
|
||||
var size = self.imageSize
|
||||
if Int(size.width) % 16 != 0 {
|
||||
size.width = ceil(size.width / 16.0) * 16.0
|
||||
}
|
||||
|
||||
if self.metalView == nil, let metalView = DrawingMetalView(size: size) {
|
||||
metalView.transform = self.currentDrawingViewContainer.transform
|
||||
if size.width != self.imageSize.width {
|
||||
let scaledSize = size.preciseAspectFilled(self.currentDrawingViewContainer.frame.size)
|
||||
metalView.frame = CGRect(origin: .zero, size: scaledSize)
|
||||
} else {
|
||||
metalView.frame = self.currentDrawingViewContainer.frame
|
||||
}
|
||||
self.insertSubview(metalView, aboveSubview: self.currentDrawingViewContainer)
|
||||
self.metalView = metalView
|
||||
}
|
||||
@@ -958,8 +968,17 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
self.drawingGesturePipeline?.transform = CGAffineTransformMakeScale(1.0 / scale, 1.0 / scale)
|
||||
|
||||
if let metalView = self.metalView {
|
||||
var size = self.imageSize
|
||||
if Int(size.width) % 16 != 0 {
|
||||
size.width = ceil(size.width / 16.0) * 16.0
|
||||
}
|
||||
metalView.transform = transform
|
||||
metalView.frame = self.bounds
|
||||
if size.width != self.imageSize.width {
|
||||
let scaledSize = size.preciseAspectFilled(self.currentDrawingViewContainer.frame.size)
|
||||
metalView.frame = CGRect(origin: .zero, size: scaledSize)
|
||||
} else {
|
||||
metalView.frame = self.currentDrawingViewContainer.frame
|
||||
}
|
||||
}
|
||||
|
||||
self.brushSizePreviewLayer.position = CGPoint(x: self.bounds.width / 2.0, y: self.bounds.height / 2.0)
|
||||
@@ -978,6 +997,13 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw
|
||||
}
|
||||
}
|
||||
|
||||
private extension CGSize {
|
||||
func preciseAspectFilled(_ size: CGSize) -> CGSize {
|
||||
let scale = max(size.width / max(1.0, self.width), size.height / max(1.0, self.height))
|
||||
return CGSize(width: self.width * scale, height: self.height * scale)
|
||||
}
|
||||
}
|
||||
|
||||
private class DrawingSlice {
|
||||
private static let queue = Queue()
|
||||
|
||||
|
||||
@@ -448,6 +448,7 @@ class SpoilerOverlayNode: ASDisplayNode {
|
||||
override init() {
|
||||
self.blurNode = ASImageNode()
|
||||
self.blurNode.displaysAsynchronously = false
|
||||
self.blurNode.contentMode = .scaleAspectFill
|
||||
|
||||
self.dustNode = MediaDustNode()
|
||||
|
||||
|
||||
@@ -1515,11 +1515,13 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
let selectionCount = self.selectionCount
|
||||
|
||||
var hasSpoilers = false
|
||||
var hasGeneric = false
|
||||
if let selectionContext = self.interaction?.selectionState, let editingContext = self.interaction?.editingState {
|
||||
for case let item as TGMediaEditableItem in selectionContext.selectedItems() {
|
||||
if editingContext.spoiler(for: item) {
|
||||
hasSpoilers = true
|
||||
break
|
||||
} else {
|
||||
hasGeneric = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1565,7 +1567,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
if !items.isEmpty {
|
||||
items.append(.separator)
|
||||
}
|
||||
items.append(.action(ContextMenuActionItem(text: hasSpoilers ? strings.Attachment_DisableSpoiler : strings.Attachment_EnableSpoiler, icon: { _ in return nil }, animationName: "anim_spoiler", action: { [weak self] _, f in
|
||||
items.append(.action(ContextMenuActionItem(text: hasGeneric ? strings.Attachment_EnableSpoiler : strings.Attachment_DisableSpoiler, icon: { _ in return nil }, animationName: "anim_spoiler", action: { [weak self] _, f in
|
||||
f(.default)
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
@@ -1573,7 +1575,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
||||
|
||||
if let selectionContext = strongSelf.interaction?.selectionState, let editingContext = strongSelf.interaction?.editingState {
|
||||
for case let item as TGMediaEditableItem in selectionContext.selectedItems() {
|
||||
editingContext.setSpoiler(!hasSpoilers, for: item)
|
||||
editingContext.setSpoiler(hasGeneric, for: item)
|
||||
}
|
||||
}
|
||||
})))
|
||||
|
||||
@@ -709,6 +709,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
}
|
||||
}
|
||||
|
||||
let hasSpoiler = message.attributes.contains(where: { $0 is MediaSpoilerMessageAttribute })
|
||||
var isExtendedMediaPreview = false
|
||||
var isInlinePlayableVideo = false
|
||||
var isSticker = false
|
||||
@@ -1496,7 +1497,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
||||
|
||||
strongSelf.updateStatus(animated: synchronousLoads)
|
||||
|
||||
strongSelf.pinchContainerNode.isPinchGestureEnabled = !isSecretMedia && !isExtendedMediaPreview
|
||||
strongSelf.pinchContainerNode.isPinchGestureEnabled = !isSecretMedia && !isExtendedMediaPreview && !hasSpoiler
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user