Various fixes

This commit is contained in:
Ilya Laktyushin 2025-05-06 02:09:44 +04:00
parent 79eb359587
commit 3865e253ff
7 changed files with 52 additions and 30 deletions

View File

@ -295,10 +295,6 @@ public func canAddMessageReactions(message: Message) -> Bool {
return true return true
} }
} }
} else if let story = media as? TelegramMediaStory {
if story.isMention {
return false
}
} }
} }
return true return true

View File

@ -559,7 +559,7 @@ public final class GiftItemComponent: Component {
let price: String let price: String
switch component.subject { switch component.subject {
case let .premium(_, priceValue), let .starGift(_, priceValue): case let .premium(_, priceValue), let .starGift(_, priceValue):
if priceValue.containsEmoji { if priceValue.contains("#") {
buttonColor = component.theme.overallDarkAppearance ? UIColor(rgb: 0xffc337) : UIColor(rgb: 0xd3720a) buttonColor = component.theme.overallDarkAppearance ? UIColor(rgb: 0xffc337) : UIColor(rgb: 0xd3720a)
if !component.isSoldOut { if !component.isSoldOut {
starsColor = UIColor(rgb: 0xffbe27) starsColor = UIColor(rgb: 0xffbe27)
@ -867,10 +867,12 @@ public final class GiftItemComponent: Component {
} }
) )
let dateTimeFormat = component.context.sharedContext.currentPresentationData.with { $0 }.dateTimeFormat let dateTimeFormat = component.context.sharedContext.currentPresentationData.with { $0 }.dateTimeFormat
let labelText = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString("#\(presentationStringsFormattedNumber(Int32(resellPrice), dateTimeFormat.groupingSeparator))", attributes: attributes)) let labelText = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString("# \(presentationStringsFormattedNumber(Int32(resellPrice), dateTimeFormat.groupingSeparator))", attributes: attributes))
if let range = labelText.string.range(of: "#") { let range = (labelText.string as NSString).range(of: "#")
labelText.addAttribute(NSAttributedString.Key.font, value: Font.semibold(10.0), range: NSRange(range, in: labelText.string)) if range.location != NSNotFound {
labelText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: true)), range: NSRange(range, in: labelText.string)) labelText.addAttribute(NSAttributedString.Key.font, value: Font.semibold(10.0), range: range)
labelText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: true)), range: range)
labelText.addAttribute(.kern, value: -2.0, range: NSRange(location: range.lowerBound, length: 1))
} }
let resellSize = self.reselLabel.update( let resellSize = self.reselLabel.update(
@ -1048,11 +1050,13 @@ private final class ButtonContentComponent: Component {
self.componentState = state self.componentState = state
let attributedText = NSMutableAttributedString(string: component.text, font: Font.semibold(11.0), textColor: component.color) let attributedText = NSMutableAttributedString(string: component.text, font: Font.semibold(11.0), textColor: component.color)
let range = (attributedText.string as NSString).range(of: "⭐️") let range = (attributedText.string as NSString).range(of: "#")
if range.location != NSNotFound { if range.location != NSNotFound {
attributedText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: component.tinted)), range: range) attributedText.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .stars(tinted: component.tinted)), range: range)
attributedText.addAttribute(.font, value: Font.semibold(15.0), range: range) attributedText.addAttribute(.font, value: Font.semibold(component.tinted ? 14.0 : 15.0), range: range)
attributedText.addAttribute(.baselineOffset, value: 2.0, range: NSRange(location: range.upperBound, length: attributedText.length - range.upperBound)) attributedText.addAttribute(.baselineOffset, value: -3.0, range: range)
attributedText.addAttribute(.baselineOffset, value: 1.5, range: NSRange(location: range.upperBound + 1, length: attributedText.length - range.upperBound - 1))
attributedText.addAttribute(.kern, value: -1.5, range: NSRange(location: range.upperBound, length: 1))
} }
let titleSize = self.title.update( let titleSize = self.title.update(

View File

@ -412,12 +412,12 @@ final class GiftOptionsScreenComponent: Component {
if let availability = gift.availability, availability.remains == 0, let minResaleStars = availability.minResaleStars { if let availability = gift.availability, availability.remains == 0, let minResaleStars = availability.minResaleStars {
let priceString = presentationStringsFormattedNumber(Int32(minResaleStars), environment.dateTimeFormat.groupingSeparator) let priceString = presentationStringsFormattedNumber(Int32(minResaleStars), environment.dateTimeFormat.groupingSeparator)
if let resaleConfiguration = self.resaleConfiguration, minResaleStars == resaleConfiguration.starGiftResaleMaxAmount || availability.resale == 1 { if let resaleConfiguration = self.resaleConfiguration, minResaleStars == resaleConfiguration.starGiftResaleMaxAmount || availability.resale == 1 {
subject = .starGift(gift: gift, price: "⭐️ \(priceString)") subject = .starGift(gift: gift, price: "# \(priceString)")
} else { } else {
subject = .starGift(gift: gift, price: "⭐️ \(priceString)+") subject = .starGift(gift: gift, price: "# \(priceString)+")
} }
} else { } else {
subject = .starGift(gift: gift, price: "⭐️ \(presentationStringsFormattedNumber(Int32(gift.price), environment.dateTimeFormat.groupingSeparator))") subject = .starGift(gift: gift, price: "# \(presentationStringsFormattedNumber(Int32(gift.price), environment.dateTimeFormat.groupingSeparator))")
} }
case let .unique(gift): case let .unique(gift):
subject = .uniqueGift(gift: gift, price: nil) subject = .uniqueGift(gift: gift, price: nil)

View File

@ -230,7 +230,7 @@ final class GiftStoreScreenComponent: Component {
color: ribbonColor color: ribbonColor
) )
let subject: GiftItemComponent.Subject = .uniqueGift(gift: uniqueGift, price: "⭐️\(presentationStringsFormattedNumber(Int32(uniqueGift.resellStars ?? 0), environment.dateTimeFormat.groupingSeparator))") let subject: GiftItemComponent.Subject = .uniqueGift(gift: uniqueGift, price: "# \(presentationStringsFormattedNumber(Int32(uniqueGift.resellStars ?? 0), environment.dateTimeFormat.groupingSeparator))")
let _ = visibleItem.update( let _ = visibleItem.update(
transition: itemTransition, transition: itemTransition,
component: AnyComponent( component: AnyComponent(

View File

@ -309,17 +309,29 @@ private final class GiftViewSheetContent: CombinedComponent {
let context = self.context let context = self.context
let action = { let action = {
if gifts { if gifts {
if let profileController = context.sharedContext.makePeerInfoController( let profileGifts = ProfileGiftsContext(account: context.account, peerId: peer.id)
context: context, let _ = (profileGifts.state
updatedPresentationData: nil, |> filter { state in
peer: peer._asPeer(), if case .ready = state.dataState {
mode: peer.id == context.account.peerId ? .myProfileGifts : .gifts, return true
avatarInitiallyExpanded: false, }
fromChat: false, return false
requestsContext: nil
) {
navigationController.pushViewController(profileController)
} }
|> take(1)
|> deliverOnMainQueue).start(next: { [weak navigationController] _ in
if let profileController = context.sharedContext.makePeerInfoController(
context: context,
updatedPresentationData: nil,
peer: peer._asPeer(),
mode: peer.id == context.account.peerId ? .myProfileGifts : .gifts,
avatarInitiallyExpanded: false,
fromChat: false,
requestsContext: nil
) {
navigationController?.pushViewController(profileController)
}
let _ = profileGifts
})
} else { } else {
context.sharedContext.navigateToChatController(NavigateToChatControllerParams( context.sharedContext.navigateToChatController(NavigateToChatControllerParams(
navigationController: navigationController, navigationController: navigationController,

View File

@ -488,7 +488,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
switch product.gift { switch product.gift {
case let .generic(gift): case let .generic(gift):
subject = .starGift(gift: gift, price: "⭐️ \(gift.price)") subject = .starGift(gift: gift, price: "# \(gift.price)")
peer = product.fromPeer.flatMap { .peer($0) } ?? .anonymous peer = product.fromPeer.flatMap { .peer($0) } ?? .anonymous
if let availability = gift.availability { if let availability = gift.availability {

View File

@ -117,6 +117,8 @@ public final class TabSelectorComponent: Component {
private let selectionView: UIImageView private let selectionView: UIImageView
private var visibleItems: [AnyHashable: VisibleItem] = [:] private var visibleItems: [AnyHashable: VisibleItem] = [:]
private var didInitiallyScroll = false
override init(frame: CGRect) { override init(frame: CGRect) {
self.selectionView = UIImageView() self.selectionView = UIImageView()
@ -238,11 +240,15 @@ public final class TabSelectorComponent: Component {
)), )),
effectAlignment: .center, effectAlignment: .center,
minSize: nil, minSize: nil,
action: { [weak self] in action: { [weak self, weak itemView] in
guard let self, let component = self.component else { guard let self, let component = self.component else {
return return
} }
component.setSelectedId(itemId) component.setSelectedId(itemId)
if let view = itemView?.title.view, allowScroll && self.contentSize.width > self.bounds.width {
self.scrollRectToVisible(view.frame.insetBy(dx: -64.0, dy: 0.0), animated: true)
}
}, },
animateScale: !isLineSelection animateScale: !isLineSelection
)), )),
@ -336,11 +342,15 @@ public final class TabSelectorComponent: Component {
self.selectionView.alpha = 0.0 self.selectionView.alpha = 0.0
} }
self.contentSize = CGSize(width: contentWidth, height: baseHeight + verticalInset * 2.0) let contentSize = CGSize(width: contentWidth, height: baseHeight + verticalInset * 2.0)
if self.contentSize != contentSize {
self.contentSize = contentSize
}
self.disablesInteractiveTransitionGestureRecognizer = contentWidth > availableSize.width self.disablesInteractiveTransitionGestureRecognizer = contentWidth > availableSize.width
if let selectedBackgroundRect, self.bounds.width > 0.0 { if let selectedBackgroundRect, self.bounds.width > 0.0 && !self.didInitiallyScroll {
self.scrollRectToVisible(selectedBackgroundRect.insetBy(dx: -spacing, dy: 0.0), animated: false) self.scrollRectToVisible(selectedBackgroundRect.insetBy(dx: -spacing, dy: 0.0), animated: false)
self.didInitiallyScroll = true
} }
return CGSize(width: min(contentWidth, availableSize.width), height: baseHeight + verticalInset * 2.0) return CGSize(width: min(contentWidth, availableSize.width), height: baseHeight + verticalInset * 2.0)