mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various improvements
This commit is contained in:
parent
2721cb44c5
commit
47ef146565
@ -271,16 +271,28 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
||||
if let attributedText = textInputView.attributedText, !attributedText.string.isEmpty {
|
||||
self.animateInputField = true
|
||||
if let textInputView = self.textInputView as? ChatInputTextView {
|
||||
self.fromMessageTextNode.textView.theme = textInputView.theme
|
||||
|
||||
let mainColor = presentationData.theme.chat.message.outgoing.accentControlColor
|
||||
self.toMessageTextNode.textView.theme = ChatInputTextView.Theme(
|
||||
quote: ChatInputTextView.Theme.Quote(
|
||||
background: mainColor.withMultipliedAlpha(0.1),
|
||||
foreground: mainColor,
|
||||
lineStyle: textInputView.theme?.quote.lineStyle ?? .solid
|
||||
if let textTheme = textInputView.theme {
|
||||
self.fromMessageTextNode.textView.theme = textTheme
|
||||
|
||||
let mainColor = presentationData.theme.chat.message.outgoing.accentControlColor
|
||||
let mappedLineStyle: ChatInputTextView.Theme.Quote.LineStyle
|
||||
switch textTheme.quote.lineStyle {
|
||||
case .solid:
|
||||
mappedLineStyle = .solid(color: mainColor)
|
||||
case .doubleDashed:
|
||||
mappedLineStyle = .doubleDashed(mainColor: mainColor, secondaryColor: .clear)
|
||||
case .tripleDashed:
|
||||
mappedLineStyle = .tripleDashed(mainColor: mainColor, secondaryColor: .clear, tertiaryColor: .clear)
|
||||
}
|
||||
|
||||
self.toMessageTextNode.textView.theme = ChatInputTextView.Theme(
|
||||
quote: ChatInputTextView.Theme.Quote(
|
||||
background: mainColor.withMultipliedAlpha(0.1),
|
||||
foreground: mainColor,
|
||||
lineStyle: mappedLineStyle
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
self.fromMessageTextNode.attributedText = attributedText
|
||||
|
||||
|
@ -466,7 +466,7 @@ public final class ChatBotInfoItemNode: ListViewItemNode {
|
||||
})
|
||||
}
|
||||
case let .textMention(name):
|
||||
self.item?.controllerInteraction.openPeerMention(name)
|
||||
self.item?.controllerInteraction.openPeerMention(name, tapAction.activate?())
|
||||
case let .botCommand(command):
|
||||
self.item?.controllerInteraction.sendBotCommand(nil, command)
|
||||
case let .hashtag(peerName, hashtag):
|
||||
|
@ -248,10 +248,10 @@ private final class ChatInputTextContainer: NSTextContainer {
|
||||
public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDelegate, NSTextStorageDelegate {
|
||||
public final class Theme: Equatable {
|
||||
public final class Quote: Equatable {
|
||||
public enum LineStyle {
|
||||
case solid
|
||||
case doubleDashed
|
||||
case tripleDashed
|
||||
public enum LineStyle: Equatable {
|
||||
case solid(color: UIColor)
|
||||
case doubleDashed(mainColor: UIColor, secondaryColor: UIColor)
|
||||
case tripleDashed(mainColor: UIColor, secondaryColor: UIColor, tertiaryColor: UIColor)
|
||||
}
|
||||
public let background: UIColor
|
||||
public let foreground: UIColor
|
||||
@ -804,12 +804,27 @@ private final class QuoteBackgroundView: UIView {
|
||||
|
||||
self.iconView.frame = CGRect(origin: CGPoint(x: size.width - 4.0 - quoteIcon.size.width, y: 4.0), size: quoteIcon.size)
|
||||
|
||||
var primaryColor: UIColor
|
||||
var secondaryColor: UIColor?
|
||||
var tertiaryColor: UIColor?
|
||||
switch theme.lineStyle {
|
||||
case let .solid(color):
|
||||
primaryColor = color
|
||||
case let .doubleDashed(mainColor, secondaryColorValue):
|
||||
primaryColor = mainColor
|
||||
secondaryColor = secondaryColorValue
|
||||
case let .tripleDashed(mainColor, secondaryColorValue, tertiaryColorValue):
|
||||
primaryColor = mainColor
|
||||
secondaryColor = secondaryColorValue
|
||||
tertiaryColor = tertiaryColorValue
|
||||
}
|
||||
|
||||
self.backgroundView.update(
|
||||
size: size,
|
||||
isTransparent: false,
|
||||
primaryColor: theme.foreground,
|
||||
secondaryColor: theme.lineStyle != .solid ? .clear : nil,
|
||||
thirdColor: theme.lineStyle == .tripleDashed ? .clear : nil,
|
||||
primaryColor: primaryColor,
|
||||
secondaryColor: secondaryColor,
|
||||
thirdColor: tertiaryColor,
|
||||
pattern: nil,
|
||||
animation: .None
|
||||
)
|
||||
|
@ -4166,7 +4166,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
||||
})
|
||||
case let .textMention(name):
|
||||
return .action(InternalBubbleTapAction.Action {
|
||||
self.item?.controllerInteraction.openPeerMention(name)
|
||||
self.item?.controllerInteraction.openPeerMention(name, tapAction.activate?())
|
||||
})
|
||||
case let .botCommand(command):
|
||||
if let item = self.item {
|
||||
|
@ -766,7 +766,38 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode {
|
||||
} else if let peerMention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention {
|
||||
return ChatMessageBubbleContentTapAction(content: .peerMention(peerId: peerMention.peerId, mention: peerMention.mention, openProfile: false))
|
||||
} else if let peerName = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerTextMention)] as? String {
|
||||
return ChatMessageBubbleContentTapAction(content: .textMention(peerName))
|
||||
var urlRange: NSRange?
|
||||
if let (_, _, urlRangeValue) = self.textNode.textNode.attributeSubstringWithRange(name: TelegramTextAttributes.PeerTextMention, index: index) {
|
||||
urlRange = urlRangeValue
|
||||
}
|
||||
|
||||
return ChatMessageBubbleContentTapAction(content: .textMention(peerName), activate: { [weak self] in
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let promise = Promise<Bool>()
|
||||
|
||||
self.linkProgressDisposable?.dispose()
|
||||
|
||||
if self.linkProgressRange != nil {
|
||||
self.linkProgressRange = nil
|
||||
self.updateLinkProgressState()
|
||||
}
|
||||
|
||||
self.linkProgressDisposable = (promise.get() |> deliverOnMainQueue).startStrict(next: { [weak self] value in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
let updatedRange: NSRange? = value ? urlRange : nil
|
||||
if self.linkProgressRange != updatedRange {
|
||||
self.linkProgressRange = updatedRange
|
||||
self.updateLinkProgressState()
|
||||
}
|
||||
})
|
||||
|
||||
return promise
|
||||
})
|
||||
} else if let botCommand = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.BotCommand)] as? String {
|
||||
return ChatMessageBubbleContentTapAction(content: .botCommand(botCommand))
|
||||
} else if let hashtag = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Hashtag)] as? TelegramHashtag {
|
||||
|
@ -264,7 +264,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode {
|
||||
if peer.id != context.account.peerId {
|
||||
self?.openPeer(peer: peer)
|
||||
}
|
||||
}, openPeerMention: { [weak self] name in
|
||||
}, openPeerMention: { [weak self] name, _ in
|
||||
self?.openPeerMention(name)
|
||||
}, openMessageContextMenu: { [weak self] message, selectAll, node, frame, anyRecognizer, location in
|
||||
let recognizer: TapLongTapOrDoubleTapGestureRecognizer? = anyRecognizer as? TapLongTapOrDoubleTapGestureRecognizer
|
||||
|
@ -112,7 +112,7 @@ public final class ChatControllerInteraction {
|
||||
|
||||
public let openMessage: (Message, ChatControllerInteractionOpenMessageMode) -> Bool
|
||||
public let openPeer: (EnginePeer, ChatControllerInteractionNavigateToPeer, MessageReference?, OpenPeerSource) -> Void
|
||||
public let openPeerMention: (String) -> Void
|
||||
public let openPeerMention: (String, Promise<Bool>?) -> Void
|
||||
public let openMessageContextMenu: (Message, Bool, ASDisplayNode, CGRect, UIGestureRecognizer?, CGPoint?) -> Void
|
||||
public let updateMessageReaction: (Message, ChatControllerInteractionReaction) -> Void
|
||||
public let openMessageReactionContextMenu: (Message, ContextExtractedContentContainingView, ContextGesture?, MessageReaction.Reaction) -> Void
|
||||
@ -230,7 +230,7 @@ public final class ChatControllerInteraction {
|
||||
public init(
|
||||
openMessage: @escaping (Message, ChatControllerInteractionOpenMessageMode) -> Bool,
|
||||
openPeer: @escaping (EnginePeer, ChatControllerInteractionNavigateToPeer, MessageReference?, OpenPeerSource) -> Void,
|
||||
openPeerMention: @escaping (String) -> Void,
|
||||
openPeerMention: @escaping (String, Promise<Bool>?) -> Void,
|
||||
openMessageContextMenu: @escaping (Message, Bool, ASDisplayNode, CGRect, UIGestureRecognizer?, CGPoint?) -> Void,
|
||||
openMessageReactionContextMenu: @escaping (Message, ContextExtractedContentContainingView, ContextGesture?, MessageReaction.Reaction) -> Void,
|
||||
updateMessageReaction: @escaping (Message, ChatControllerInteractionReaction) -> Void,
|
||||
|
@ -837,14 +837,14 @@ private func chatLinkOptions(selfController: ChatControllerImpl, sourceNode: ASD
|
||||
return
|
||||
}
|
||||
|
||||
if let (updatedUrlPreviewUrl, signal) = urlPreviewStateForInputText(NSAttributedString(string: url), context: selfController.context, currentQuery: nil), let updatedUrlPreviewUrl {
|
||||
if let webpage = webpageCache[updatedUrlPreviewUrl] {
|
||||
if let (updatedUrlPreviewState, signal) = urlPreviewStateForInputText(NSAttributedString(string: url), context: selfController.context, currentQuery: nil), let updatedUrlPreviewState {
|
||||
if let webpage = webpageCache[updatedUrlPreviewState.detectedUrl] {
|
||||
progress?.set(.single(false))
|
||||
|
||||
selfController.updateChatPresentationInterfaceState(animated: true, interactive: false, { state in
|
||||
if state.interfaceState.editMessage != nil {
|
||||
if var urlPreview = state.editingUrlPreview {
|
||||
urlPreview.url = updatedUrlPreviewUrl
|
||||
urlPreview.url = updatedUrlPreviewState.detectedUrl
|
||||
urlPreview.webPage = webpage
|
||||
|
||||
return state.updatedEditingUrlPreview(urlPreview)
|
||||
@ -853,7 +853,7 @@ private func chatLinkOptions(selfController: ChatControllerImpl, sourceNode: ASD
|
||||
}
|
||||
} else {
|
||||
if var urlPreview = state.urlPreview {
|
||||
urlPreview.url = updatedUrlPreviewUrl
|
||||
urlPreview.url = updatedUrlPreviewState.detectedUrl
|
||||
urlPreview.webPage = webpage
|
||||
|
||||
return state.updatedUrlPreview(urlPreview)
|
||||
@ -876,9 +876,9 @@ private func chatLinkOptions(selfController: ChatControllerImpl, sourceNode: ASD
|
||||
selfController.updateChatPresentationInterfaceState(animated: true, interactive: false, { state in
|
||||
if state.interfaceState.editMessage != nil {
|
||||
if let webpage = result(nil), var urlPreview = state.editingUrlPreview {
|
||||
urlPreview.url = updatedUrlPreviewUrl
|
||||
urlPreview.url = updatedUrlPreviewState.detectedUrl
|
||||
urlPreview.webPage = webpage
|
||||
webpageCache[updatedUrlPreviewUrl] = webpage
|
||||
webpageCache[updatedUrlPreviewState.detectedUrl] = webpage
|
||||
|
||||
return state.updatedEditingUrlPreview(urlPreview)
|
||||
} else {
|
||||
@ -886,9 +886,9 @@ private func chatLinkOptions(selfController: ChatControllerImpl, sourceNode: ASD
|
||||
}
|
||||
} else {
|
||||
if let webpage = result(nil), var urlPreview = state.urlPreview {
|
||||
urlPreview.url = updatedUrlPreviewUrl
|
||||
urlPreview.url = updatedUrlPreviewState.detectedUrl
|
||||
urlPreview.webPage = webpage
|
||||
webpageCache[updatedUrlPreviewUrl] = webpage
|
||||
webpageCache[updatedUrlPreviewState.detectedUrl] = webpage
|
||||
|
||||
return state.updatedUrlPreview(urlPreview)
|
||||
} else {
|
||||
|
@ -220,7 +220,7 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
}
|
||||
}
|
||||
|
||||
if let (updatedUrlPreviewUrl, updatedUrlPreviewSignal) = urlPreviewStateForInputText(updatedChatPresentationInterfaceState.interfaceState.composeInputState.inputText, context: selfController.context, currentQuery: selfController.urlPreviewQueryState?.0) {
|
||||
if let (updatedUrlPreviewState, updatedUrlPreviewSignal) = urlPreviewStateForInputText(updatedChatPresentationInterfaceState.interfaceState.composeInputState.inputText, context: selfController.context, currentQuery: selfController.urlPreviewQueryState?.0) {
|
||||
selfController.urlPreviewQueryState?.1.dispose()
|
||||
var inScope = true
|
||||
var inScopeResult: ((TelegramMediaWebpage?) -> TelegramMediaWebpage?)?
|
||||
@ -260,7 +260,7 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
}
|
||||
}
|
||||
|
||||
selfController.urlPreviewQueryState = (updatedUrlPreviewUrl, (filteredPreviewSignal |> deliverOnMainQueue).startStrict(next: { [weak selfController] (result) in
|
||||
selfController.urlPreviewQueryState = (updatedUrlPreviewState, (filteredPreviewSignal |> deliverOnMainQueue).startStrict(next: { [weak selfController] (result) in
|
||||
guard let selfController else {
|
||||
return
|
||||
}
|
||||
@ -269,9 +269,9 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
inScopeResult = result
|
||||
} else {
|
||||
selfController.updateChatPresentationInterfaceState(animated: true, interactive: false, {
|
||||
if let updatedUrlPreviewUrl = updatedUrlPreviewUrl, let webpage = result($0.urlPreview?.webPage) {
|
||||
if let updatedUrlPreviewState, let webpage = result($0.urlPreview?.webPage) {
|
||||
let updatedPreview = ChatPresentationInterfaceState.UrlPreview(
|
||||
url: updatedUrlPreviewUrl,
|
||||
url: updatedUrlPreviewState.detectedUrl,
|
||||
webPage: webpage,
|
||||
positionBelowText: $0.urlPreview?.positionBelowText ?? true,
|
||||
largeMedia: $0.urlPreview?.largeMedia
|
||||
@ -285,9 +285,9 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
}))
|
||||
inScope = false
|
||||
if let inScopeResult = inScopeResult {
|
||||
if let updatedUrlPreviewUrl = updatedUrlPreviewUrl, let webpage = inScopeResult(updatedChatPresentationInterfaceState.urlPreview?.webPage) {
|
||||
if let updatedUrlPreviewState, let webpage = inScopeResult(updatedChatPresentationInterfaceState.urlPreview?.webPage) {
|
||||
let updatedPreview = ChatPresentationInterfaceState.UrlPreview(
|
||||
url: updatedUrlPreviewUrl,
|
||||
url: updatedUrlPreviewState.detectedUrl,
|
||||
webPage: webpage,
|
||||
positionBelowText: updatedChatPresentationInterfaceState.urlPreview?.positionBelowText ?? true,
|
||||
largeMedia: updatedChatPresentationInterfaceState.urlPreview?.largeMedia
|
||||
@ -301,11 +301,11 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
|
||||
let isEditingMedia: Bool = updatedChatPresentationInterfaceState.editMessageState?.content != .plaintext
|
||||
let editingUrlPreviewText: NSAttributedString? = isEditingMedia ? nil : updatedChatPresentationInterfaceState.interfaceState.editMessage?.inputState.inputText
|
||||
if let (updatedEditingUrlPreviewUrl, updatedEditingUrlPreviewSignal) = urlPreviewStateForInputText(editingUrlPreviewText, context: selfController.context, currentQuery: selfController.editingUrlPreviewQueryState?.0) {
|
||||
if let (updatedEditingUrlPreviewState, updatedEditingUrlPreviewSignal) = urlPreviewStateForInputText(editingUrlPreviewText, context: selfController.context, currentQuery: selfController.editingUrlPreviewQueryState?.0) {
|
||||
selfController.editingUrlPreviewQueryState?.1.dispose()
|
||||
var inScope = true
|
||||
var inScopeResult: ((TelegramMediaWebpage?) -> TelegramMediaWebpage?)?
|
||||
selfController.editingUrlPreviewQueryState = (updatedEditingUrlPreviewUrl, (updatedEditingUrlPreviewSignal |> deliverOnMainQueue).startStrict(next: { [weak selfController] result in
|
||||
selfController.editingUrlPreviewQueryState = (updatedEditingUrlPreviewState, (updatedEditingUrlPreviewSignal |> deliverOnMainQueue).startStrict(next: { [weak selfController] result in
|
||||
guard let selfController else {
|
||||
return
|
||||
}
|
||||
@ -314,9 +314,9 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
inScopeResult = result
|
||||
} else {
|
||||
selfController.updateChatPresentationInterfaceState(animated: true, interactive: false, {
|
||||
if let updatedEditingUrlPreviewUrl = updatedEditingUrlPreviewUrl, let webpage = result($0.editingUrlPreview?.webPage) {
|
||||
if let updatedEditingUrlPreviewState, let webpage = result($0.editingUrlPreview?.webPage) {
|
||||
let updatedPreview = ChatPresentationInterfaceState.UrlPreview(
|
||||
url: updatedEditingUrlPreviewUrl,
|
||||
url: updatedEditingUrlPreviewState.detectedUrl,
|
||||
webPage: webpage,
|
||||
positionBelowText: $0.editingUrlPreview?.positionBelowText ?? true,
|
||||
largeMedia: $0.editingUrlPreview?.largeMedia
|
||||
@ -330,9 +330,9 @@ func updateChatPresentationInterfaceStateImpl(
|
||||
}))
|
||||
inScope = false
|
||||
if let inScopeResult = inScopeResult {
|
||||
if let updatedEditingUrlPreviewUrl = updatedEditingUrlPreviewUrl, let webpage = inScopeResult(updatedChatPresentationInterfaceState.editingUrlPreview?.webPage) {
|
||||
if let updatedEditingUrlPreviewState, let webpage = inScopeResult(updatedChatPresentationInterfaceState.editingUrlPreview?.webPage) {
|
||||
let updatedPreview = ChatPresentationInterfaceState.UrlPreview(
|
||||
url: updatedEditingUrlPreviewUrl,
|
||||
url: updatedEditingUrlPreviewState.detectedUrl,
|
||||
webPage: webpage,
|
||||
positionBelowText: updatedChatPresentationInterfaceState.editingUrlPreview?.positionBelowText ?? true,
|
||||
largeMedia: updatedChatPresentationInterfaceState.editingUrlPreview?.largeMedia
|
||||
|
@ -326,8 +326,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
var contextQueryStates: [ChatPresentationInputQueryKind: (ChatPresentationInputQuery, Disposable)] = [:]
|
||||
var searchQuerySuggestionState: (ChatPresentationInputQuery?, Disposable)?
|
||||
var urlPreviewQueryState: (String?, Disposable)?
|
||||
var editingUrlPreviewQueryState: (String?, Disposable)?
|
||||
var urlPreviewQueryState: (UrlPreviewState?, Disposable)?
|
||||
var editingUrlPreviewQueryState: (UrlPreviewState?, Disposable)?
|
||||
var replyMessageState: (EngineMessage.Id, Disposable)?
|
||||
var searchState: ChatSearchState?
|
||||
|
||||
@ -1113,7 +1113,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}, openPeerMention: { [weak self] mention in
|
||||
if let strongSelf = self {
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention)
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention, nil)
|
||||
}
|
||||
}, openPeer: { [weak self] peer in
|
||||
if let strongSelf = self {
|
||||
@ -1205,8 +1205,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
fromReactionMessageId = fromMessage?.id
|
||||
}
|
||||
self?.openPeer(peer: peer, navigation: navigation, fromMessage: fromMessage, fromReactionMessageId: fromReactionMessageId, expandAvatar: expandAvatar)
|
||||
}, openPeerMention: { [weak self] name in
|
||||
self?.openPeerMention(name)
|
||||
}, openPeerMention: { [weak self] name, progress in
|
||||
self?.openPeerMention(name, progress: progress)
|
||||
}, openMessageContextMenu: { [weak self] message, selectAll, node, frame, anyRecognizer, location in
|
||||
guard let strongSelf = self, strongSelf.isNodeLoaded else {
|
||||
return
|
||||
@ -14549,7 +14549,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
case let .textMention(mention):
|
||||
switch action {
|
||||
case .tap:
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention)
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention, nil)
|
||||
case .longTap:
|
||||
strongSelf.controllerInteraction?.longTap(.mention(mention), nil)
|
||||
}
|
||||
@ -14642,7 +14642,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
case let .textMention(mention):
|
||||
switch action {
|
||||
case .tap:
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention)
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention, nil)
|
||||
case .longTap:
|
||||
strongSelf.controllerInteraction?.longTap(.mention(mention), nil)
|
||||
}
|
||||
@ -14756,7 +14756,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
case let .textMention(mention):
|
||||
switch action {
|
||||
case .tap:
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention)
|
||||
strongSelf.controllerInteraction?.openPeerMention(mention, nil)
|
||||
case .longTap:
|
||||
strongSelf.controllerInteraction?.longTap(.mention(mention), nil)
|
||||
}
|
||||
@ -17075,7 +17075,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
|
||||
func openPeerMention(_ name: String, navigation: ChatControllerInteractionNavigateToPeer = .default, sourceMessageId: MessageId? = nil) {
|
||||
func openPeerMention(_ name: String, navigation: ChatControllerInteractionNavigateToPeer = .default, sourceMessageId: MessageId? = nil, progress: Promise<Bool>? = nil) {
|
||||
let _ = self.presentVoiceMessageDiscardAlert(action: {
|
||||
let disposable: MetaDisposable
|
||||
if let resolvePeerByNameDisposable = self.resolvePeerByNameDisposable {
|
||||
@ -17085,23 +17085,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.resolvePeerByNameDisposable = disposable
|
||||
}
|
||||
var resolveSignal = self.context.engine.peers.resolvePeerByName(name: name, ageLimit: 10)
|
||||
|> mapToSignal { result -> Signal<EnginePeer?, NoError> in
|
||||
guard case let .result(result) = result else {
|
||||
return .complete()
|
||||
}
|
||||
return .single(result)
|
||||
}
|
||||
|
||||
var cancelImpl: (() -> Void)?
|
||||
let presentationData = self.presentationData
|
||||
let progressSignal = Signal<Never, NoError> { [weak self] subscriber in
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||
cancelImpl?()
|
||||
}))
|
||||
self?.present(controller, in: .window(.root))
|
||||
return ActionDisposable { [weak controller] in
|
||||
Queue.mainQueue().async() {
|
||||
controller?.dismiss()
|
||||
if progress != nil {
|
||||
return ActionDisposable {
|
||||
}
|
||||
} else {
|
||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: {
|
||||
cancelImpl?()
|
||||
}))
|
||||
self?.present(controller, in: .window(.root))
|
||||
return ActionDisposable { [weak controller] in
|
||||
Queue.mainQueue().async() {
|
||||
controller?.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17119,22 +17118,26 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self?.resolvePeerByNameDisposable?.set(nil)
|
||||
}
|
||||
disposable.set((resolveSignal
|
||||
|> take(1)
|
||||
|> mapToSignal { peer -> Signal<Peer?, NoError> in
|
||||
return .single(peer?._asPeer())
|
||||
}
|
||||
|> deliverOnMainQueue).start(next: { [weak self] peer in
|
||||
if let strongSelf = self {
|
||||
if let peer = peer {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] result in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
switch result {
|
||||
case .progress:
|
||||
progress?.set(.single(true))
|
||||
case let .result(peer):
|
||||
progress?.set(.single(false))
|
||||
|
||||
if let peer {
|
||||
var navigation = navigation
|
||||
if case .default = navigation {
|
||||
if let peer = peer as? TelegramUser, peer.botInfo != nil {
|
||||
if case let .user(user) = peer, user.botInfo != nil {
|
||||
navigation = .chat(textInputState: nil, subject: nil, peekData: nil)
|
||||
}
|
||||
}
|
||||
strongSelf.openResolved(result: .peer(peer, navigation), sourceMessageId: sourceMessageId)
|
||||
self.openResolved(result: .peer(peer._asPeer(), navigation), sourceMessageId: sourceMessageId)
|
||||
} else {
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: nil, text: strongSelf.presentationData.strings.Resolve_ErrorNotFound, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
self.present(textAlertController(context: self.context, updatedPresentationData: self.updatedPresentationData, title: nil, text: self.presentationData.strings.Resolve_ErrorNotFound, actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
@ -506,7 +506,11 @@ func detectUrls(_ inputText: NSAttributedString?) -> [String] {
|
||||
return detectedUrls
|
||||
}
|
||||
|
||||
func urlPreviewStateForInputText(_ inputText: NSAttributedString?, context: AccountContext, currentQuery: String?) -> (String?, Signal<(TelegramMediaWebpage?) -> TelegramMediaWebpage?, NoError>)? {
|
||||
struct UrlPreviewState {
|
||||
var detectedUrl: String
|
||||
}
|
||||
|
||||
func urlPreviewStateForInputText(_ inputText: NSAttributedString?, context: AccountContext, currentQuery: UrlPreviewState?) -> (UrlPreviewState?, Signal<(TelegramMediaWebpage?) -> TelegramMediaWebpage?, NoError>)? {
|
||||
guard let _ = inputText else {
|
||||
if currentQuery != nil {
|
||||
return (nil, .single({ _ in return nil }))
|
||||
@ -516,9 +520,9 @@ func urlPreviewStateForInputText(_ inputText: NSAttributedString?, context: Acco
|
||||
}
|
||||
if let _ = dataDetector {
|
||||
let detectedUrl = detectUrls(inputText).first
|
||||
if detectedUrl != currentQuery {
|
||||
if detectedUrl != currentQuery?.detectedUrl {
|
||||
if let detectedUrl = detectedUrl {
|
||||
return (detectedUrl, webpagePreview(account: context.account, url: detectedUrl)
|
||||
return (UrlPreviewState(detectedUrl: detectedUrl), webpagePreview(account: context.account, url: detectedUrl)
|
||||
|> mapToSignal { result -> Signal<TelegramMediaWebpage?, NoError> in
|
||||
guard case let .result(result) = result else {
|
||||
return .complete()
|
||||
|
@ -470,6 +470,46 @@ final class ChatTextViewForOverlayContent: UIView, ChatInputPanelViewForOverlayC
|
||||
}
|
||||
}
|
||||
|
||||
private func makeTextInputTheme(context: AccountContext, interfaceState: ChatPresentationInterfaceState) -> ChatInputTextView.Theme {
|
||||
let lineStyle: ChatInputTextView.Theme.Quote.LineStyle
|
||||
let authorNameColor: UIColor
|
||||
|
||||
if let peer = interfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info, let nameColor = peer.nameColor {
|
||||
let colors = context.peerNameColors.get(nameColor)
|
||||
authorNameColor = colors.main
|
||||
|
||||
if let secondary = colors.secondary, let tertiary = colors.tertiary {
|
||||
lineStyle = .tripleDashed(mainColor: colors.main, secondaryColor: secondary, tertiaryColor: tertiary)
|
||||
} else if let secondary = colors.secondary {
|
||||
lineStyle = .doubleDashed(mainColor: colors.main, secondaryColor: secondary)
|
||||
} else {
|
||||
lineStyle = .solid(color: colors.main)
|
||||
}
|
||||
} else if let accountPeerColor = interfaceState.accountPeerColor {
|
||||
authorNameColor = interfaceState.theme.list.itemAccentColor
|
||||
|
||||
switch accountPeerColor.style {
|
||||
case .solid:
|
||||
lineStyle = .solid(color: authorNameColor)
|
||||
case .doubleDashed:
|
||||
lineStyle = .doubleDashed(mainColor: authorNameColor, secondaryColor: .clear)
|
||||
case .tripleDashed:
|
||||
lineStyle = .tripleDashed(mainColor: authorNameColor, secondaryColor: .clear, tertiaryColor: .clear)
|
||||
}
|
||||
} else {
|
||||
lineStyle = .solid(color: interfaceState.theme.list.itemAccentColor)
|
||||
authorNameColor = interfaceState.theme.list.itemAccentColor
|
||||
}
|
||||
|
||||
return ChatInputTextView.Theme(
|
||||
quote: ChatInputTextView.Theme.Quote(
|
||||
background: authorNameColor.withMultipliedAlpha(interfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||
foreground: authorNameColor,
|
||||
lineStyle: lineStyle
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, ChatInputTextNodeDelegate {
|
||||
let clippingNode: ASDisplayNode
|
||||
var textPlaceholderNode: ImmediateTextNode
|
||||
@ -1044,61 +1084,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
||||
var tintColor: UIColor = .blue
|
||||
var baseFontSize: CGFloat = 17.0
|
||||
var keyboardAppearance: UIKeyboardAppearance = UIKeyboardAppearance.default
|
||||
if let presentationInterfaceState = self.presentationInterfaceState {
|
||||
var lineStyle: ChatInputTextView.Theme.Quote.LineStyle = .solid
|
||||
let authorNameColor: UIColor
|
||||
let dashSecondaryColor: UIColor?
|
||||
let dashTertiaryColor: UIColor?
|
||||
|
||||
if let _ = self.context, let peer = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, case .broadcast = peer.info, let nameColor = peer.nameColor {
|
||||
let _ = nameColor
|
||||
|
||||
lineStyle = .solid
|
||||
authorNameColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
dashSecondaryColor = nil
|
||||
dashTertiaryColor = nil
|
||||
|
||||
/*let colors = context.peerNameColors.get(nameColor)
|
||||
|
||||
authorNameColor = colors.main
|
||||
dashSecondaryColor = colors.secondary
|
||||
dashTertiaryColor = colors.tertiary
|
||||
|
||||
if dashSecondaryColor != nil {
|
||||
lineStyle = .doubleDashed
|
||||
} else {
|
||||
lineStyle = .solid
|
||||
}*/
|
||||
} else if let accountPeerColor = presentationInterfaceState.accountPeerColor {
|
||||
switch accountPeerColor.style {
|
||||
case .solid:
|
||||
lineStyle = .solid
|
||||
case .doubleDashed:
|
||||
lineStyle = .doubleDashed
|
||||
case .tripleDashed:
|
||||
lineStyle = .tripleDashed
|
||||
}
|
||||
|
||||
authorNameColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
dashSecondaryColor = .clear
|
||||
dashTertiaryColor = nil
|
||||
} else {
|
||||
lineStyle = .solid
|
||||
authorNameColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
dashSecondaryColor = nil
|
||||
dashTertiaryColor = nil
|
||||
}
|
||||
|
||||
let _ = dashSecondaryColor
|
||||
let _ = dashTertiaryColor
|
||||
|
||||
textInputNode.textView.theme = ChatInputTextView.Theme(
|
||||
quote: ChatInputTextView.Theme.Quote(
|
||||
background: authorNameColor.withMultipliedAlpha(presentationInterfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||
foreground: authorNameColor,
|
||||
lineStyle: lineStyle
|
||||
)
|
||||
)
|
||||
if let context = self.context, let presentationInterfaceState = self.presentationInterfaceState {
|
||||
textInputNode.textView.theme = makeTextInputTheme(context: context, interfaceState: presentationInterfaceState)
|
||||
|
||||
textColor = presentationInterfaceState.theme.chat.inputPanel.inputTextColor
|
||||
tintColor = presentationInterfaceState.theme.list.itemAccentColor
|
||||
@ -1674,25 +1661,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
||||
textInputNode.tintColorDidChange()
|
||||
}
|
||||
|
||||
if let textInputNode = self.textInputNode {
|
||||
var lineStyle: ChatInputTextView.Theme.Quote.LineStyle = .solid
|
||||
if let accountPeerColor = interfaceState.accountPeerColor {
|
||||
switch accountPeerColor.style {
|
||||
case .solid:
|
||||
lineStyle = .solid
|
||||
case .doubleDashed:
|
||||
lineStyle = .doubleDashed
|
||||
case .tripleDashed:
|
||||
lineStyle = .tripleDashed
|
||||
}
|
||||
}
|
||||
textInputNode.textView.theme = ChatInputTextView.Theme(
|
||||
quote: ChatInputTextView.Theme.Quote(
|
||||
background: interfaceState.theme.list.itemAccentColor.withMultipliedAlpha(interfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||
foreground: interfaceState.theme.list.itemAccentColor,
|
||||
lineStyle: lineStyle
|
||||
)
|
||||
)
|
||||
if let textInputNode = self.textInputNode, let context = self.context {
|
||||
textInputNode.textView.theme = makeTextInputTheme(context: context, interfaceState: interfaceState)
|
||||
}
|
||||
|
||||
let keyboardAppearance = interfaceState.theme.rootController.keyboardColor.keyboardAppearance
|
||||
|
@ -75,7 +75,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu
|
||||
return false
|
||||
}
|
||||
}, openPeer: { _, _, _, _ in
|
||||
}, openPeerMention: { _ in
|
||||
}, openPeerMention: { _, _ in
|
||||
}, openMessageContextMenu: { _, _, _, _, _, _ in
|
||||
}, openMessageReactionContextMenu: { _, _, _, _ in
|
||||
}, updateMessageReaction: { _, _ in
|
||||
|
@ -2413,7 +2413,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
return strongSelf.openMessage(id: message.id)
|
||||
}, openPeer: { [weak self] peer, navigation, _, _ in
|
||||
self?.openPeer(peerId: peer.id, navigation: navigation)
|
||||
}, openPeerMention: { _ in
|
||||
}, openPeerMention: { _, _ in
|
||||
}, openMessageContextMenu: { [weak self] message, _, node, frame, anyRecognizer, _ in
|
||||
guard let strongSelf = self, let node = node as? ContextExtractedContentContainingNode else {
|
||||
return
|
||||
|
@ -1492,7 +1492,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
let controllerInteraction: ChatControllerInteraction
|
||||
|
||||
controllerInteraction = ChatControllerInteraction(openMessage: { _, _ in
|
||||
return false }, openPeer: { _, _, _, _ in }, openPeerMention: { _ in }, openMessageContextMenu: { _, _, _, _, _, _ in }, openMessageReactionContextMenu: { _, _, _, _ in
|
||||
return false }, openPeer: { _, _, _, _ in }, openPeerMention: { _, _ in }, openMessageContextMenu: { _, _, _, _, _, _ in }, openMessageReactionContextMenu: { _, _, _, _ in
|
||||
}, updateMessageReaction: { _, _ in }, activateMessagePinch: { _ in
|
||||
}, openMessageContextActions: { _, _, _, _ in }, navigateToMessage: { _, _, _ in }, navigateToMessageStandalone: { _ in
|
||||
}, navigateToThreadMessage: { _, _, _ in
|
||||
|
Loading…
x
Reference in New Issue
Block a user