Merge commit 'd4a1857d6cd5f175057328ac370db09b9645ea58'

This commit is contained in:
Ali 2023-07-07 18:55:53 +04:00
commit 849e0224b9
7 changed files with 20 additions and 12 deletions

View File

@ -635,7 +635,7 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
func getRenderImage() -> UIImage? {
let rect = self.bounds
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 2.0)
self.textView.drawHierarchy(in: rect, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

View File

@ -257,7 +257,7 @@ public extension TelegramEngine {
)
}
guard let message else {
guard let message = message else {
return .complete()
}

View File

@ -267,7 +267,9 @@ private func makeEditorImageFrameComposition(context: CIContext, inputImage: CII
image = image.transformed(by: resetTransform)
var baseScale: CGFloat = 1.0
if let baseSize = entity.baseSize {
if let entityBaseScale = entity.baseScale {
baseScale = entityBaseScale
} else if let baseSize = entity.baseSize {
baseScale = baseSize.width / image.extent.width
if baseSize.width != baseSize.height {
baseScale *= min(baseSize.width, baseSize.height) / max(baseSize.width, baseSize.height)

View File

@ -28,14 +28,14 @@ func composerEntitiesForDrawingEntity(account: Account, entity: DrawingEntity, c
return [MediaEditorComposerStickerEntity(account: account, content: content, position: entity.position, scale: entity.scale, rotation: entity.rotation, baseSize: entity.baseSize, mirrored: entity.mirrored, colorSpace: colorSpace, isStatic: entity.isExplicitlyStatic)]
} else if let renderImage = entity.renderImage, let image = CIImage(image: renderImage, options: [.colorSpace: colorSpace]) {
if let entity = entity as? DrawingBubbleEntity {
return [MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: 1.0, rotation: entity.rotation, baseSize: entity.size, mirrored: false)]
return [MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: 1.0, rotation: entity.rotation, baseSize: entity.size, baseScale: nil, mirrored: false)]
} else if let entity = entity as? DrawingSimpleShapeEntity {
return [MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: 1.0, rotation: entity.rotation, baseSize: entity.size, mirrored: false)]
return [MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: 1.0, rotation: entity.rotation, baseSize: entity.size, baseScale: nil, mirrored: false)]
} else if let entity = entity as? DrawingVectorEntity {
return [MediaEditorComposerStaticEntity(image: image, position: CGPoint(x: entity.drawingSize.width * 0.5, y: entity.drawingSize.height * 0.5), scale: 1.0, rotation: 0.0, baseSize: entity.drawingSize, mirrored: false)]
return [MediaEditorComposerStaticEntity(image: image, position: CGPoint(x: entity.drawingSize.width * 0.5, y: entity.drawingSize.height * 0.5), scale: 1.0, rotation: 0.0, baseSize: entity.drawingSize, baseScale: nil, mirrored: false)]
} else if let entity = entity as? DrawingTextEntity {
var entities: [MediaEditorComposerEntity] = []
entities.append(MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: entity.scale, rotation: entity.rotation, baseSize: nil, mirrored: false))
entities.append(MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: entity.scale, rotation: entity.rotation, baseSize: nil, baseScale: 0.5, mirrored: false))
if let renderSubEntities = entity.renderSubEntities {
for subEntity in renderSubEntities {
entities.append(contentsOf: composerEntitiesForDrawingEntity(account: account, entity: subEntity, colorSpace: colorSpace))
@ -53,14 +53,16 @@ private class MediaEditorComposerStaticEntity: MediaEditorComposerEntity {
let scale: CGFloat
let rotation: CGFloat
let baseSize: CGSize?
let baseScale: CGFloat?
let mirrored: Bool
init(image: CIImage, position: CGPoint, scale: CGFloat, rotation: CGFloat, baseSize: CGSize?, mirrored: Bool) {
init(image: CIImage, position: CGPoint, scale: CGFloat, rotation: CGFloat, baseSize: CGSize?, baseScale: CGFloat?, mirrored: Bool) {
self.image = image
self.position = position
self.scale = scale
self.rotation = rotation
self.baseSize = baseSize
self.baseScale = baseScale
self.mirrored = mirrored
}
@ -88,6 +90,7 @@ private class MediaEditorComposerStickerEntity: MediaEditorComposerEntity {
let scale: CGFloat
let rotation: CGFloat
let baseSize: CGSize?
let baseScale: CGFloat? = nil
let mirrored: Bool
let colorSpace: CGColorSpace
let isStatic: Bool
@ -433,6 +436,7 @@ protocol MediaEditorComposerEntity {
var scale: CGFloat { get }
var rotation: CGFloat { get }
var baseSize: CGSize? { get }
var baseScale: CGFloat? { get }
var mirrored: Bool { get }
func image(for time: CMTime, frameRate: Float, context: CIContext, completion: @escaping (CIImage?) -> Void)

View File

@ -3638,7 +3638,9 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
let codableEntities = DrawingEntitiesView.encodeEntities(entities, entitiesView: self.node.entitiesView)
mediaEditor.setDrawingAndEntities(data: nil, image: mediaEditor.values.drawing, entities: codableEntities)
let caption = self.getCaption()
var caption = self.getCaption()
caption = convertMarkdownToAttributes(caption)
let randomId: Int64
if case let .draft(_, id) = subject, let id {
randomId = id

View File

@ -1335,7 +1335,7 @@ final class ShareWithPeersScreenComponent: Component {
sideInset: sideInset,
title: "Name",
peer: nil,
subtitle: nil,
subtitle: "sub",
subtitleAccessory: .none,
presence: nil,
selectionState: .editing(isSelected: false, isTinted: false),

View File

@ -3548,12 +3548,12 @@ public final class StoryItemSetContainerComponent: Component {
var tip: ContextController.Tip?
var tipSignal: Signal<ContextController.Tip?, NoError>?
if hasLinkedStickers {
if hasLinkedStickers, let peerReference = PeerReference(component.slice.peer._asPeer()) {
let context = component.context
tip = .animatedEmoji(text: nil, arguments: nil, file: nil, action: nil)
let packsPromise = Promise<[StickerPackReference]>()
packsPromise.set(context.engine.stickers.stickerPacksAttachedToMedia(media: .standalone(media: media)))
packsPromise.set(context.engine.stickers.stickerPacksAttachedToMedia(media: .story(peer: peerReference, id: component.slice.item.storyItem.id, media: media)))
let action: () -> Void = { [weak self] in
if let self {