From c696a0aaed004e16b7b64c63d3beeda08a604da8 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 9 Feb 2025 00:46:02 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 1 + .../AccountContext/Sources/AccountContext.swift | 1 + .../Sources/PremiumOptionComponent.swift | 3 +-- .../ChatMessageGiftBubbleContentNode.swift | 17 ++++++++++++----- .../PeerInfoScreen/Sources/PeerInfoData.swift | 4 ++-- .../Sources/PeerInfoPaneContainerNode.swift | 9 ++++++--- .../PeerInfoScreen/Sources/PeerInfoScreen.swift | 7 ++----- .../Sources/UserApperanceScreen.swift | 2 +- .../TelegramUI/Sources/OpenResolvedUrl.swift | 12 ++++++++++++ submodules/TelegramUI/Sources/OpenUrl.swift | 2 ++ .../Sources/FullscreenControlsComponent.swift | 8 ++++++++ 11 files changed, 48 insertions(+), 18 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 48060e73c8..fce72fef5b 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -13568,6 +13568,7 @@ Sorry for the inconvenience."; "Notification.StarGift.Unpack" = "Unpack"; +"Notification.StarGift.Collectible" = "Collectible"; "Notification.StarGift.Model" = "Model"; "Notification.StarGift.Backdrop" = "Backdrop"; "Notification.StarGift.Symbol" = "Symbol"; diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index dff4dcd6f8..95514ec2bb 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -190,6 +190,7 @@ public enum ResolvedUrlSettingsSection { case autoremoveMessages case twoStepAuth case enableLog + case phonePrivacy } public struct ResolvedBotChoosePeerTypes: OptionSet { diff --git a/submodules/PremiumUI/Sources/PremiumOptionComponent.swift b/submodules/PremiumUI/Sources/PremiumOptionComponent.swift index df785dff42..2bc42b0c5c 100644 --- a/submodules/PremiumUI/Sources/PremiumOptionComponent.swift +++ b/submodules/PremiumUI/Sources/PremiumOptionComponent.swift @@ -153,8 +153,7 @@ final class PremiumOptionComponent: CombinedComponent { transition: context.transition ) - let discountPosition = CGPoint(x: insets.left + title.size.width + 6.0 + discountSize.width / 2.0, y: insets.top + title.size.height / 2.0) - + let discountPosition = CGPoint(x: insets.left + title.size.width + 6.0 + discountSize.width / 2.0, y: insets.top + title.size.height / 2.0 - 2.0) context.add(discountBackground .position(discountPosition) ) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift index 3de1f1658e..7fa100d6f0 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode/Sources/ChatMessageGiftBubbleContentNode.swift @@ -426,7 +426,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { peerName = EnginePeer(channel).compactDisplayTitle } title = item.presentationData.strings.Notification_StarsGiveaway_Title - text = item.presentationData.strings.Notification_StarsGiveaway_Subtitle(peerName, item.presentationData.strings.Notification_StarsGiveaway_Subtitle_Stars(Int32(count))).string + let starsString = item.presentationData.strings.Notification_StarsGiveaway_Subtitle_Stars(Int32(count)).replacingOccurrences(of: " ", with: "\u{00A0}") + text = item.presentationData.strings.Notification_StarsGiveaway_Subtitle(peerName, starsString).string case let .giftCode(_, fromGiveaway, unclaimed, channelId, monthsValue, _, _, _, _, giftText, giftEntities): if channelId == nil { months = monthsValue @@ -523,7 +524,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { } if peerName.isEmpty { if let convertStars, convertStars > 0 { - text = item.presentationData.strings.Notification_StarGift_Subtitle(item.presentationData.strings.Notification_StarGift_Subtitle_Stars(Int32(convertStars))).string + let starsString = item.presentationData.strings.Notification_StarGift_Subtitle_Stars(Int32(convertStars)).replacingOccurrences(of: " ", with: "\u{00A0}") + text = item.presentationData.strings.Notification_StarGift_Subtitle(starsString).string } else { text = item.presentationData.strings.Notification_StarGift_Bot_Subtitle } @@ -531,7 +533,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { if upgradeStars != nil { text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade_Other(peerName).string } else if let convertStars, convertStars > 0 { - let formattedString = item.presentationData.strings.Notification_StarGift_Subtitle_Other(peerName, item.presentationData.strings.Notification_StarGift_Subtitle_Other_Stars(Int32(convertStars))) + let starsString = item.presentationData.strings.Notification_StarGift_Subtitle_Other_Stars(Int32(convertStars)).replacingOccurrences(of: " ", with: "\u{00A0}") + let formattedString = item.presentationData.strings.Notification_StarGift_Subtitle_Other(peerName, starsString) text = formattedString.string if let starsRange = formattedString.ranges.last { entities.append(MessageTextEntity(range: starsRange.range.lowerBound ..< starsRange.range.upperBound, type: .Bold)) @@ -560,6 +563,8 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { case let .starGiftUnique(gift, isUpgrade, _, _, _, _, isRefunded, _, _, _): if case let .unique(uniqueGift) = gift { isStarGift = true + + let isSelfGift = item.message.id.peerId == item.context.account.peerId let authorName: String if isUpgrade { if item.message.author?.id == item.context.account.peerId { @@ -570,12 +575,14 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode { } else { authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? "" } - if item.message.id.peerId.isTelegramNotifications { + if isSelfGift { + title = item.presentationData.strings.Notification_StarGift_Self_Title + } else if item.message.id.peerId.isTelegramNotifications { title = item.presentationData.strings.Notification_StarGift_TitleShort } else { title = isStoryEntity ? uniqueGift.title : item.presentationData.strings.Notification_StarGift_Title(authorName).string } - text = isStoryEntity ? "**Collectible #\(uniqueGift.number)**" : "**\(uniqueGift.title) #\(uniqueGift.number)**" + text = isStoryEntity ? "**\(item.presentationData.strings.Notification_StarGift_Collectible) #\(uniqueGift.number)**" : "**\(uniqueGift.title) #\(uniqueGift.number)**" ribbonTitle = isStoryEntity ? "" : item.presentationData.strings.Notification_StarGift_Gift buttonTitle = isStoryEntity ? "" : item.presentationData.strings.Notification_StarGift_View modelTitle = item.presentationData.strings.Notification_StarGift_Model diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoData.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoData.swift index c16d3c4379..3892bbae0b 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoData.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoData.swift @@ -952,7 +952,7 @@ func peerInfoScreenSettingsData(context: AccountContext, peerId: EnginePeer.Id, } } -func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, isSettings: Bool, isMyProfile: Bool, hintGroupInCommon: PeerId?, existingRequestsContext: PeerInvitationImportersContext?, chatLocation: ChatLocation, chatLocationContextHolder: Atomic, privacySettings: Signal) -> Signal { +func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, isSettings: Bool, isMyProfile: Bool, hintGroupInCommon: PeerId?, existingRequestsContext: PeerInvitationImportersContext?, chatLocation: ChatLocation, chatLocationContextHolder: Atomic, privacySettings: Signal, forceHasGifts: Bool) -> Signal { return peerInfoScreenInputData(context: context, peerId: peerId, isSettings: isSettings) |> mapToSignal { inputData -> Signal in let wasUpgradedGroup = Atomic(value: nil) @@ -1606,7 +1606,7 @@ func peerInfoScreenData(context: AccountContext, peerId: PeerId, strings: Presen } if availablePanes != nil, let cachedData = peerView.cachedData as? CachedChannelData { - if (cachedData.starGiftsCount ?? 0) > 0 || (profileGiftsState.count ?? 0) > 0 { + if (cachedData.starGiftsCount ?? 0) > 0 || (profileGiftsState.count ?? 0) > 0 || forceHasGifts { availablePanes?.insert(.gifts, at: hasStories ? 1 : 0) } } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift index 62a60640cd..2ccef75a18 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoPaneContainerNode.swift @@ -1273,9 +1273,12 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegat self.isReady.set(.single(true)) } } - if let previousCurrentPaneKey = previousCurrentPaneKey, self.currentPaneKey != previousCurrentPaneKey { - self.currentPaneUpdated?(self.expandOnSwitch) - self.expandOnSwitch = false + if let previousCurrentPaneKey, self.currentPaneKey != previousCurrentPaneKey || self.expandOnSwitch { + if self.currentPaneKey == nil && previousCurrentPaneKey == .gifts { + } else { + self.currentPaneUpdated?(self.expandOnSwitch) + self.expandOnSwitch = false + } } if updateCurrentPaneStatus { self.currentPaneStatusPromise.set(self.currentPane?.node.status ?? .single(nil)) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 9d643cc5ea..77131b15b5 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -4603,7 +4603,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro self.privacySettings.set(.single(nil)) } - screenData = peerInfoScreenData(context: context, peerId: peerId, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, isSettings: self.isSettings, isMyProfile: self.isMyProfile, hintGroupInCommon: hintGroupInCommon, existingRequestsContext: requestsContext, chatLocation: self.chatLocation, chatLocationContextHolder: self.chatLocationContextHolder, privacySettings: self.privacySettings.get()) + screenData = peerInfoScreenData(context: context, peerId: peerId, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, isSettings: self.isSettings, isMyProfile: self.isMyProfile, hintGroupInCommon: hintGroupInCommon, existingRequestsContext: requestsContext, chatLocation: self.chatLocation, chatLocationContextHolder: self.chatLocationContextHolder, privacySettings: self.privacySettings.get(), forceHasGifts: initialPaneKey == .gifts) var previousTimestamp: Double? self.headerNode.displayPremiumIntro = { [weak self] sourceView, peerStatus, emojiStatusFileAndPack, white in @@ -6497,16 +6497,13 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro } let boostTitle: String - var isNew = false switch channel.info { case .group: boostTitle = presentationData.strings.PeerInfo_Group_Boost - isNew = true case .broadcast: boostTitle = presentationData.strings.PeerInfo_Channel_Boost } - - items.append(.action(ContextMenuActionItem(text: boostTitle, badge: isNew ? ContextMenuActionBadge(value: presentationData.strings.Settings_New, color: .accent, style: .label) : nil, icon: { theme in + items.append(.action(ContextMenuActionItem(text: boostTitle, badge: nil, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Boost"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in f(.dismissWithoutContent) diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift index 7dbe2cd3b7..0bbf2fa9fe 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/UserApperanceScreen.swift @@ -402,7 +402,7 @@ final class UserAppearanceScreenComponent: Component { if case .info = action { var replaceImpl: ((ViewController) -> Void)? let controller = component.context.sharedContext.makePremiumDemoController(context: component.context, subject: .colors, forceDark: false, action: { - let controller = component.context.sharedContext.makePremiumIntroController(context: component.context, source: .settings, forceDark: false, dismissed: nil) + let controller = component.context.sharedContext.makePremiumIntroController(context: component.context, source: .nameColor, forceDark: false, dismissed: nil) replaceImpl?(controller) }, dismissed: nil) replaceImpl = { [weak controller] c in diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index 0bf8672f70..e521548cbf 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -703,6 +703,18 @@ func openResolvedUrlImpl( navigationController.setViewControllers(controllers, animated: true) } } + case .phonePrivacy: + let privacySignal = context.engine.privacy.requestAccountPrivacySettings() + let _ = (privacySignal + |> deliverOnMainQueue).start(next: { info in + let current: SelectivePrivacySettings = info.phoneNumber + if let navigationController = navigationController { + let controller = selectivePrivacySettingsController(context: context, kind: .phoneNumber, current: current, phoneDiscoveryEnabled: info.phoneDiscoveryEnabled, updated: { _, _, _, _ in + }) + controller.navigationPresentation = .modal + navigationController.pushViewController(controller) + } + }) } case let .premiumOffer(reference): dismissInput() diff --git a/submodules/TelegramUI/Sources/OpenUrl.swift b/submodules/TelegramUI/Sources/OpenUrl.swift index 71230c9e5a..e54e402009 100644 --- a/submodules/TelegramUI/Sources/OpenUrl.swift +++ b/submodules/TelegramUI/Sources/OpenUrl.swift @@ -1014,6 +1014,8 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur section = .twoStepAuth case "enable_log": section = .enableLog + case "phone_privacy": + section = .phonePrivacy default: break } diff --git a/submodules/WebUI/Sources/FullscreenControlsComponent.swift b/submodules/WebUI/Sources/FullscreenControlsComponent.swift index 69dbd1716a..f5ae78231f 100644 --- a/submodules/WebUI/Sources/FullscreenControlsComponent.swift +++ b/submodules/WebUI/Sources/FullscreenControlsComponent.swift @@ -353,6 +353,14 @@ final class FullscreenControlsComponent: Component { return CGSize(width: availableSize.width, height: leftBackgroundSize.height) } + + override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + let result = super.hitTest(point, with: event) + if result === self { + return nil + } + return result + } } func makeView() -> View {