mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
no message
This commit is contained in:
parent
2168cdd46a
commit
d55d3eecc6
@ -324,9 +324,20 @@ public class ChatController: ViewController {
|
|||||||
let size = CGSize(width: CGFloat(asset.pixelWidth), height: CGFloat(asset.pixelHeight))
|
let size = CGSize(width: CGFloat(asset.pixelWidth), height: CGFloat(asset.pixelHeight))
|
||||||
let scaledSize = size.aspectFitted(CGSize(width: 1280.0, height: 1280.0))
|
let scaledSize = size.aspectFitted(CGSize(width: 1280.0, height: 1280.0))
|
||||||
let resource = PhotoLibraryMediaResource(localIdentifier: asset.localIdentifier)
|
let resource = PhotoLibraryMediaResource(localIdentifier: asset.localIdentifier)
|
||||||
let media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: [TelegramMediaImageRepresentation(dimensions: scaledSize, resource: resource)])
|
|
||||||
strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({})
|
if true {
|
||||||
enqueueMessages(account: strongSelf.account, peerId: strongSelf.peerId, messages: [.message(text: "", media: media, replyToMessageId: nil)]).start()
|
let media = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: randomId), representations: [TelegramMediaImageRepresentation(dimensions: scaledSize, resource: resource)])
|
||||||
|
strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({})
|
||||||
|
enqueueMessages(account: strongSelf.account, peerId: strongSelf.peerId, messages: [.message(text: "", media: media, replyToMessageId: nil)]).start()
|
||||||
|
} else {
|
||||||
|
let media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: randomId), resource: resource, previewRepresentations: [], mimeType: "image/jpeg", size: 0, attributes: [.FileName(fileName: "image.jpeg"), .ImageSize(size: scaledSize)])
|
||||||
|
enqueueMessages(account: strongSelf.account, peerId: strongSelf.peerId, messages: [.message(text: "", media: media, replyToMessageId: nil)]).start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
controller.files = { [weak strongSelf] in
|
||||||
|
if let strongSelf = strongSelf {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
controller.location = { [weak strongSelf] in
|
controller.location = { [weak strongSelf] in
|
||||||
|
|||||||
@ -13,6 +13,7 @@ final class ChatMediaActionSheetController: ActionSheetController {
|
|||||||
private var didSetReady = false
|
private var didSetReady = false
|
||||||
|
|
||||||
var photo: (PHAsset) -> Void = { _ in }
|
var photo: (PHAsset) -> Void = { _ in }
|
||||||
|
var files: () -> Void = { }
|
||||||
var location: () -> Void = { }
|
var location: () -> Void = { }
|
||||||
var contacts: () -> Void = { }
|
var contacts: () -> Void = { }
|
||||||
|
|
||||||
@ -29,7 +30,12 @@ final class ChatMediaActionSheetController: ActionSheetController {
|
|||||||
strongSelf.photo(asset)
|
strongSelf.photo(asset)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
ActionSheetButtonItem(title: "File", action: {}),
|
ActionSheetButtonItem(title: "File", action: { [weak self] in
|
||||||
|
if let strongSelf = self {
|
||||||
|
self?.dismissAnimated()
|
||||||
|
strongSelf.files()
|
||||||
|
}
|
||||||
|
}),
|
||||||
ActionSheetButtonItem(title: "Location", action: { [weak self] in
|
ActionSheetButtonItem(title: "Location", action: { [weak self] in
|
||||||
self?.dismissAnimated()
|
self?.dismissAnimated()
|
||||||
if let location = self?.location {
|
if let location = self?.location {
|
||||||
|
|||||||
@ -624,6 +624,14 @@ class ChatMessageBubbleItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func shouldAnimateHorizontalFrameTransition() -> Bool {
|
||||||
|
if let _ = self.backgroundFrameTransition {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func animateFrameTransition(_ progress: CGFloat) {
|
override func animateFrameTransition(_ progress: CGFloat) {
|
||||||
super.animateFrameTransition(progress)
|
super.animateFrameTransition(progress)
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class ChatMessageFileBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (initialWidth, refineLayout) = interactiveFileLayout(item.account, selectedFile!, item.message.flags.contains(.Incoming), CGSize(width: constrainedSize.width, height: constrainedSize.height))
|
let (initialWidth, refineLayout) = interactiveFileLayout(item.account, item.message, selectedFile!, item.message.flags.contains(.Incoming), CGSize(width: constrainedSize.width, height: constrainedSize.height))
|
||||||
|
|
||||||
return (initialWidth + layoutConstants.file.bubbleInsets.left + layoutConstants.file.bubbleInsets.right, { constrainedSize in
|
return (initialWidth + layoutConstants.file.bubbleInsets.left + layoutConstants.file.bubbleInsets.right, { constrainedSize in
|
||||||
let (refinedWidth, finishLayout) = refineLayout(constrainedSize)
|
let (refinedWidth, finishLayout) = refineLayout(constrainedSize)
|
||||||
|
|||||||
@ -35,6 +35,8 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
private let fetchDisposable = MetaDisposable()
|
private let fetchDisposable = MetaDisposable()
|
||||||
|
|
||||||
var activateLocalContent: () -> Void = { }
|
var activateLocalContent: () -> Void = { }
|
||||||
|
|
||||||
|
private var messageIdAndFlags: (MessageId, MessageFlags)?
|
||||||
private var file: TelegramMediaFile?
|
private var file: TelegramMediaFile?
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@ -90,13 +92,14 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func asyncLayout() -> (_ account: Account, _ file: TelegramMediaFile, _ incoming: Bool, _ constrainedSize: CGSize) -> (CGFloat, (CGSize) -> (CGFloat, (CGFloat) -> (CGSize, () -> Void))) {
|
func asyncLayout() -> (_ account: Account, _ message: Message, _ file: TelegramMediaFile, _ incoming: Bool, _ constrainedSize: CGSize) -> (CGFloat, (CGSize) -> (CGFloat, (CGFloat) -> (CGSize, () -> Void))) {
|
||||||
let currentFile = self.file
|
let currentFile = self.file
|
||||||
|
|
||||||
let titleAsyncLayout = TextNode.asyncLayout(self.titleNode)
|
let titleAsyncLayout = TextNode.asyncLayout(self.titleNode)
|
||||||
let descriptionAsyncLayout = TextNode.asyncLayout(self.descriptionNode)
|
let descriptionAsyncLayout = TextNode.asyncLayout(self.descriptionNode)
|
||||||
|
let currentMessageIdAndFlags = self.messageIdAndFlags
|
||||||
|
|
||||||
return { account, file, incoming, constrainedSize in
|
return { account, message, file, incoming, constrainedSize in
|
||||||
return (CGFloat.greatestFiniteMagnitude, { constrainedSize in
|
return (CGFloat.greatestFiniteMagnitude, { constrainedSize in
|
||||||
//var updateImageSignal: Signal<TransformImageArguments -> DrawingContext, NoError>?
|
//var updateImageSignal: Signal<TransformImageArguments -> DrawingContext, NoError>?
|
||||||
var updatedStatusSignal: Signal<MediaResourceStatus, NoError>?
|
var updatedStatusSignal: Signal<MediaResourceStatus, NoError>?
|
||||||
@ -109,9 +112,12 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
mediaUpdated = true
|
mediaUpdated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var statusUpdated = mediaUpdated
|
||||||
|
if currentMessageIdAndFlags?.0 != message.id || currentMessageIdAndFlags?.1 != message.flags {
|
||||||
|
statusUpdated = true
|
||||||
|
}
|
||||||
|
|
||||||
if mediaUpdated {
|
if mediaUpdated {
|
||||||
//updateImageSignal = chatMessagePhoto(account, photo: image)
|
|
||||||
updatedStatusSignal = chatMessageFileStatus(account: account, file: file)
|
|
||||||
updatedFetchControls = FetchControls(fetch: { [weak self] in
|
updatedFetchControls = FetchControls(fetch: { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.fetchDisposable.set(chatMessageFileInteractiveFetched(account: account, file: file).start())
|
strongSelf.fetchDisposable.set(chatMessageFileInteractiveFetched(account: account, file: file).start())
|
||||||
@ -121,6 +127,17 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if statusUpdated {
|
||||||
|
updatedStatusSignal = combineLatest(chatMessageFileStatus(account: account, file: file), account.pendingMessageManager.pendingMessageStatus(message.id))
|
||||||
|
|> map { resourceStatus, pendingStatus -> MediaResourceStatus in
|
||||||
|
if let pendingStatus = pendingStatus {
|
||||||
|
return .Fetching(progress: pendingStatus.progress)
|
||||||
|
} else {
|
||||||
|
return resourceStatus
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var candidateTitleString: NSAttributedString?
|
var candidateTitleString: NSAttributedString?
|
||||||
var candidateDescriptionString: NSAttributedString?
|
var candidateDescriptionString: NSAttributedString?
|
||||||
|
|
||||||
@ -162,6 +179,7 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
|
|
||||||
return (titleFrame.union(descriptionFrame).union(progressFrame).size, { [weak self] in
|
return (titleFrame.union(descriptionFrame).union(progressFrame).size, { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
|
strongSelf.messageIdAndFlags = (message.id, message.flags)
|
||||||
strongSelf.file = file
|
strongSelf.file = file
|
||||||
|
|
||||||
let _ = titleApply()
|
let _ = titleApply()
|
||||||
@ -212,12 +230,12 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func asyncLayout(_ node: ChatMessageInteractiveFileNode?) -> (_ account: Account, _ file: TelegramMediaFile, _ incoming: Bool, _ constrainedSize: CGSize) -> (CGFloat, (CGSize) -> (CGFloat, (CGFloat) -> (CGSize, () -> ChatMessageInteractiveFileNode))) {
|
static func asyncLayout(_ node: ChatMessageInteractiveFileNode?) -> (_ account: Account, _ message: Message, _ file: TelegramMediaFile, _ incoming: Bool, _ constrainedSize: CGSize) -> (CGFloat, (CGSize) -> (CGFloat, (CGFloat) -> (CGSize, () -> ChatMessageInteractiveFileNode))) {
|
||||||
let currentAsyncLayout = node?.asyncLayout()
|
let currentAsyncLayout = node?.asyncLayout()
|
||||||
|
|
||||||
return { account, file, incoming, constrainedSize in
|
return { account, message, file, incoming, constrainedSize in
|
||||||
var fileNode: ChatMessageInteractiveFileNode
|
var fileNode: ChatMessageInteractiveFileNode
|
||||||
var fileLayout: (_ account: Account, _ file: TelegramMediaFile, _ incoming: Bool, _ constrainedSize: CGSize) -> (CGFloat, (CGSize) -> (CGFloat, (CGFloat) -> (CGSize, () -> Void)))
|
var fileLayout: (_ account: Account, _ message: Message, _ file: TelegramMediaFile, _ incoming: Bool, _ constrainedSize: CGSize) -> (CGFloat, (CGSize) -> (CGFloat, (CGFloat) -> (CGSize, () -> Void)))
|
||||||
|
|
||||||
if let node = node, let currentAsyncLayout = currentAsyncLayout {
|
if let node = node, let currentAsyncLayout = currentAsyncLayout {
|
||||||
fileNode = node
|
fileNode = node
|
||||||
@ -227,7 +245,7 @@ final class ChatMessageInteractiveFileNode: ASTransformNode {
|
|||||||
fileLayout = fileNode.asyncLayout()
|
fileLayout = fileNode.asyncLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
let (initialWidth, continueLayout) = fileLayout(account, file, incoming, constrainedSize)
|
let (initialWidth, continueLayout) = fileLayout(account, message, file, incoming, constrainedSize)
|
||||||
|
|
||||||
return (initialWidth, { constrainedSize in
|
return (initialWidth, { constrainedSize in
|
||||||
let (finalWidth, finalLayout) = continueLayout(constrainedSize)
|
let (finalWidth, finalLayout) = continueLayout(constrainedSize)
|
||||||
|
|||||||
@ -127,7 +127,7 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
initialWidth = initialImageWidth + insets.left + insets.right
|
initialWidth = initialImageWidth + insets.left + insets.right
|
||||||
refineContentImageLayout = refineLayout
|
refineContentImageLayout = refineLayout
|
||||||
} else {
|
} else {
|
||||||
let (_, refineLayout) = contentFileLayout(item.account, file, item.message.flags.contains(.Incoming), CGSize(width: constrainedSize.width - insets.left - insets.right, height: constrainedSize.height))
|
let (_, refineLayout) = contentFileLayout(item.account, item.message, file, item.message.flags.contains(.Incoming), CGSize(width: constrainedSize.width - insets.left - insets.right, height: constrainedSize.height))
|
||||||
refineContentFileLayout = refineLayout
|
refineContentFileLayout = refineLayout
|
||||||
}
|
}
|
||||||
} else if let image = webpage.image {
|
} else if let image = webpage.image {
|
||||||
|
|||||||
@ -72,9 +72,9 @@ private func chatMessagePhotoDatas(account: Account, photo: TelegramMediaImage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func chatMessageFileDatas(account: Account, file: TelegramMediaFile, progressive: Bool = false) -> Signal<(Data?, (Data, String)?, Bool), NoError> {
|
private func chatMessageFileDatas(account: Account, file: TelegramMediaFile, progressive: Bool = false) -> Signal<(Data?, (Data, String)?, Bool), NoError> {
|
||||||
if let smallestRepresentation = smallestImageRepresentation(file.previewRepresentations), let largestRepresentation = largestImageRepresentation(file.previewRepresentations) {
|
if let smallestRepresentation = smallestImageRepresentation(file.previewRepresentations) {
|
||||||
let thumbnailResource = smallestRepresentation.resource
|
let thumbnailResource = smallestRepresentation.resource
|
||||||
let fullSizeResource = largestRepresentation.resource
|
let fullSizeResource = file.resource
|
||||||
|
|
||||||
let maybeFullSize = account.postbox.mediaBox.resourceData(fullSizeResource)
|
let maybeFullSize = account.postbox.mediaBox.resourceData(fullSizeResource)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user