From 6e3c3940c2c790fb8e76e072f8ef3a61ff7b4128 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 23 Aug 2025 11:41:30 +0400 Subject: [PATCH] Various fixes --- submodules/Display/Source/TextAlertController.swift | 4 ++-- .../Sources/GiftOptionsScreen.swift | 12 ++++++++++-- .../PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift | 2 +- .../PeerInfoScreen/Sources/PeerInfoHeaderNode.swift | 10 +++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/submodules/Display/Source/TextAlertController.swift b/submodules/Display/Source/TextAlertController.swift index 291446f04b..2224e1a4d0 100644 --- a/submodules/Display/Source/TextAlertController.swift +++ b/submodules/Display/Source/TextAlertController.swift @@ -463,8 +463,8 @@ public final class TextAlertContentNode: AlertContentNode { } } -public func textAlertController(theme: AlertControllerTheme, title: NSAttributedString?, text: NSAttributedString, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, dismissOnOutsideTap: Bool = true) -> AlertController { - return AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title, text: text, actions: actions, actionLayout: actionLayout, dismissOnOutsideTap: dismissOnOutsideTap)) +public func textAlertController(theme: AlertControllerTheme, title: NSAttributedString?, text: NSAttributedString, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, dismissOnOutsideTap: Bool = true, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) -> AlertController { + return AlertController(theme: theme, contentNode: TextAlertContentNode(theme: theme, title: title, text: text, actions: actions, actionLayout: actionLayout, dismissOnOutsideTap: dismissOnOutsideTap, linkAction: linkAction)) } public func standardTextAlertController(theme: AlertControllerTheme, title: String?, text: String, actions: [TextAlertAction], actionLayout: TextAlertContentActionLayout = .horizontal, allowInputInset: Bool = true, parseMarkdown: Bool = false, dismissOnOutsideTap: Bool = true, linkAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil) -> AlertController { diff --git a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift index 6f1baf3c9e..8b5f38ca6d 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift @@ -434,6 +434,7 @@ final class GiftOptionsScreenComponent: Component { subject = .uniqueGift(gift: gift, price: nil) } + let context = component.context let _ = visibleItem.update( transition: itemTransition, component: AnyComponent( @@ -472,12 +473,19 @@ final class GiftOptionsScreenComponent: Component { let theme = AlertControllerTheme(presentationData: component.context.sharedContext.currentPresentationData.with { $0 }) let font = Font.regular(floor(theme.baseFontSize * 13.0 / 17.0)) let boldFont = Font.semibold(floor(theme.baseFontSize * 13.0 / 17.0)) - let attributedText = stringWithAppliedEntities(text, entities: entities, baseColor: theme.primaryColor, linkColor: .black, baseFont: font, linkFont: font, boldFont: boldFont, italicFont: font, boldItalicFont: font, fixedFont: font, blockQuoteFont: font, message: nil, paragraphAlignment: .center) + let attributedText = stringWithAppliedEntities(text, entities: entities, baseColor: theme.primaryColor, linkColor: theme.accentColor, baseFont: font, linkFont: font, boldFont: boldFont, italicFont: font, boldItalicFont: font, fixedFont: font, blockQuoteFont: font, message: nil, paragraphAlignment: .center) var dismissImpl: (() -> Void)? let alertController = textAlertController(theme: theme, title: NSAttributedString(string: strings.Gift_Options_GiftLocked_Title, font: Font.semibold(theme.baseFontSize), textColor: theme.primaryColor, paragraphAlignment: .center), text: attributedText, actions: [TextAlertAction(type: .defaultAction, title: strings.Common_OK, action: { dismissImpl?() - })], actionLayout: .horizontal, dismissOnOutsideTap: true) + })], actionLayout: .horizontal, dismissOnOutsideTap: true, linkAction: { [weak controller] attributes, _ in + if let value = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String { + dismissImpl?() + if let navigationController = controller?.navigationController as? NavigationController { + context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: value, forceExternal: false, presentationData: context.sharedContext.currentPresentationData.with { $0 }, navigationController: navigationController, dismissInput: {}) + } + } + }) dismissImpl = { [weak alertController] in alertController?.dismissAnimated() } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift index 32e3928b92..99ae063a1a 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoPaneNode/Sources/PeerInfoPaneNode.swift @@ -10,7 +10,6 @@ public enum PeerInfoPaneKey: Int32 { case botPreview case members case stories - case storyArchive case gifts case media case savedMessagesChats @@ -23,6 +22,7 @@ public enum PeerInfoPaneKey: Int32 { case groupsInCommon case similarChannels case similarBots + case storyArchive public init(tab: TelegramProfileTab) { switch tab { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift index d7a6ab2542..490974662c 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift @@ -1453,7 +1453,15 @@ final class PeerInfoHeaderNode: ASDisplayNode { if let previousPanelStatusData = previousPanelStatusData, let currentPanelStatusData = panelStatusData.0, let previousPanelStatusDataKey = previousPanelStatusData.key, let currentPanelStatusDataKey = currentPanelStatusData.key, previousPanelStatusDataKey != currentPanelStatusDataKey { if let snapshotView = self.panelSubtitleNode.view.snapshotContentTree() { - let direction: CGFloat = previousPanelStatusDataKey.rawValue > currentPanelStatusDataKey.rawValue ? 1.0 : -1.0 + let previousIndex = screenData?.availablePanes.firstIndex(of: previousPanelStatusDataKey) + let currentIndex = screenData?.availablePanes.firstIndex(of: currentPanelStatusDataKey) + + let direction: CGFloat + if let previousIndex, let currentIndex { + direction = previousIndex > currentIndex ? 1.0 : -1.0 + } else { + direction = previousPanelStatusDataKey.rawValue > currentPanelStatusDataKey.rawValue ? 1.0 : -1.0 + } self.panelSubtitleNode.view.superview?.addSubview(snapshotView) snapshotView.frame = self.panelSubtitleNode.frame