mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various improvements
This commit is contained in:
@@ -2931,6 +2931,75 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
return GiftViewScreen(context: context, subject: .uniqueGift(gift), shareStory: shareStory)
|
||||
}
|
||||
|
||||
public func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController {
|
||||
let editorSubject: Signal<MediaEditorScreenImpl.Subject?, NoError>
|
||||
switch subject {
|
||||
case let .messages(messages):
|
||||
editorSubject = .single(.message(messages.map { $0.id }))
|
||||
case let .gift(gift):
|
||||
editorSubject = .single(.gift(gift))
|
||||
}
|
||||
|
||||
let externalState = MediaEditorTransitionOutExternalState(
|
||||
storyTarget: nil,
|
||||
isForcedTarget: false,
|
||||
isPeerArchived: false,
|
||||
transitionOut: nil
|
||||
)
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let controller = MediaEditorScreenImpl(
|
||||
context: context,
|
||||
mode: .storyEditor,
|
||||
subject: editorSubject,
|
||||
transitionIn: nil,
|
||||
transitionOut: { _, _ in
|
||||
return nil
|
||||
},
|
||||
completion: { [weak parentController] result, commit in
|
||||
let targetPeerId: EnginePeer.Id
|
||||
let target: Stories.PendingTarget
|
||||
if let sendAsPeerId = result.options.sendAsPeerId {
|
||||
target = .peer(sendAsPeerId)
|
||||
targetPeerId = sendAsPeerId
|
||||
} else {
|
||||
target = .myStories
|
||||
targetPeerId = context.account.peerId
|
||||
}
|
||||
externalState.storyTarget = target
|
||||
|
||||
if let rootController = context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
|
||||
rootController.proceedWithStoryUpload(target: target, result: result, existingMedia: nil, forwardInfo: nil, externalState: externalState, commit: commit)
|
||||
}
|
||||
|
||||
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: targetPeerId))
|
||||
|> deliverOnMainQueue).start(next: { peer in
|
||||
guard let peer else {
|
||||
return
|
||||
}
|
||||
let text: String
|
||||
if case .channel = peer {
|
||||
text = presentationData.strings.Story_MessageReposted_Channel(peer.compactDisplayTitle).string
|
||||
} else {
|
||||
text = presentationData.strings.Story_MessageReposted_Personal
|
||||
}
|
||||
Queue.mainQueue().after(0.25) {
|
||||
parentController?.present(UndoOverlayController(
|
||||
presentationData: presentationData,
|
||||
content: .forward(savedMessages: false, text: text),
|
||||
elevatedLayout: false,
|
||||
action: { _ in return false }
|
||||
), in: .current)
|
||||
|
||||
Queue.mainQueue().after(0.1) {
|
||||
HapticFeedback().success()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
return controller
|
||||
}
|
||||
|
||||
public func makeContentReportScreen(context: AccountContext, subject: ReportContentSubject, forceDark: Bool, present: @escaping (ViewController) -> Void, completion: @escaping () -> Void, requestSelectMessages: ((String, Data, String?) -> Void)?) {
|
||||
let _ = (context.engine.messages.reportContent(subject: subject, option: nil, message: nil)
|
||||
|> deliverOnMainQueue).startStandalone(next: { result in
|
||||
@@ -2940,9 +3009,10 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
})
|
||||
}
|
||||
|
||||
public func makeShareController(context: AccountContext, subject: ShareControllerSubject, forceExternal: Bool, shareStory: (() -> Void)?, actionCompleted: (() -> Void)?) -> ViewController {
|
||||
public func makeShareController(context: AccountContext, subject: ShareControllerSubject, forceExternal: Bool, shareStory: (() -> Void)?, enqueued: (([PeerId], [Int64]) -> Void)?, actionCompleted: (() -> Void)?) -> ViewController {
|
||||
let controller = ShareController(context: context, subject: subject, externalShare: forceExternal)
|
||||
controller.shareStory = shareStory
|
||||
controller.enqueued = enqueued
|
||||
controller.actionCompleted = actionCompleted
|
||||
return controller
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user