mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Quickly share links with system's share menu
This commit is contained in:
parent
72486ff01c
commit
fc087f7c57
@ -461,11 +461,14 @@ public final class ShareController: ViewController {
|
|||||||
|
|
||||||
public var parentNavigationController: NavigationController?
|
public var parentNavigationController: NavigationController?
|
||||||
|
|
||||||
public convenience init(context: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil, shareAsLink: Bool = false, collectibleItemInfo: TelegramCollectibleItemInfo? = nil) {
|
public convenience init(context: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, immediateExternalShareOverridingSGBehaviour: Bool? = nil, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil, shareAsLink: Bool = false, collectibleItemInfo: TelegramCollectibleItemInfo? = nil) {
|
||||||
var immediateExternalShare = immediateExternalShare
|
var immediateExternalShare = immediateExternalShare
|
||||||
if SGSimpleSettings.shared.forceSystemSharing {
|
if SGSimpleSettings.shared.forceSystemSharing {
|
||||||
immediateExternalShare = true
|
immediateExternalShare = true
|
||||||
}
|
}
|
||||||
|
if let immediateExternalShareOverridingSGBehaviour = immediateExternalShareOverridingSGBehaviour {
|
||||||
|
immediateExternalShare = immediateExternalShareOverridingSGBehaviour
|
||||||
|
}
|
||||||
self.init(
|
self.init(
|
||||||
environment: ShareControllerAppEnvironment(sharedContext: context.sharedContext),
|
environment: ShareControllerAppEnvironment(sharedContext: context.sharedContext),
|
||||||
currentContext: ShareControllerAppAccountContext(context: context),
|
currentContext: ShareControllerAppAccountContext(context: context),
|
||||||
|
@ -16,6 +16,9 @@ import UrlWhitelist
|
|||||||
import OpenInExternalAppUI
|
import OpenInExternalAppUI
|
||||||
import SafariServices
|
import SafariServices
|
||||||
|
|
||||||
|
// MARK: Swiftgram
|
||||||
|
import ShareController
|
||||||
|
|
||||||
extension ChatControllerImpl {
|
extension ChatControllerImpl {
|
||||||
func openLinkContextMenu(url: String, params: ChatControllerInteraction.LongTapParams) -> Void {
|
func openLinkContextMenu(url: String, params: ChatControllerInteraction.LongTapParams) -> Void {
|
||||||
guard let message = params.message, let contentNode = params.contentNode else {
|
guard let message = params.message, let contentNode = params.contentNode else {
|
||||||
@ -92,6 +95,22 @@ extension ChatControllerImpl {
|
|||||||
}
|
}
|
||||||
self.present(UndoOverlayController(presentationData: self.presentationData, content: content, elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
self.present(UndoOverlayController(presentationData: self.presentationData, content: content, elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .current)
|
||||||
}))
|
}))
|
||||||
|
// MARK: Swiftgram
|
||||||
|
items.append(ActionSheetButtonItem(title: self.presentationData.strings.Conversation_ContextMenuForward, color: .accent, action: { [weak actionSheet, weak self] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.present(ShareController(context: self.context, subject: .url(url), immediateExternalShareOverridingSGBehaviour: false), in: .window(.root))
|
||||||
|
}))
|
||||||
|
items.append(ActionSheetButtonItem(title: self.presentationData.strings.Conversation_ContextMenuShare, color: .accent, action: { [weak actionSheet, weak self] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.present(ShareController(context: self.context, subject: .url(url), immediateExternalShareOverridingSGBehaviour: true), in: .current)
|
||||||
|
}))
|
||||||
|
//
|
||||||
if canAddToReadingList {
|
if canAddToReadingList {
|
||||||
items.append(ActionSheetButtonItem(title: self.presentationData.strings.Conversation_AddToReadingList, color: .accent, action: { [weak actionSheet] in
|
items.append(ActionSheetButtonItem(title: self.presentationData.strings.Conversation_AddToReadingList, color: .accent, action: { [weak actionSheet] in
|
||||||
actionSheet?.dismissAnimated()
|
actionSheet?.dismissAnimated()
|
||||||
@ -183,6 +202,30 @@ extension ChatControllerImpl {
|
|||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// MARK: Swiftgram
|
||||||
|
items.append(
|
||||||
|
.action(ContextMenuActionItem(text: self.presentationData.strings.Conversation_ContextMenuForward, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in
|
||||||
|
f(.default)
|
||||||
|
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.present(ShareController(context: self.context, subject: .url(url), immediateExternalShareOverridingSGBehaviour: false), in: .window(.root))
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
items.append(
|
||||||
|
.action(ContextMenuActionItem(text: self.presentationData.strings.Conversation_ContextMenuShare, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Share"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in
|
||||||
|
f(.default)
|
||||||
|
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.present(ShareController(context: self.context, subject: .url(url), immediateExternalShareOverridingSGBehaviour: true), in: .current)
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
//
|
||||||
if canAddToReadingList {
|
if canAddToReadingList {
|
||||||
items.append(
|
items.append(
|
||||||
.action(ContextMenuActionItem(text: self.presentationData.strings.Conversation_AddToReadingList, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReadingList"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
.action(ContextMenuActionItem(text: self.presentationData.strings.Conversation_AddToReadingList, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReadingList"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user