mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-05 19:28:46 +02:00
Merge 75a97a8c4e into 6e370e06d1
This commit is contained in:
commit
1df58d60ab
4 changed files with 25 additions and 9 deletions
|
|
@ -6847,7 +6847,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
|
|||
var didComplete = false
|
||||
|
||||
public var cancelled: (Bool) -> Void = { _ in }
|
||||
public var willComplete: (UIImage?, Bool, @escaping () -> Void) -> Void
|
||||
public var willComplete: (UIImage?, Bool, @escaping () -> Void, @escaping () -> Void) -> Void
|
||||
public var completion: ([MediaEditorScreenImpl.Result], @escaping (@escaping () -> Void) -> Void) -> Void
|
||||
public var dismissed: () -> Void = { }
|
||||
public var willDismiss: () -> Void = { }
|
||||
|
|
@ -6881,7 +6881,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID
|
|||
initialLink: (url: String, name: String?)? = nil,
|
||||
transitionIn: TransitionIn?,
|
||||
transitionOut: @escaping (Bool, Bool?) -> TransitionOut?,
|
||||
willComplete: @escaping (UIImage?, Bool, @escaping () -> Void) -> Void = { _, _, commit in commit() },
|
||||
willComplete: @escaping (UIImage?, Bool, @escaping () -> Void, @escaping () -> Void) -> Void = { _, _, commit, _ in commit() },
|
||||
completion: @escaping ([MediaEditorScreenImpl.Result], @escaping (@escaping () -> Void) -> Void) -> Void
|
||||
) {
|
||||
self.context = context
|
||||
|
|
|
|||
|
|
@ -31,13 +31,9 @@ extension MediaEditorScreenImpl {
|
|||
}
|
||||
|
||||
self.didComplete = true
|
||||
|
||||
|
||||
self.updateMediaEditorEntities()
|
||||
|
||||
mediaEditor.stop()
|
||||
mediaEditor.invalidate()
|
||||
self.node.entitiesView.invalidate()
|
||||
|
||||
if let navigationController = self.navigationController as? NavigationController {
|
||||
navigationController.updateRootContainerTransitionOffset(0.0, transition: .immediate)
|
||||
}
|
||||
|
|
@ -490,6 +486,9 @@ extension MediaEditorScreenImpl {
|
|||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.node.mediaEditor?.stop()
|
||||
self.node.mediaEditor?.invalidate()
|
||||
self.node.entitiesView.invalidate()
|
||||
Logger.shared.log("MediaEditor", "Completed with video \(videoResult)")
|
||||
self.completion([MediaEditorScreenImpl.Result(media: .video(video: videoResult, coverImage: coverImage, values: values, duration: duration, dimensions: values.resultDimensions), mediaAreas: mediaAreas, caption: caption, coverTimestamp: values.coverImageTimestamp, options: self.state.privacy, stickers: stickers, music: values.audioTrack?.file, randomId: randomId)], { [weak self] finished in
|
||||
self?.node.animateOut(finished: true, saveDraft: false, completion: { [weak self] in
|
||||
|
|
@ -499,6 +498,8 @@ extension MediaEditorScreenImpl {
|
|||
}
|
||||
})
|
||||
})
|
||||
}, { [weak self] in
|
||||
self?.didComplete = false
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -532,6 +533,9 @@ extension MediaEditorScreenImpl {
|
|||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.node.mediaEditor?.stop()
|
||||
self.node.mediaEditor?.invalidate()
|
||||
self.node.entitiesView.invalidate()
|
||||
Logger.shared.log("MediaEditor", "Completed with image \(resultImage)")
|
||||
self.completion([MediaEditorScreenImpl.Result(media: .image(image: resultImage, dimensions: PixelDimensions(resultImage.size)), mediaAreas: mediaAreas, caption: caption, coverTimestamp: nil, options: self.state.privacy, stickers: stickers, music: values.audioTrack?.file, randomId: randomId)], { [weak self] finished in
|
||||
self?.node.animateOut(finished: true, saveDraft: false, completion: { [weak self] in
|
||||
|
|
@ -544,6 +548,8 @@ extension MediaEditorScreenImpl {
|
|||
if case let .draft(draft, id) = actualSubject, id == nil {
|
||||
removeStoryDraft(engine: self.context.engine, path: draft.path, delete: true)
|
||||
}
|
||||
}, { [weak self] in
|
||||
self?.didComplete = false
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -604,10 +604,12 @@ extension PeerInfoScreenImpl {
|
|||
}
|
||||
return nil
|
||||
},
|
||||
willComplete: { [weak self, weak parentController] image, isVideo, commit in
|
||||
willComplete: { [weak self, weak parentController] image, isVideo, commit, cancel in
|
||||
if let self, let confirmationAlert, let image {
|
||||
let controller = photoUpdateConfirmationController(context: self.context, peer: peer, image: image, text: isVideo ? confirmationAlert.videoText : confirmationAlert.photoText, doneTitle: confirmationAlert.action, commit: {
|
||||
commit()
|
||||
}, onCancel: {
|
||||
cancel()
|
||||
})
|
||||
parentController?.presentInGlobalOverlay(controller)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ func photoUpdateConfirmationController(
|
|||
text: String,
|
||||
doneTitle: String,
|
||||
isDark: Bool = true,
|
||||
commit: @escaping () -> Void
|
||||
commit: @escaping () -> Void,
|
||||
onCancel: (() -> Void)? = nil
|
||||
) -> ViewController {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let strings = presentationData.strings
|
||||
|
|
@ -62,16 +63,23 @@ func photoUpdateConfirmationController(
|
|||
updatedPresentationData = (presentationData, context.sharedContext.presentationData)
|
||||
}
|
||||
|
||||
var didCommit = false
|
||||
let alertController = AlertScreen(
|
||||
content: content,
|
||||
actions: [
|
||||
.init(title: strings.Common_Cancel),
|
||||
.init(title: doneTitle, type: .default, action: {
|
||||
didCommit = true
|
||||
commit()
|
||||
})
|
||||
],
|
||||
updatedPresentationData: updatedPresentationData
|
||||
)
|
||||
alertController.dismissed = { _ in
|
||||
if !didCommit {
|
||||
onCancel?()
|
||||
}
|
||||
}
|
||||
return alertController
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue