From aeb2e35d4223343dade479858557bb0e36bed04a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 11 Dec 2025 21:36:25 +0400 Subject: [PATCH] Various fixes --- .../Sources/SheetComponent.swift | 4 +- .../MtProtoKit/Sources/MTApiEnvironment.m | 16 +++ .../SelectivePrivacySettingsController.swift | 6 + .../Payments/StarGiftsAuctions.swift | 12 +- .../Sources/ServiceMessageStrings.swift | 10 +- ...hatMessageGiftOfferBubbleContentNode.swift | 2 +- .../Sources/GiftOptionsScreen.swift | 3 + .../Sources/GiftAuctionBidScreen.swift | 57 +++++++- .../GiftAuctionWearPreviewScreen.swift | 2 +- .../Sources/GiftOfferAlertController.swift | 2 +- .../Sources/GiftViewScreen.swift | 122 ++++++++++++------ .../Sources/TableComponent.swift | 11 +- .../PeerInfoScreenCallListItem.swift | 7 +- .../Sources/StarsWithdrawalScreen.swift | 13 +- .../DeviceModel/Sources/DeviceModel.swift | 7 +- 15 files changed, 202 insertions(+), 72 deletions(-) diff --git a/submodules/Components/SheetComponent/Sources/SheetComponent.swift b/submodules/Components/SheetComponent/Sources/SheetComponent.swift index 32d5c33a4a..ccca83dc4c 100644 --- a/submodules/Components/SheetComponent/Sources/SheetComponent.swift +++ b/submodules/Components/SheetComponent/Sources/SheetComponent.swift @@ -468,7 +468,7 @@ public final class SheetComponent: C switch component.style { case .glass: let clipFrame = CGRect(origin: CGPoint(x: glassInset, y: -glassInset), size: CGSize(width: contentSize.width, height: contentSize.height)) - self.clipView.update(size: clipFrame.size, color: .clear, topCornerRadius: topCornerRadius, bottomCornerRadius: bottomCornerRadius, transition: transition) + self.clipView.update(size: clipFrame.size, color: .clear, topCornerRadius: topCornerRadius - 1.5, bottomCornerRadius: bottomCornerRadius, transition: transition) transition.setFrame(view: self.clipView, frame: clipFrame) transition.setFrame(view: contentView, frame: CGRect(origin: .zero, size: CGSize(width: contentSize.width, height: contentSize.height)), completion: nil) transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(x: glassInset, y: -glassInset), size: CGSize(width: contentSize.width, height: contentSize.height)), completion: nil) @@ -482,7 +482,7 @@ public final class SheetComponent: C transition.setFrame(view: effectView, frame: CGRect(origin: .zero, size: CGSize(width: contentSize.width, height: contentSize.height + 1000.0)), completion: nil) } } - self.backgroundView.update(size: contentSize, color: backgroundColor, topCornerRadius: topCornerRadius, bottomCornerRadius: bottomCornerRadius, transition: transition) + self.backgroundView.update(size: contentSize, color: backgroundColor, topCornerRadius: topCornerRadius + 1.5, bottomCornerRadius: bottomCornerRadius, transition: transition) } } transition.setFrame(view: self.scrollView, frame: CGRect(origin: CGPoint(), size: availableSize), completion: nil) diff --git a/submodules/MtProtoKit/Sources/MTApiEnvironment.m b/submodules/MtProtoKit/Sources/MTApiEnvironment.m index e4d6010437..e42c2bc549 100644 --- a/submodules/MtProtoKit/Sources/MTApiEnvironment.m +++ b/submodules/MtProtoKit/Sources/MTApiEnvironment.m @@ -716,6 +716,22 @@ NSString *suffix = @""; [platform isEqualToString:@"iPad14,11"]) return @"iPad Air (7th gen)"; + if ([platform isEqualToString:@"iPad15,3"] || + [platform isEqualToString:@"iPad15,4"]) + return @"iPad Air 11 inch (7th gen)"; + + if ([platform isEqualToString:@"iPad15,5"] || + [platform isEqualToString:@"iPad15,6"]) + return @"iPad Air 13 inch (7th gen)"; + + if ([platform isEqualToString:@"iPad15,7"] || + [platform isEqualToString:@"iPad15,8"]) + return @"iPad (11th gen)"; + + if ([platform isEqualToString:@"iPad16,1"] || + [platform isEqualToString:@"iPad16,2"]) + return @"iPad mini (7th gen)"; + if ([platform isEqualToString:@"iPad16,3"] || [platform isEqualToString:@"iPad16,4"]) return @"iPad Pro 11 inch (5th gen)"; diff --git a/submodules/SettingsUI/Sources/Privacy and Security/SelectivePrivacySettingsController.swift b/submodules/SettingsUI/Sources/Privacy and Security/SelectivePrivacySettingsController.swift index 5f656d9bcc..6913f3f3fe 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/SelectivePrivacySettingsController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/SelectivePrivacySettingsController.swift @@ -1664,6 +1664,12 @@ public func selectivePrivacySettingsController( } else { updatedDisallowedGifts.remove(.premium) } + case .channel: + if value { + updatedDisallowedGifts.insert(.channel) + } else { + updatedDisallowedGifts.remove(.channel) + } default: break } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift index 10ed47ea5a..a3652a45e9 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift @@ -580,7 +580,7 @@ public class GiftAuctionsManager { } public extension GiftAuctionContext.State { - func getPlace(myBid: Int64?, myBidDate: Int32?) -> Int32? { + func getPlace(myBid: Int64?, myBidDate: Int32?) -> (place: Int32, isApproximate: Bool)? { guard case let .ongoing(_, _, _, _, bidLevels, _, _, _, _, _, _, _) = self.auctionState else { return nil } @@ -592,7 +592,7 @@ public extension GiftAuctionContext.State { let levels = bidLevels guard !levels.isEmpty else { - return 1 + return (1, false) } func isWorse(than level: GiftAuctionContext.State.BidLevel) -> Bool { @@ -614,7 +614,7 @@ public extension GiftAuctionContext.State { } } if lowerIndex == -1 { - return 1 + return (1, false) } let lowerPosition = levels[lowerIndex].position @@ -626,14 +626,14 @@ public extension GiftAuctionContext.State { nextPosition = lowerPosition } if nextPosition == lowerPosition + 1 { - return lowerPosition + 1 + return (lowerPosition + 1, false) } else { - return nextPosition + return (lowerPosition, true) } } var place: Int32? { - return self.getPlace(myBid: nil, myBidDate: nil) + return self.getPlace(myBid: nil, myBidDate: nil)?.place } var startDate: Int32 { diff --git a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift index 01c037b5c9..c139bcc6ad 100644 --- a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift @@ -1663,7 +1663,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, case .stars: priceString = strings.Notification_StarsGiftOffer_OfferYou_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat) + " TON" } attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGiftOffer_OfferYou(peerName, priceString, giftTitle)._tuple, body: bodyAttributes, argumentAttributes: attributes) @@ -1673,7 +1673,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, case .stars: priceString = strings.Notification_StarsGiftOffer_Offer_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat) + " TON" } attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGiftOffer_Offer(peerName, priceString, giftTitle)._tuple, body: bodyAttributes, argumentAttributes: attributes) @@ -1696,7 +1696,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, case .stars: priceString = strings.Notification_StarsGiftOffer_ExpiredYou_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat) + " TON" } var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds) @@ -1709,7 +1709,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, case .stars: priceString = strings.Notification_StarsGiftOffer_Expired_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat) + " TON" } let timeString = "[TODO]" @@ -1730,7 +1730,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, case .stars: priceString = strings.Notification_StarsGiftOffer_Rejected_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: dateTimeFormat) + " TON" } var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageGiftOfferBubbleContentNode/Sources/ChatMessageGiftOfferBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageGiftOfferBubbleContentNode/Sources/ChatMessageGiftOfferBubbleContentNode.swift index f50e5b49c3..ea4683c80e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageGiftOfferBubbleContentNode/Sources/ChatMessageGiftOfferBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageGiftOfferBubbleContentNode/Sources/ChatMessageGiftOfferBubbleContentNode.swift @@ -131,7 +131,7 @@ public class ChatMessageGiftOfferBubbleContentNode: ChatMessageBubbleContentNode case .stars: priceString = item.presentationData.strings.Notification_StarGiftOffer_Offer_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: item.presentationData.dateTimeFormat) + " TON" } let peerName = item.message.peers[item.message.id.peerId].flatMap { EnginePeer($0) }?.compactDisplayTitle ?? "" diff --git a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift index 7176042275..946ef20f90 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift @@ -1084,6 +1084,9 @@ final class GiftOptionsScreenComponent: Component { guard let self, let component = self.component, let controller = controller(), let navigationController = controller.navigationController as? NavigationController else { return } + guard component.peerId != component.context.account.peerId else { + return + } let _ = (component.context.engine.data.get( TelegramEngine.EngineData.Item.Peer.Peer(id: component.peerId) ) diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift index 9863ae0d7e..9b1aea12c0 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift @@ -369,17 +369,20 @@ private final class PeerPlaceComponent: Component { let theme: PresentationTheme let color: UIColor let place: Int32? + let placeIsApproximate: Bool let groupingSeparator: String init( theme: PresentationTheme, color: UIColor, place: Int32?, + placeIsApproximate: Bool, groupingSeparator: String ) { self.theme = theme self.color = color self.place = place + self.placeIsApproximate = placeIsApproximate self.groupingSeparator = groupingSeparator } @@ -393,6 +396,9 @@ private final class PeerPlaceComponent: Component { if lhs.place != rhs.place { return false } + if lhs.placeIsApproximate != rhs.placeIsApproximate { + return false + } if lhs.groupingSeparator != rhs.groupingSeparator { return false } @@ -455,7 +461,7 @@ private final class PeerPlaceComponent: Component { var placeString: String if let place = component.place { placeString = presentationStringsFormattedNumber(place, component.groupingSeparator) - if place >= 100 { + if component.placeIsApproximate { placeString = "\(compactNumericCountString(Int(place), decimalSeparator: ".", showDecimalPart: false))+" } } else { @@ -501,6 +507,7 @@ private final class PeerComponent: Component { let groupingSeparator: String let peer: EnginePeer let place: Int32 + let placeIsApproximate: Bool let amount: Int64 let status: Status? let isLast: Bool @@ -512,6 +519,7 @@ private final class PeerComponent: Component { groupingSeparator: String, peer: EnginePeer, place: Int32, + placeIsApproximate: Bool, amount: Int64, status: Status? = nil, isLast: Bool, @@ -522,6 +530,7 @@ private final class PeerComponent: Component { self.groupingSeparator = groupingSeparator self.peer = peer self.place = place + self.placeIsApproximate = placeIsApproximate self.amount = amount self.status = status self.isLast = isLast @@ -541,6 +550,9 @@ private final class PeerComponent: Component { if lhs.place != rhs.place { return false } + if lhs.placeIsApproximate != rhs.placeIsApproximate { + return false + } if lhs.amount != rhs.amount { return false } @@ -623,8 +635,17 @@ private final class PeerComponent: Component { let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } let placeSize = self.place.update( transition: .immediate, - component: AnyComponent(PeerPlaceComponent(theme: component.theme, color: color, place: component.status == .returned ? nil : component.place, groupingSeparator: presentationData.dateTimeFormat.groupingSeparator)), - environment: {}, + component: AnyComponent( + PeerPlaceComponent( + theme: component.theme, + color: color, + place: component.status == .returned ? nil : component.place, + placeIsApproximate: component.placeIsApproximate, + groupingSeparator: presentationData.dateTimeFormat.groupingSeparator + ) + ), + environment: { + }, containerSize: CGSize(width: 40.0, height: 40.0) ) let placeFrame = CGRect(origin: CGPoint(x: 0.0, y: floorToScreenPixels((size.height - placeSize.height) / 2.0)), size: placeSize) @@ -2213,8 +2234,9 @@ private final class GiftAuctionBidScreenComponent: Component { isBiddingUp = false } - place = giftAuctionState.getPlace(myBid: myBidAmount, myBidDate: myBidDate) ?? 1 - + let placeAndIsApproximate = giftAuctionState.getPlace(myBid: myBidAmount, myBidDate: myBidDate) ?? (1, false) + place = placeAndIsApproximate.place + var bidTitle: String var bidTitleColor: UIColor var bidStatus: PeerComponent.Status? @@ -2247,7 +2269,18 @@ private final class GiftAuctionBidScreenComponent: Component { if let peer = self.peersMap[component.context.account.peerId] { myBidTitleComponent = AnyComponent(PeerHeaderComponent(color: bidTitleColor, dateTimeFormat: environment.dateTimeFormat, title: bidTitle, giftTitle: giftTitle, giftNumber: giftNumber)) - myBidComponent = AnyComponent(PeerComponent(context: component.context, theme: environment.theme, groupingSeparator: environment.dateTimeFormat.groupingSeparator, peer: peer, place: place, amount: myBidAmount, status: bidStatus, isLast: true, action: nil)) + myBidComponent = AnyComponent(PeerComponent( + context: component.context, + theme: environment.theme, + groupingSeparator: environment.dateTimeFormat.groupingSeparator, + peer: peer, + place: place, + placeIsApproximate: placeAndIsApproximate.isApproximate, + amount: myBidAmount, + status: bidStatus, + isLast: true, + action: nil + )) } var i: Int32 = 1 @@ -2259,7 +2292,17 @@ private final class GiftAuctionBidScreenComponent: Component { break } } - topBidsComponents.append((peer.id, AnyComponent(PeerComponent(context: component.context, theme: environment.theme, groupingSeparator: environment.dateTimeFormat.groupingSeparator, peer: peer, place: i, amount: bid, isLast: i == topBidders.count, action: nil)))) + topBidsComponents.append((peer.id, AnyComponent(PeerComponent( + context: component.context, + theme: environment.theme, + groupingSeparator: environment.dateTimeFormat.groupingSeparator, + peer: peer, + place: i, + placeIsApproximate: false, + amount: bid, + isLast: i == topBidders.count, + action: nil + )))) i += 1 } diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionWearPreviewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionWearPreviewScreen.swift index 26014f362b..e90791c64f 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionWearPreviewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionWearPreviewScreen.swift @@ -199,7 +199,7 @@ private final class GiftAuctionWearPreviewSheetContent: CombinedComponent { return { context in let environment = context.environment[ViewControllerComponentContainer.Environment.self].value let component = context.component - let theme = environment.theme + let theme = environment.theme.withModalBlocksBackground() let strings = environment.strings let nameDisplayOrder = component.context.sharedContext.currentPresentationData.with { $0 }.nameDisplayOrder let controller = environment.controller diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftOfferAlertController.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftOfferAlertController.swift index 7f9a368d2a..751ea0d6e7 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftOfferAlertController.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftOfferAlertController.swift @@ -485,7 +485,7 @@ public func giftOfferAlertController( case .stars: priceString = strings.Chat_GiftPurchaseOffer_AcceptConfirmation_Text_Stars(Int32(clamping: amount.amount.value)) case .ton: - priceString = "\(amount.amount) TON" + priceString = formatTonAmountText(amount.amount.value, dateTimeFormat: presentationData.dateTimeFormat) + " TON" } let resaleConfiguration = StarsSubscriptionConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index 514b601653..e21689fcac 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -40,6 +40,7 @@ import ChatThemeScreen import ProfileLevelRatingBarComponent import AnimatedTextComponent import InfoParagraphComponent +import ChatMessagePaymentAlertController private final class GiftViewSheetContent: CombinedComponent { typealias EnvironmentType = ViewControllerComponentContainer.Environment @@ -2337,6 +2338,7 @@ private final class GiftViewSheetContent: CombinedComponent { guard let gift = self.subject.arguments?.gift, case let .unique(uniqueGift) = gift, case let .peerId(ownerPeerId) = uniqueGift.owner, let controller = self.getController() else { return } + let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: ownerPeerId)) |> deliverOnMainQueue).start(next: { [weak self] peer in guard let self, let peer else { @@ -2346,13 +2348,41 @@ private final class GiftViewSheetContent: CombinedComponent { guard let self else { return } - self.commitGiftBuyOffer(peer: peer, price: amount, duration: duration) + + let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.SendPaidMessageStars(id: peer.id)) + |> deliverOnMainQueue).start(next: { [weak self, weak controller] sendPaidMessageStars in + guard let self else { + return + } + let action: (Int64?) -> Void = { allowPaidStars in + self.commitGiftBuyOffer(peer: peer, price: amount, duration: duration, allowPaidStars: allowPaidStars) + } + if let sendPaidMessageStars, sendPaidMessageStars.value > 0 { + let alertController = chatMessagePaymentAlertController( + context: nil, + presentationData: presentationData, + updatedPresentationData: nil, + peers: [EngineRenderedPeer(peer: peer)], + count: 1, + amount: sendPaidMessageStars, + totalAmount: nil, + hasCheck: false, + navigationController: controller?.navigationController as? NavigationController, + completion: { _ in + action(sendPaidMessageStars.value) + } + ) + controller?.present(alertController, in: .window(.root)) + } else { + action(nil) + } + }) })) controller.push(buyController) }) } - func commitGiftBuyOffer(peer: EnginePeer, price: CurrencyAmount, duration: Int32) { + func commitGiftBuyOffer(peer: EnginePeer, price: CurrencyAmount, duration: Int32, allowPaidStars: Int64?) { guard let gift = self.subject.arguments?.gift, case let .unique(uniqueGift) = gift, let starsContext = self.context.starsContext, let starsState = starsContext.currentState else { return } @@ -2362,7 +2392,7 @@ private final class GiftViewSheetContent: CombinedComponent { guard let self else { return } - self.upgradeDisposable = (context.engine.payments.sendStarGiftOffer(peerId: peer.id, slug: uniqueGift.slug, amount: price, duration: duration, allowPaidStars: nil) + self.upgradeDisposable = (context.engine.payments.sendStarGiftOffer(peerId: peer.id, slug: uniqueGift.slug, amount: price, duration: duration, allowPaidStars: allowPaidStars) |> deliverOnMainQueue).start(error: { _ in }, completed: { [weak self, weak starsContext] in guard let self else { @@ -2383,11 +2413,15 @@ private final class GiftViewSheetContent: CombinedComponent { guard let self, let controller = self.getController() else { return } + var finalStars = price.amount.value + if let allowPaidStars { + finalStars += allowPaidStars + } let purchaseController = context.sharedContext.makeStarsPurchaseScreen( context: context, starsContext: starsContext, options: options ?? [], - purpose: .starGiftOffer(requiredStars: price.amount.value), + purpose: .starGiftOffer(requiredStars: finalStars), targetPeerId: nil, customTheme: nil, completion: { [weak self, weak starsContext] stars in @@ -2411,7 +2445,7 @@ private final class GiftViewSheetContent: CombinedComponent { self.inProgress = false self.updated() - self.commitGiftBuyOffer(peer: peer, price: price, duration: duration) + self.commitGiftBuyOffer(peer: peer, price: price, duration: duration, allowPaidStars: allowPaidStars) } else { proceed() } @@ -5164,42 +5198,50 @@ final class GiftViewSheetComponent: CombinedComponent { var headerContent: AnyComponent? if let arguments = context.component.subject.arguments, case .unique = arguments.gift, let fromPeerId = arguments.fromPeerId, var fromPeerName = arguments.fromPeerName, arguments.fromPeerId != context.component.context.account.peerId && !(arguments.fromPeerId?.isTelegramNotifications ?? false) { - let dateString = stringForMediumDate(timestamp: arguments.date, strings: environment.strings, dateTimeFormat: environment.dateTimeFormat, withTime: false) - - if fromPeerName.count > 25 { - fromPeerName = "\(fromPeerName.prefix(25))…" + var showSenderInfo = false + if arguments.incoming { + showSenderInfo = true + } else if arguments.peerId == context.component.context.account.peerId { + showSenderInfo = true + } + if showSenderInfo { + let dateString = stringForMediumDate(timestamp: arguments.date, strings: environment.strings, dateTimeFormat: environment.dateTimeFormat, withTime: false) + + if fromPeerName.count > 25 { + fromPeerName = "\(fromPeerName.prefix(25))…" + } + let rawString = environment.strings.Gift_View_SenderInfo(fromPeerName, dateString).string + let attributedString = parseMarkdownIntoAttributedString(rawString, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: Font.regular(13.0), textColor: .white), bold: MarkdownAttributeSet(font: Font.semibold(13.0), textColor: .white), link: MarkdownAttributeSet(font: Font.regular(13.0), textColor: .white), linkAttribute: { _ in return nil })) + + let context = context.component.context + headerContent = AnyComponent( + PlainButtonComponent(content: AnyComponent(HeaderContentComponent(attributedText: attributedString)), action: { + if let controller = controller(), let navigationController = controller.navigationController as? NavigationController { + let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: fromPeerId)) + |> deliverOnMainQueue).start(next: { [weak navigationController] peer in + guard let peer, let navigationController else { + return + } + context.sharedContext.navigateToChatController(NavigateToChatControllerParams( + navigationController: navigationController, + chatController: nil, + context: context, + chatLocation: .peer(peer), + subject: nil, + botStart: nil, + updateTextInputState: nil, + keepStack: .always, + useExisting: true, + purposefulAction: nil, + scrollToEndIfExists: false, + activateMessageSearch: nil, + animated: true + )) + }) + } + }) + ) } - let rawString = environment.strings.Gift_View_SenderInfo(fromPeerName, dateString).string - let attributedString = parseMarkdownIntoAttributedString(rawString, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: Font.regular(13.0), textColor: .white), bold: MarkdownAttributeSet(font: Font.semibold(13.0), textColor: .white), link: MarkdownAttributeSet(font: Font.regular(13.0), textColor: .white), linkAttribute: { _ in return nil })) - - let context = context.component.context - headerContent = AnyComponent( - PlainButtonComponent(content: AnyComponent(HeaderContentComponent(attributedText: attributedString)), action: { - if let controller = controller(), let navigationController = controller.navigationController as? NavigationController { - let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: fromPeerId)) - |> deliverOnMainQueue).start(next: { [weak navigationController] peer in - guard let peer, let navigationController else { - return - } - context.sharedContext.navigateToChatController(NavigateToChatControllerParams( - navigationController: navigationController, - chatController: nil, - context: context, - chatLocation: .peer(peer), - subject: nil, - botStart: nil, - updateTextInputState: nil, - keepStack: .always, - useExisting: true, - purposefulAction: nil, - scrollToEndIfExists: false, - activateMessageSearch: nil, - animated: true - )) - }) - } - }) - ) } let sheet = sheet.update( diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/TableComponent.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/TableComponent.swift index 8d128e4a0a..d696aef50f 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/TableComponent.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/TableComponent.swift @@ -142,6 +142,7 @@ final class TableComponent: CombinedComponent { var innerTotalOffset: CGFloat = 0.0 var hasRowBackground = false var rowBackgroundIsLast = false + var hasStraightSide = false for item in context.component.items { let insets: UIEdgeInsets @@ -194,6 +195,12 @@ final class TableComponent: CombinedComponent { } hasRowBackground = true } + if item.title == nil { + if i != 0 { + rowBackgroundIsLast = true + } + hasStraightSide = true + } i += 1 } @@ -247,8 +254,8 @@ final class TableComponent: CombinedComponent { context.clear(bounds) var offset: CGFloat = 0.0 - if hasRowBackground { - offset = rowBackgroundIsLast ? borderRadius : -borderRadius + if hasStraightSide { + offset = rowBackgroundIsLast ? 0.0 : -borderRadius bounds.origin.y += offset bounds.size.height += borderRadius diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift index dd685d0439..f85773787d 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/ListItems/PeerInfoScreenCallListItem.swift @@ -74,13 +74,15 @@ private final class PeerInfoScreenCallListItemNode: PeerInfoScreenItemNode { let params = ListViewItemLayoutParams(width: width, leftInset: safeInsets.left, rightInset: safeInsets.right, availableHeight: 1000.0) + let verticalInset: CGFloat = 8.0 + let itemNode: ItemListCallListItemNode if let current = self.itemNode { itemNode = current addressItem.updateNode(async: { $0() }, node: { return itemNode }, params: params, previousItem: nil, nextItem: nil, animation: .None, completion: { (layout, apply) in - let nodeFrame = CGRect(origin: CGPoint(), size: CGSize(width: width, height: layout.size.height)) + let nodeFrame = CGRect(origin: CGPoint(x: 0.0, y: verticalInset), size: CGSize(width: width, height: layout.size.height)) itemNode.contentSize = layout.contentSize itemNode.insets = layout.insets @@ -100,9 +102,8 @@ private final class PeerInfoScreenCallListItemNode: PeerInfoScreenItemNode { self.addSubnode(itemNode) } - let verticalInset: CGFloat = 8.0 - let height = itemNode.contentSize.height + verticalInset * 2.0 + let height = itemNode.contentSize.height + verticalInset * 2.0 transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: 0.0, y: verticalInset), size: itemNode.bounds.size)) let highlightNodeOffset: CGFloat = topItem == nil ? 0.0 : UIScreenPixel diff --git a/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift b/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift index 17df881092..b56ee4f8be 100644 --- a/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsWithdrawalScreen/Sources/StarsWithdrawalScreen.swift @@ -1769,8 +1769,15 @@ public final class AmountFieldComponent: Component { guard let component = self.component, let value = component.value else { return } - self.textField.text = "\(value)" - self.placeholderView.view?.isHidden = self.textField.text?.isEmpty ?? false + var text = "" + switch component.currency { + case .stars: + text = "\(value)" + case .ton: + text = "\(formatTonAmountText(value, dateTimeFormat: PresentationDateTimeFormat(timeFormat: component.dateTimeFormat.timeFormat, dateFormat: component.dateTimeFormat.dateFormat, dateSeparator: "", dateSuffix: "", requiresFullYear: false, decimalSeparator: ".", groupingSeparator: ""), maxDecimalPositions: nil))" + } + self.textField.text = text + self.placeholderView.view?.isHidden = !(self.textField.text ?? "").isEmpty } func update(component: AmountFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { @@ -1790,7 +1797,7 @@ public final class AmountFieldComponent: Component { text = "\(formatTonAmountText(value, dateTimeFormat: PresentationDateTimeFormat(timeFormat: component.dateTimeFormat.timeFormat, dateFormat: component.dateTimeFormat.dateFormat, dateSeparator: "", dateSuffix: "", requiresFullYear: false, decimalSeparator: ".", groupingSeparator: ""), maxDecimalPositions: nil))" } self.textField.text = text - self.placeholderView.view?.isHidden = text.isEmpty + self.placeholderView.view?.isHidden = !text.isEmpty } else { self.textField.text = "" } diff --git a/submodules/Utils/DeviceModel/Sources/DeviceModel.swift b/submodules/Utils/DeviceModel/Sources/DeviceModel.swift index c2392f3d9d..2717d827ba 100644 --- a/submodules/Utils/DeviceModel/Sources/DeviceModel.swift +++ b/submodules/Utils/DeviceModel/Sources/DeviceModel.swift @@ -52,7 +52,12 @@ public enum DeviceModel: CaseIterable, Equatable { .iPhone16, .iPhone16Plus, .iPhone16Pro, - .iPhone16ProMax + .iPhone16ProMax, + .iPhone16e, + .iPhone17, + .iPhone17Pro, + .iPhone17ProMax, + .iPhoneAir ] }