mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit 'd4a1857d6cd5f175057328ac370db09b9645ea58'
This commit is contained in:
commit
849e0224b9
@ -635,7 +635,7 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
|
|||||||
|
|
||||||
func getRenderImage() -> UIImage? {
|
func getRenderImage() -> UIImage? {
|
||||||
let rect = self.bounds
|
let rect = self.bounds
|
||||||
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
|
UIGraphicsBeginImageContextWithOptions(rect.size, false, 2.0)
|
||||||
self.textView.drawHierarchy(in: rect, afterScreenUpdates: true)
|
self.textView.drawHierarchy(in: rect, afterScreenUpdates: true)
|
||||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||||
UIGraphicsEndImageContext()
|
UIGraphicsEndImageContext()
|
||||||
|
@ -257,7 +257,7 @@ public extension TelegramEngine {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let message else {
|
guard let message = message else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +267,9 @@ private func makeEditorImageFrameComposition(context: CIContext, inputImage: CII
|
|||||||
image = image.transformed(by: resetTransform)
|
image = image.transformed(by: resetTransform)
|
||||||
|
|
||||||
var baseScale: CGFloat = 1.0
|
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
|
baseScale = baseSize.width / image.extent.width
|
||||||
if baseSize.width != baseSize.height {
|
if baseSize.width != baseSize.height {
|
||||||
baseScale *= min(baseSize.width, baseSize.height) / max(baseSize.width, baseSize.height)
|
baseScale *= min(baseSize.width, baseSize.height) / max(baseSize.width, baseSize.height)
|
||||||
|
@ -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)]
|
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]) {
|
} else if let renderImage = entity.renderImage, let image = CIImage(image: renderImage, options: [.colorSpace: colorSpace]) {
|
||||||
if let entity = entity as? DrawingBubbleEntity {
|
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 {
|
} 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 {
|
} 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 {
|
} else if let entity = entity as? DrawingTextEntity {
|
||||||
var entities: [MediaEditorComposerEntity] = []
|
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 {
|
if let renderSubEntities = entity.renderSubEntities {
|
||||||
for subEntity in renderSubEntities {
|
for subEntity in renderSubEntities {
|
||||||
entities.append(contentsOf: composerEntitiesForDrawingEntity(account: account, entity: subEntity, colorSpace: colorSpace))
|
entities.append(contentsOf: composerEntitiesForDrawingEntity(account: account, entity: subEntity, colorSpace: colorSpace))
|
||||||
@ -53,14 +53,16 @@ private class MediaEditorComposerStaticEntity: MediaEditorComposerEntity {
|
|||||||
let scale: CGFloat
|
let scale: CGFloat
|
||||||
let rotation: CGFloat
|
let rotation: CGFloat
|
||||||
let baseSize: CGSize?
|
let baseSize: CGSize?
|
||||||
|
let baseScale: CGFloat?
|
||||||
let mirrored: Bool
|
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.image = image
|
||||||
self.position = position
|
self.position = position
|
||||||
self.scale = scale
|
self.scale = scale
|
||||||
self.rotation = rotation
|
self.rotation = rotation
|
||||||
self.baseSize = baseSize
|
self.baseSize = baseSize
|
||||||
|
self.baseScale = baseScale
|
||||||
self.mirrored = mirrored
|
self.mirrored = mirrored
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +90,7 @@ private class MediaEditorComposerStickerEntity: MediaEditorComposerEntity {
|
|||||||
let scale: CGFloat
|
let scale: CGFloat
|
||||||
let rotation: CGFloat
|
let rotation: CGFloat
|
||||||
let baseSize: CGSize?
|
let baseSize: CGSize?
|
||||||
|
let baseScale: CGFloat? = nil
|
||||||
let mirrored: Bool
|
let mirrored: Bool
|
||||||
let colorSpace: CGColorSpace
|
let colorSpace: CGColorSpace
|
||||||
let isStatic: Bool
|
let isStatic: Bool
|
||||||
@ -433,6 +436,7 @@ protocol MediaEditorComposerEntity {
|
|||||||
var scale: CGFloat { get }
|
var scale: CGFloat { get }
|
||||||
var rotation: CGFloat { get }
|
var rotation: CGFloat { get }
|
||||||
var baseSize: CGSize? { get }
|
var baseSize: CGSize? { get }
|
||||||
|
var baseScale: CGFloat? { get }
|
||||||
var mirrored: Bool { get }
|
var mirrored: Bool { get }
|
||||||
|
|
||||||
func image(for time: CMTime, frameRate: Float, context: CIContext, completion: @escaping (CIImage?) -> Void)
|
func image(for time: CMTime, frameRate: Float, context: CIContext, completion: @escaping (CIImage?) -> Void)
|
||||||
|
@ -3638,7 +3638,9 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
|||||||
let codableEntities = DrawingEntitiesView.encodeEntities(entities, entitiesView: self.node.entitiesView)
|
let codableEntities = DrawingEntitiesView.encodeEntities(entities, entitiesView: self.node.entitiesView)
|
||||||
mediaEditor.setDrawingAndEntities(data: nil, image: mediaEditor.values.drawing, entities: codableEntities)
|
mediaEditor.setDrawingAndEntities(data: nil, image: mediaEditor.values.drawing, entities: codableEntities)
|
||||||
|
|
||||||
let caption = self.getCaption()
|
var caption = self.getCaption()
|
||||||
|
caption = convertMarkdownToAttributes(caption)
|
||||||
|
|
||||||
let randomId: Int64
|
let randomId: Int64
|
||||||
if case let .draft(_, id) = subject, let id {
|
if case let .draft(_, id) = subject, let id {
|
||||||
randomId = id
|
randomId = id
|
||||||
|
@ -1335,7 +1335,7 @@ final class ShareWithPeersScreenComponent: Component {
|
|||||||
sideInset: sideInset,
|
sideInset: sideInset,
|
||||||
title: "Name",
|
title: "Name",
|
||||||
peer: nil,
|
peer: nil,
|
||||||
subtitle: nil,
|
subtitle: "sub",
|
||||||
subtitleAccessory: .none,
|
subtitleAccessory: .none,
|
||||||
presence: nil,
|
presence: nil,
|
||||||
selectionState: .editing(isSelected: false, isTinted: false),
|
selectionState: .editing(isSelected: false, isTinted: false),
|
||||||
|
@ -3548,12 +3548,12 @@ public final class StoryItemSetContainerComponent: Component {
|
|||||||
|
|
||||||
var tip: ContextController.Tip?
|
var tip: ContextController.Tip?
|
||||||
var tipSignal: Signal<ContextController.Tip?, NoError>?
|
var tipSignal: Signal<ContextController.Tip?, NoError>?
|
||||||
if hasLinkedStickers {
|
if hasLinkedStickers, let peerReference = PeerReference(component.slice.peer._asPeer()) {
|
||||||
let context = component.context
|
let context = component.context
|
||||||
tip = .animatedEmoji(text: nil, arguments: nil, file: nil, action: nil)
|
tip = .animatedEmoji(text: nil, arguments: nil, file: nil, action: nil)
|
||||||
|
|
||||||
let packsPromise = Promise<[StickerPackReference]>()
|
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
|
let action: () -> Void = { [weak self] in
|
||||||
if let self {
|
if let self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user