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
}
}
} else if let story = media as? TelegramMediaStory {
if story.isMention {
return false
}
}
}
return true

View File

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

View File

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

View File

@ -230,7 +230,7 @@ final class GiftStoreScreenComponent: Component {
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(
transition: itemTransition,
component: AnyComponent(

View File

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

View File

@ -488,7 +488,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
switch product.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
if let availability = gift.availability {

View File

@ -117,6 +117,8 @@ public final class TabSelectorComponent: Component {
private let selectionView: UIImageView
private var visibleItems: [AnyHashable: VisibleItem] = [:]
private var didInitiallyScroll = false
override init(frame: CGRect) {
self.selectionView = UIImageView()
@ -238,11 +240,15 @@ public final class TabSelectorComponent: Component {
)),
effectAlignment: .center,
minSize: nil,
action: { [weak self] in
action: { [weak self, weak itemView] in
guard let self, let component = self.component else {
return
}
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
)),
@ -336,11 +342,15 @@ public final class TabSelectorComponent: Component {
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
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.didInitiallyScroll = true
}
return CGSize(width: min(contentWidth, availableSize.width), height: baseHeight + verticalInset * 2.0)