mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-28 19:05:49 +00:00
Various fixes
This commit is contained in:
parent
c90748c8d4
commit
36e4eb858b
@ -1003,11 +1003,11 @@ private final class DrawingScreenComponent: CombinedComponent {
|
||||
|
||||
self.updateEntitiesPlayback.invoke(false)
|
||||
let controller = StickerPickerScreen(context: self.context, inputData: self.stickerPickerInputData.get())
|
||||
controller.completion = { [weak self] file in
|
||||
controller.completion = { [weak self] content in
|
||||
self?.updateEntitiesPlayback.invoke(true)
|
||||
|
||||
if let file = file {
|
||||
let stickerEntity = DrawingStickerEntity(content: .file(file))
|
||||
if let content {
|
||||
let stickerEntity = DrawingStickerEntity(content: content)
|
||||
self?.insertEntity.invoke(stickerEntity)
|
||||
} else {
|
||||
self?.updateCurrentMode(.drawing)
|
||||
|
||||
@ -16,6 +16,7 @@ import TelegramNotices
|
||||
import ChatEntityKeyboardInputNode
|
||||
import ContextUI
|
||||
import ChatPresentationInterfaceState
|
||||
import MediaEditor
|
||||
|
||||
public struct StickerPickerInputData: Equatable {
|
||||
var emoji: EmojiPagerContentComponent
|
||||
@ -474,10 +475,34 @@ public class StickerPickerScreen: ViewController {
|
||||
|
||||
content.emoji.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction(
|
||||
performItemAction: { [weak self] _, item, _, _, _, _ in
|
||||
guard let strongSelf = self, let file = item.itemFile else {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.controller?.completion(file)
|
||||
if let file = item.itemFile {
|
||||
strongSelf.controller?.completion(.file(file))
|
||||
} else if case let .staticEmoji(emoji) = item.content {
|
||||
if let image = generateImage(CGSize(width: 256.0, height: 256.0), scale: 1.0, rotatedContext: { size, context in
|
||||
context.clear(CGRect(origin: .zero, size: size))
|
||||
|
||||
let attributedString = NSAttributedString(string: emoji, attributes: [NSAttributedString.Key.font: Font.regular(200), NSAttributedString.Key.foregroundColor: UIColor.white])
|
||||
|
||||
let line = CTLineCreateWithAttributedString(attributedString)
|
||||
let lineBounds = CTLineGetBoundsWithOptions(line, [.useOpticalBounds])
|
||||
|
||||
let lineOffset = CGPoint(x: 1.0 - UIScreenPixel, y: 0.0)
|
||||
let lineOrigin = CGPoint(x: floorToScreenPixels(-lineBounds.origin.x + (size.width - lineBounds.size.width) / 2.0) + lineOffset.x, y: floorToScreenPixels(-lineBounds.origin.y + (size.height - lineBounds.size.height) / 2.0) + lineOffset.y)
|
||||
|
||||
context.translateBy(x: size.width / 2.0, y: size.height / 2.0)
|
||||
context.scaleBy(x: 1.0, y: -1.0)
|
||||
context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0)
|
||||
|
||||
context.translateBy(x: lineOrigin.x, y: lineOrigin.y)
|
||||
CTLineDraw(line, context)
|
||||
context.translateBy(x: -lineOrigin.x, y: -lineOrigin.y)
|
||||
}) {
|
||||
strongSelf.controller?.completion(.image(image))
|
||||
}
|
||||
}
|
||||
strongSelf.controller?.dismiss(animated: true)
|
||||
},
|
||||
deleteBackwards: nil,
|
||||
@ -810,7 +835,7 @@ public class StickerPickerScreen: ViewController {
|
||||
guard let strongSelf = self, let file = item.itemFile else {
|
||||
return
|
||||
}
|
||||
strongSelf.controller?.completion(file)
|
||||
strongSelf.controller?.completion(.file(file))
|
||||
strongSelf.controller?.dismiss(animated: true)
|
||||
},
|
||||
deleteBackwards: nil,
|
||||
@ -901,7 +926,7 @@ public class StickerPickerScreen: ViewController {
|
||||
guard let strongSelf = self, let file = item.itemFile else {
|
||||
return
|
||||
}
|
||||
strongSelf.controller?.completion(file)
|
||||
strongSelf.controller?.completion(.file(file))
|
||||
strongSelf.controller?.dismiss(animated: true)
|
||||
},
|
||||
deleteBackwards: nil,
|
||||
@ -1523,7 +1548,7 @@ public class StickerPickerScreen: ViewController {
|
||||
public var pushController: (ViewController) -> Void = { _ in }
|
||||
public var presentController: (ViewController) -> Void = { _ in }
|
||||
|
||||
public var completion: (TelegramMediaFile?) -> Void = { _ in }
|
||||
public var completion: (DrawingStickerEntity.Content?) -> Void = { _ in }
|
||||
|
||||
public init(context: AccountContext, inputData: Signal<StickerPickerInputData, NoError>) {
|
||||
self.context = context
|
||||
|
||||
@ -265,7 +265,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
let context = strongSelf.context
|
||||
var cancelImpl: (() -> Void)?
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: theme)
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||
cancelImpl?()
|
||||
}))
|
||||
@ -305,7 +305,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode {
|
||||
}
|
||||
}
|
||||
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: theme)
|
||||
strongSelf.interaction.getNavigationController()?.presentOverlay(controller: UndoOverlayController(presentationData: presentationData, content: .stickersModified(title: presentationData.strings.StickerPackActionInfo_AddedTitle, text: presentationData.strings.StickerPackActionInfo_AddedText(info.title).string, undo: false, info: info, topItem: items.first, context: strongSelf.context), elevatedLayout: false, animateInAsReplacement: animateInAsReplacement, action: { _ in
|
||||
return true
|
||||
}))
|
||||
|
||||
@ -2606,10 +2606,10 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
||||
switch mode {
|
||||
case .sticker:
|
||||
let controller = StickerPickerScreen(context: self.context, inputData: self.stickerPickerInputData.get())
|
||||
controller.completion = { [weak self] file in
|
||||
controller.completion = { [weak self] content in
|
||||
if let self {
|
||||
if let file {
|
||||
let stickerEntity = DrawingStickerEntity(content: .file(file))
|
||||
if let content {
|
||||
let stickerEntity = DrawingStickerEntity(content: content)
|
||||
self.interaction?.insertEntity(stickerEntity)
|
||||
|
||||
self.hasAnyChanges = true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user