From e4d9d2e53aa740d9ceb3fdc28720299b50f710b2 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 16 Jul 2024 17:39:42 +0400 Subject: [PATCH] Various improvements --- .../ChatMessageGiftBubbleContentNode.swift | 8 ++++++- .../Sources/MediaEditorUtils.swift | 2 +- .../Components/StickerPickerScreen/BUILD | 1 + .../Sources/StickerPickerScreen.swift | 24 +++++++++++++++++++ submodules/TelegramUI/Sources/OpenUrl.swift | 10 ++++++++ .../UrlHandling/Sources/UrlHandling.swift | 5 ++++ .../WebUI/Sources/WebAppController.swift | 2 +- 7 files changed, 49 insertions(+), 3 deletions(-) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift index 152625ba23..43f5fe28b2 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift @@ -255,7 +255,13 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { months = monthsValue text = item.presentationData.strings.Notification_PremiumGift_Subtitle(item.presentationData.strings.Notification_PremiumGift_Months(months)).string case let .giftStars(_, _, count, _, _, _): - months = 6 + if count <= 1000 { + months = 3 + } else if count < 2500 { + months = 6 + } else { + months = 12 + } var peerName = "" if let peer = item.message.peers[item.message.id.peerId] { peerName = EnginePeer(peer).compactDisplayTitle diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorUtils.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorUtils.swift index b87eef93c0..52de11f16e 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorUtils.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorUtils.swift @@ -8,7 +8,7 @@ import DeviceLocationManager func emojiFor(for meteocode: Int, date: Date, location: CLLocationCoordinate2D) -> String? { var emoji = weatherEmoji(for: meteocode) - if ["☀️", "🌤️"].contains(emoji) && isNightTime(date: date, location: location) { + if ["☀️", "🌤️"].contains(emoji) && isNightTime(date: date, location: location) && !"".isEmpty { emoji = moonPhaseEmoji(for: date) } return emoji diff --git a/submodules/TelegramUI/Components/StickerPickerScreen/BUILD b/submodules/TelegramUI/Components/StickerPickerScreen/BUILD index a216f747cb..5ad856e097 100644 --- a/submodules/TelegramUI/Components/StickerPickerScreen/BUILD +++ b/submodules/TelegramUI/Components/StickerPickerScreen/BUILD @@ -41,6 +41,7 @@ swift_library( "//submodules/ContextUI", "//submodules/UndoUI", "//submodules/GalleryUI", + "//submodules/TelegramUI/Components/TextLoadingEffect", ], visibility = [ "//visibility:public", diff --git a/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift b/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift index b5403e11e1..e4638ad8f6 100644 --- a/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift +++ b/submodules/TelegramUI/Components/StickerPickerScreen/Sources/StickerPickerScreen.swift @@ -24,6 +24,7 @@ import LottieComponent import LottieComponentResourceContent import UndoUI import GalleryUI +import TextLoadingEffect private final class StickerSelectionComponent: Component { typealias EnvironmentType = Empty @@ -2216,6 +2217,7 @@ private final class InteractiveStickerButtonContent: Component { private let backgroundLayer = SimpleLayer() let tintBackgroundLayer = SimpleLayer() + private var loadingView: TextLoadingEffectView? private var icon: ComponentView private var title: ComponentView @@ -2295,8 +2297,24 @@ private final class InteractiveStickerButtonContent: Component { } transition.setFrame(view: view, frame: CGRect(origin: CGPoint(x: padding + iconSize.width + spacing, y: floorToScreenPixels((buttonSize.height - titleSize.height) / 2.0)), size: titleSize)) } + + if let loadingView = self.loadingView { + self.loadingView = nil + loadingView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false, completion: { _ in + loadingView.removeFromSuperview() + }) + } } else { buttonSize = CGSize(width: 87.0, height: 34.0) + + let loadingView: TextLoadingEffectView + if let current = self.loadingView { + loadingView = current + } else { + loadingView = TextLoadingEffectView() + self.addSubview(loadingView) + self.loadingView = loadingView + } } self.backgroundLayer.cornerRadius = 6.0 @@ -2315,6 +2333,12 @@ private final class InteractiveStickerButtonContent: Component { } } + if let loadingView = self.loadingView { + let loadingSize = CGSize(width: buttonSize.width - 18.0, height: 16.0) + loadingView.update(color: UIColor.white, rect: CGRect(origin: .zero, size: loadingSize)) + loadingView.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((buttonSize.width - loadingSize.width) / 2.0), y: floorToScreenPixels((buttonSize.width - loadingSize.width) / 2.0)), size: loadingSize) + } + return buttonSize } } diff --git a/submodules/TelegramUI/Sources/OpenUrl.swift b/submodules/TelegramUI/Sources/OpenUrl.swift index 47f8cb34fc..0ac8c5a3e9 100644 --- a/submodules/TelegramUI/Sources/OpenUrl.swift +++ b/submodules/TelegramUI/Sources/OpenUrl.swift @@ -737,6 +737,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur var appName: String? var startApp: String? var text: String? + var profile: Bool = false if let queryItems = components.queryItems { for queryItem in queryItems { if let value = queryItem.value { @@ -779,6 +780,8 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur startGroup = "" } else if queryItem.name == "startchannel" { startChannel = "" + } else if queryItem.name == "profile" { + profile = true } } } @@ -858,6 +861,13 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur } convertedUrl = result } + if profile, let current = convertedUrl { + if current.contains("?") { + convertedUrl = current + "&profile" + } else { + convertedUrl = current + "?profile" + } + } } } else if parsedUrl.host == "hostOverride" { if let components = URLComponents(string: "/?" + query) { diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index 9bcc4064ea..f8fb3f07c5 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -75,6 +75,7 @@ public enum ParsedInternalPeerUrlParameter { case story(Int32) case boost case text(String) + case profile } public enum ParsedInternalUrl { @@ -318,6 +319,8 @@ public func parseInternalUrl(sharedContext: SharedAccountContext, query: String) return .peer(.name(peerName), .groupBotStart("", botAdminRights)) } else if queryItem.name == "boost" { return .peer(.name(peerName), .boost) + } else if queryItem.name == "profile" { + return .peer(.name(peerName), .profile) } } } @@ -688,6 +691,8 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) if let peer = peer { if let parameter = parameter { switch parameter { + case .profile: + return .single(.result(.peer(peer._asPeer(), .info(nil)))) case let .text(text): var textInputState: ChatTextInputState? if !text.isEmpty { diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 995cc1d22b..26a8165a3c 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -1946,7 +1946,7 @@ public final class WebAppController: ViewController, AttachmentContainable { guard let self else { return } - let shareController = ShareController(context: context, subject: .url("https://t.me/\(addressName)")) + let shareController = ShareController(context: context, subject: .url("https://t.me/\(addressName)?profile")) shareController.actionCompleted = { [weak self] in let presentationData = context.sharedContext.currentPresentationData.with { $0 } self?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.Conversation_LinkCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))