Psa-related fixes

This commit is contained in:
Ali 2020-04-25 18:00:03 +04:00
parent 049cba24bf
commit e43dcbfaca
19 changed files with 93 additions and 45 deletions

View File

@ -274,7 +274,7 @@ private final class AuthDataTransferSplashScreenNode: ViewControllerTracingNode
return nil return nil
} }
} }
textNode.tapAttributeAction = { attributes in textNode.tapAttributeAction = { attributes, _ in
if let _ = attributes[NSAttributedString.Key(rawValue: "URL")] { if let _ = attributes[NSAttributedString.Key(rawValue: "URL")] {
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: "https://desktop.telegram.org", forceExternal: true, presentationData: context.sharedContext.currentPresentationData.with { $0 }, navigationController: nil, dismissInput: {}) context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: "https://desktop.telegram.org", forceExternal: true, presentationData: context.sharedContext.currentPresentationData.with { $0 }, navigationController: nil, dismissInput: {})
} }

View File

@ -44,9 +44,13 @@ enum ChatContextMenuSource {
case search(ChatListSearchContextActionSource) case search(ChatListSearchContextActionSource)
} }
func chatContextMenuItems(context: AccountContext, peerId: PeerId, source: ChatContextMenuSource, chatListController: ChatListControllerImpl?) -> Signal<[ContextMenuItem], NoError> { func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: ChatListNodeEntryPromoInfo?, source: ChatContextMenuSource, chatListController: ChatListControllerImpl?) -> Signal<[ContextMenuItem], NoError> {
let strings = context.sharedContext.currentPresentationData.with({ $0 }).strings let strings = context.sharedContext.currentPresentationData.with({ $0 }).strings
return context.account.postbox.transaction { [weak chatListController] transaction -> [ContextMenuItem] in return context.account.postbox.transaction { [weak chatListController] transaction -> [ContextMenuItem] in
if promoInfo != nil {
return []
}
var items: [ContextMenuItem] = [] var items: [ContextMenuItem] = []
if case let .search(search) = source { if case let .search(search) = source {

View File

@ -801,10 +801,10 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
chatListController.navigationPresentation = .master chatListController.navigationPresentation = .master
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture) let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: archiveContextMenuItems(context: strongSelf.context, groupId: groupReference.groupId, chatListController: strongSelf), reactionItems: [], gesture: gesture)
strongSelf.presentInGlobalOverlay(contextController) strongSelf.presentInGlobalOverlay(contextController)
case let .peer(peer): case let .peer(_, peer, _, _, _, _, _, _, promoInfo, _, _, _):
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.peer.peerId), subject: nil, botStart: nil, mode: .standard(previewing: true)) let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.peerId), subject: nil, botStart: nil, mode: .standard(previewing: true))
chatController.canReadHistory.set(false) chatController.canReadHistory.set(false)
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.peer.peerId, source: .chatList(filter: strongSelf.chatListDisplayNode.containerNode.currentItemNode.chatListFilter), chatListController: strongSelf), reactionItems: [], gesture: gesture) let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.peerId, promoInfo: promoInfo, source: .chatList(filter: strongSelf.chatListDisplayNode.containerNode.currentItemNode.chatListFilter), chatListController: strongSelf), reactionItems: [], gesture: gesture)
strongSelf.presentInGlobalOverlay(contextController) strongSelf.presentInGlobalOverlay(contextController)
} }
} }
@ -817,7 +817,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController,
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.id), subject: nil, botStart: nil, mode: .standard(previewing: true)) let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peer.id), subject: nil, botStart: nil, mode: .standard(previewing: true))
chatController.canReadHistory.set(false) chatController.canReadHistory.set(false)
let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.id, source: .search(source), chatListController: strongSelf), reactionItems: [], gesture: gesture) let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.id, promoInfo: nil, source: .search(source), chatListController: strongSelf), reactionItems: [], gesture: gesture)
strongSelf.presentInGlobalOverlay(contextController) strongSelf.presentInGlobalOverlay(contextController)
} }

View File

@ -651,8 +651,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
guard let item = self.item, item.editing else { guard let item = self.item, item.editing else {
return return
} }
if case .peer = item.content { if case let .peer(_, _, _, _, _, _, _, _, promoInfo, _, _, _) = item.content {
item.interaction.togglePeerSelected(item.index.messageIndex.id.peerId) if promoInfo == nil {
item.interaction.togglePeerSelected(item.index.messageIndex.id.peerId)
}
} }
} }

View File

@ -60,8 +60,8 @@ public class ImmediateTextNode: TextNode {
} }
} }
public var tapAttributeAction: (([NSAttributedString.Key: Any]) -> Void)? public var tapAttributeAction: (([NSAttributedString.Key: Any], Int) -> Void)?
public var longTapAttributeAction: (([NSAttributedString.Key: Any]) -> Void)? public var longTapAttributeAction: (([NSAttributedString.Key: Any], Int) -> Void)?
public func makeCopy() -> TextNode { public func makeCopy() -> TextNode {
let node = TextNode() let node = TextNode()
@ -179,12 +179,12 @@ public class ImmediateTextNode: TextNode {
if let (gesture, location) = recognizer.lastRecognizedGestureAndLocation { if let (gesture, location) = recognizer.lastRecognizedGestureAndLocation {
switch gesture { switch gesture {
case .tap: case .tap:
if let (_, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) { if let (index, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) {
self.tapAttributeAction?(attributes) self.tapAttributeAction?(attributes, index)
} }
case .longTap: case .longTap:
if let (_, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) { if let (index, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) {
self.longTapAttributeAction?(attributes) self.longTapAttributeAction?(attributes, index)
} }
default: default:
break break

View File

@ -147,7 +147,7 @@ public final class TextAlertContentNode: AlertContentNode {
return nil return nil
} }
} }
self.textNode.tapAttributeAction = { attributes in self.textNode.tapAttributeAction = { attributes, _ in
if let value = attributes[attribute] { if let value = attributes[attribute] {
textAttributeAction(value) textAttributeAction(value)
} }

View File

@ -314,12 +314,12 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
} }
return nil return nil
} }
self.textNode.tapAttributeAction = { [weak self] attributes in self.textNode.tapAttributeAction = { [weak self] attributes, _ in
if let strongSelf = self, let action = strongSelf.actionForAttributes(attributes) { if let strongSelf = self, let action = strongSelf.actionForAttributes(attributes) {
strongSelf.performAction?(action) strongSelf.performAction?(action)
} }
} }
self.textNode.longTapAttributeAction = { [weak self] attributes in self.textNode.longTapAttributeAction = { [weak self] attributes, _ in
if let strongSelf = self, let action = strongSelf.actionForAttributes(attributes) { if let strongSelf = self, let action = strongSelf.actionForAttributes(attributes) {
strongSelf.openActionOptions?(action) strongSelf.openActionOptions?(action)
} }

View File

@ -55,12 +55,12 @@ final class InstantPageGalleryFooterContentNode: GalleryFooterContentNode {
return nil return nil
} }
} }
self.textNode.tapAttributeAction = { [weak self] attributes in self.textNode.tapAttributeAction = { [weak self] attributes, _ in
if let strongSelf = self, let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? InstantPageUrlItem { if let strongSelf = self, let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? InstantPageUrlItem {
strongSelf.openUrl?(url) strongSelf.openUrl?(url)
} }
} }
self.textNode.longTapAttributeAction = { [weak self] attributes in self.textNode.longTapAttributeAction = { [weak self] attributes, _ in
if let strongSelf = self, let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? InstantPageUrlItem { if let strongSelf = self, let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? InstantPageUrlItem {
strongSelf.openUrlOptions?(url) strongSelf.openUrlOptions?(url)
} }

View File

@ -58,7 +58,7 @@ final class LanguageLinkPreviewContentNode: ASDisplayNode, ShareContentContainer
return nil return nil
} }
} }
self.textNode.tapAttributeAction = { attributes in self.textNode.tapAttributeAction = { attributes, _ in
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] { if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] {
let url: String let url: String
if localizationInfo.platformUrl.isEmpty { if localizationInfo.platformUrl.isEmpty {

View File

@ -80,7 +80,7 @@ final class SecureIdAuthFormContentNode: ASDisplayNode, SecureIdAuthContentNode,
return nil return nil
} }
} }
self.textNode.tapAttributeAction = { attributes in self.textNode.tapAttributeAction = { attributes, _ in
if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String { if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
openURL(url) openURL(url)
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention { } else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {

View File

@ -1561,13 +1561,16 @@ final class MessageHistoryTable: Table {
var forwardInfoFlags: Int8 = 1 var forwardInfoFlags: Int8 = 1
if forwardInfo.sourceId != nil { if forwardInfo.sourceId != nil {
forwardInfoFlags |= 2 forwardInfoFlags |= 1 << 1
} }
if forwardInfo.sourceMessageId != nil { if forwardInfo.sourceMessageId != nil {
forwardInfoFlags |= 4 forwardInfoFlags |= 1 << 2
} }
if forwardInfo.authorSignature != nil { if forwardInfo.authorSignature != nil {
forwardInfoFlags |= 8 forwardInfoFlags |= 1 << 3
}
if forwardInfo.psaType != nil {
forwardInfoFlags |= 1 << 4
} }
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1) sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)
var forwardAuthorId: Int64 = forwardInfo.authorId?.toInt64() ?? 0 var forwardAuthorId: Int64 = forwardInfo.authorId?.toInt64() ?? 0
@ -1599,6 +1602,17 @@ final class MessageHistoryTable: Table {
sharedBuffer.write(&length, offset: 0, length: 4) sharedBuffer.write(&length, offset: 0, length: 4)
} }
} }
if let psaType = forwardInfo.psaType {
if let data = psaType.data(using: .utf8, allowLossyConversion: true) {
var length: Int32 = Int32(data.count)
sharedBuffer.write(&length, offset: 0, length: 4)
sharedBuffer.write(data)
} else {
var length: Int32 = 0
sharedBuffer.write(&length, offset: 0, length: 4)
}
}
} else { } else {
var forwardInfoFlags: Int8 = 0 var forwardInfoFlags: Int8 = 0
sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1) sharedBuffer.write(&forwardInfoFlags, offset: 0, length: 1)

View File

@ -152,7 +152,7 @@ final class TermsOfServiceControllerNode: ViewControllerTracingNode {
strongSelf.present(actionSheet, nil) strongSelf.present(actionSheet, nil)
} }
self.contentTextNode.tapAttributeAction = { [weak self] attributes in self.contentTextNode.tapAttributeAction = { [weak self] attributes, _ in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
@ -164,7 +164,7 @@ final class TermsOfServiceControllerNode: ViewControllerTracingNode {
showMentionActionSheet(mention) showMentionActionSheet(mention)
} }
} }
self.contentTextNode.longTapAttributeAction = { [weak self] attributes in self.contentTextNode.longTapAttributeAction = { [weak self] attributes, _ in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }

View File

@ -182,7 +182,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
} }
} }
self.contentTitleNode.tapAttributeAction = { attributes in self.contentTitleNode.tapAttributeAction = { attributes, _ in
if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String, mention.count > 1 { if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String, mention.count > 1 {
openMention(String(mention[mention.index(after: mention.startIndex)...])) openMention(String(mention[mention.index(after: mention.startIndex)...]))
} }

View File

@ -169,7 +169,7 @@ final class AuthorizationSequenceSignUpControllerNode: ASDisplayNode, UITextFiel
return nil return nil
} }
} }
self.termsNode.tapAttributeAction = { [weak self] attributes in self.termsNode.tapAttributeAction = { [weak self] attributes, _ in
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] { if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] {
self?.openTermsOfService?() self?.openTermsOfService?()
} }

View File

@ -6401,10 +6401,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
switch item { switch item {
case let .url(url): case let .url(url, concealed):
switch action { switch action {
case .tap: case .tap:
strongSelf.openUrl(url, concealed: false) strongSelf.openUrl(url, concealed: concealed)
case .longTap: case .longTap:
strongSelf.controllerInteraction?.longTap(.url(url), nil) strongSelf.controllerInteraction?.longTap(.url(url), nil)
} }
@ -6489,7 +6489,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
switch item { switch item {
case let .url(url): case let .url(url, concealed):
switch action { switch action {
case .tap: case .tap:
strongSelf.openUrl(url, concealed: false) strongSelf.openUrl(url, concealed: false)
@ -6575,14 +6575,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return return
} }
let tooltipScreen = TooltipScreen(text: psaText, textEntities: psaEntities, icon: .info, location: .top, shouldDismissOnTouch: { point in let tooltipScreen = TooltipScreen(text: psaText, textEntities: psaEntities, icon: .info, location: .top, displayDuration: .custom(10.0), shouldDismissOnTouch: { point in
return .ignore return .ignore
}, openActiveTextItem: { [weak self] item, action in }, openActiveTextItem: { [weak self] item, action in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
switch item { switch item {
case let .url(url): case let .url(url, concealed):
switch action { switch action {
case .tap: case .tap:
strongSelf.openUrl(url, concealed: false) strongSelf.openUrl(url, concealed: false)

View File

@ -14,6 +14,7 @@ static_library(
"//submodules/SyncCore:SyncCore#shared", "//submodules/SyncCore:SyncCore#shared",
"//submodules/TelegramCore:TelegramCore#shared", "//submodules/TelegramCore:TelegramCore#shared",
"//submodules/TextFormat:TextFormat", "//submodules/TextFormat:TextFormat",
"//submodules/UrlEscaping:UrlEscaping",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -15,6 +15,7 @@ swift_library(
"//submodules/SyncCore:SyncCore", "//submodules/SyncCore:SyncCore",
"//submodules/TelegramCore:TelegramCore", "//submodules/TelegramCore:TelegramCore",
"//submodules/TextFormat:TextFormat", "//submodules/TextFormat:TextFormat",
"//submodules/UrlEscaping:UrlEscaping",
], ],
visibility = [ visibility = [
"//visibility:public", "//visibility:public",

View File

@ -9,9 +9,10 @@ import SyncCore
import TelegramCore import TelegramCore
import TextFormat import TextFormat
import Postbox import Postbox
import UrlEscaping
public enum TooltipActiveTextItem { public enum TooltipActiveTextItem {
case url(String) case url(String, Bool)
case mention(PeerId, String) case mention(PeerId, String)
case textMention(String) case textMention(String)
case botCommand(String) case botCommand(String)
@ -26,6 +27,7 @@ public enum TooltipActiveTextAction {
private final class TooltipScreenNode: ViewControllerTracingNode { private final class TooltipScreenNode: ViewControllerTracingNode {
private let icon: TooltipScreen.Icon? private let icon: TooltipScreen.Icon?
private let location: TooltipScreen.Location private let location: TooltipScreen.Location
private let displayDuration: TooltipScreen.DisplayDuration
private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch
private let requestDismiss: () -> Void private let requestDismiss: () -> Void
@ -42,9 +44,10 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
private var validLayout: ContainerViewLayout? private var validLayout: ContainerViewLayout?
init(text: String, textEntities: [MessageTextEntity], icon: TooltipScreen.Icon?, location: TooltipScreen.Location, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, requestDismiss: @escaping () -> Void, openActiveTextItem: @escaping (TooltipActiveTextItem, TooltipActiveTextAction) -> Void) { init(text: String, textEntities: [MessageTextEntity], icon: TooltipScreen.Icon?, location: TooltipScreen.Location, displayDuration: TooltipScreen.DisplayDuration, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, requestDismiss: @escaping () -> Void, openActiveTextItem: @escaping (TooltipActiveTextItem, TooltipActiveTextAction) -> Void) {
self.icon = icon self.icon = icon
self.location = location self.location = location
self.displayDuration = displayDuration
self.shouldDismissOnTouch = shouldDismissOnTouch self.shouldDismissOnTouch = shouldDismissOnTouch
self.requestDismiss = requestDismiss self.requestDismiss = requestDismiss
@ -127,12 +130,16 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
} }
return nil return nil
} }
self.textNode.tapAttributeAction = { [weak self] attributes in self.textNode.tapAttributeAction = { [weak self] attributes, index in
guard let _ = self else { guard let strongSelf = self else {
return return
} }
if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String { if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
openActiveTextItem(.url(url), .tap) var concealed = true
if let (attributeText, fullText) = strongSelf.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
}
openActiveTextItem(.url(url, concealed), .tap)
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention { } else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
openActiveTextItem(.mention(mention.peerId, mention.mention), .tap) openActiveTextItem(.mention(mention.peerId, mention.mention), .tap)
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String { } else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
@ -144,12 +151,16 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
} }
} }
self.textNode.longTapAttributeAction = { [weak self] attributes in self.textNode.longTapAttributeAction = { [weak self] attributes, index in
guard let _ = self else { guard let strongSelf = self else {
return return
} }
if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String { if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String {
openActiveTextItem(.url(url), .longTap) var concealed = true
if let (attributeText, fullText) = strongSelf.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) {
concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText)
}
openActiveTextItem(.url(url, concealed), .longTap)
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention { } else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
openActiveTextItem(.mention(mention.peerId, mention.mention), .longTap) openActiveTextItem(.mention(mention.peerId, mention.mention), .longTap)
} else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String { } else if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
@ -357,10 +368,16 @@ public final class TooltipScreen: ViewController {
case top case top
} }
public enum DisplayDuration {
case `default`
case custom(Double)
}
public let text: String public let text: String
public let textEntities: [MessageTextEntity] public let textEntities: [MessageTextEntity]
private let icon: TooltipScreen.Icon? private let icon: TooltipScreen.Icon?
private let location: TooltipScreen.Location private let location: TooltipScreen.Location
private let displayDuration: DisplayDuration
private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch private let shouldDismissOnTouch: (CGPoint) -> TooltipScreen.DismissOnTouch
private let openActiveTextItem: (TooltipActiveTextItem, TooltipActiveTextAction) -> Void private let openActiveTextItem: (TooltipActiveTextItem, TooltipActiveTextAction) -> Void
@ -374,11 +391,12 @@ public final class TooltipScreen: ViewController {
public var willBecomeDismissed: ((TooltipScreen) -> Void)? public var willBecomeDismissed: ((TooltipScreen) -> Void)?
public var becameDismissed: ((TooltipScreen) -> Void)? public var becameDismissed: ((TooltipScreen) -> Void)?
public init(text: String, textEntities: [MessageTextEntity] = [], icon: TooltipScreen.Icon?, location: TooltipScreen.Location, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, openActiveTextItem: @escaping (TooltipActiveTextItem, TooltipActiveTextAction) -> Void = { _, _ in }) { public init(text: String, textEntities: [MessageTextEntity] = [], icon: TooltipScreen.Icon?, location: TooltipScreen.Location, displayDuration: DisplayDuration = .default, shouldDismissOnTouch: @escaping (CGPoint) -> TooltipScreen.DismissOnTouch, openActiveTextItem: @escaping (TooltipActiveTextItem, TooltipActiveTextAction) -> Void = { _, _ in }) {
self.text = text self.text = text
self.textEntities = textEntities self.textEntities = textEntities
self.icon = icon self.icon = icon
self.location = location self.location = location
self.displayDuration = displayDuration
self.shouldDismissOnTouch = shouldDismissOnTouch self.shouldDismissOnTouch = shouldDismissOnTouch
self.openActiveTextItem = openActiveTextItem self.openActiveTextItem = openActiveTextItem
@ -396,13 +414,21 @@ public final class TooltipScreen: ViewController {
self.controllerNode.animateIn() self.controllerNode.animateIn()
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 5.0, execute: { [weak self] in let timeout: Double
switch self.displayDuration {
case .default:
timeout = 5.0
case let .custom(value):
timeout = value
}
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + timeout, execute: { [weak self] in
self?.dismiss() self?.dismiss()
}) })
} }
override public func loadDisplayNode() { override public func loadDisplayNode() {
self.displayNode = TooltipScreenNode(text: self.text, textEntities: self.textEntities, icon: self.icon, location: self.location, shouldDismissOnTouch: self.shouldDismissOnTouch, requestDismiss: { [weak self] in self.displayNode = TooltipScreenNode(text: self.text, textEntities: self.textEntities, icon: self.icon, location: self.location, displayDuration: self.displayDuration, shouldDismissOnTouch: self.shouldDismissOnTouch, requestDismiss: { [weak self] in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }

View File

@ -953,7 +953,7 @@ private final class WalletSplashScreenNode: ViewControllerTracingNode {
return nil return nil
} }
} }
self.termsNode.tapAttributeAction = { attributes in self.termsNode.tapAttributeAction = { attributes, _ in
if let _ = attributes[NSAttributedString.Key.underlineStyle] { if let _ = attributes[NSAttributedString.Key.underlineStyle] {
openTerms() openTerms()
} }