mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
9a875f27b2
commit
2a9344b7f5
@ -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, 3.0)
|
||||
self.textView.drawHierarchy(in: rect, afterScreenUpdates: true)
|
||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||
UIGraphicsEndImageContext()
|
||||
|
@ -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)
|
||||
|
@ -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.333, 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)
|
||||
|
@ -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
|
||||
|
@ -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),
|
||||
|
@ -3547,12 +3547,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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user