mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various fixes
This commit is contained in:
@@ -1108,21 +1108,27 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
let format = senderName != nil ? strings.Gift_Unique_OriginalInfoSenderWithText(senderName!, recipientName, dateString, "") : strings.Gift_Unique_OriginalInfoWithText(recipientName, dateString, "")
|
||||
let string = NSMutableAttributedString(string: format.string, font: tableFont, textColor: tableTextColor)
|
||||
string.replaceCharacters(in: format.ranges[format.ranges.count - 1].range, with: attributedText)
|
||||
if let _ = senderName {
|
||||
string.addAttribute(NSAttributedString.Key.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(NSAttributedString.Key.foregroundColor, value: tableLinkColor, range: format.ranges[1].range)
|
||||
if let senderPeerId {
|
||||
string.addAttribute(.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention), value: TelegramPeerMention(peerId: senderPeerId, mention: ""), range: format.ranges[0].range)
|
||||
string.addAttribute(.foregroundColor, value: tableLinkColor, range: format.ranges[1].range)
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention), value: TelegramPeerMention(peerId: recipientPeerId, mention: ""), range: format.ranges[1].range)
|
||||
} else {
|
||||
string.addAttribute(NSAttributedString.Key.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention), value: TelegramPeerMention(peerId: recipientPeerId, mention: ""), range: format.ranges[0].range)
|
||||
}
|
||||
value = string
|
||||
} else {
|
||||
let format = senderName != nil ? strings.Gift_Unique_OriginalInfoSender(senderName!, recipientName, dateString) : strings.Gift_Unique_OriginalInfo(recipientName, dateString)
|
||||
let string = NSMutableAttributedString(string: format.string, font: tableFont, textColor: tableTextColor)
|
||||
if let _ = senderName {
|
||||
string.addAttribute(NSAttributedString.Key.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(NSAttributedString.Key.foregroundColor, value: tableLinkColor, range: format.ranges[1].range)
|
||||
if let senderPeerId {
|
||||
string.addAttribute(.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention), value: TelegramPeerMention(peerId: senderPeerId, mention: ""), range: format.ranges[0].range)
|
||||
string.addAttribute(.foregroundColor, value: tableLinkColor, range: format.ranges[1].range)
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention), value: TelegramPeerMention(peerId: recipientPeerId, mention: ""), range: format.ranges[1].range)
|
||||
} else {
|
||||
string.addAttribute(NSAttributedString.Key.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(.foregroundColor, value: tableLinkColor, range: format.ranges[0].range)
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention), value: TelegramPeerMention(peerId: recipientPeerId, mention: ""), range: format.ranges[0].range)
|
||||
}
|
||||
|
||||
value = string
|
||||
@@ -1146,7 +1152,26 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
horizontalAlignment: .center,
|
||||
maximumNumberOfLines: 0,
|
||||
insets: id == "originalInfo" ? UIEdgeInsets(top: 2.0, left: 0.0, bottom: 2.0, right: 0.0) : .zero,
|
||||
handleSpoilers: true
|
||||
highlightColor: tableLinkColor.withAlphaComponent(0.1),
|
||||
handleSpoilers: true,
|
||||
highlightAction: { attributes in
|
||||
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] {
|
||||
return NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
},
|
||||
tapAction: { [weak state] attributes, _ in
|
||||
guard let state else {
|
||||
return
|
||||
}
|
||||
if let mention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention, let peer = state.peerMap[mention.peerId] {
|
||||
component.openPeer(peer)
|
||||
Queue.mainQueue().after(1.0, {
|
||||
component.cancel(false)
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -1178,11 +1203,13 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
}
|
||||
}
|
||||
|
||||
let issuedString = presentationStringsFormattedNumber(uniqueGift.availability.issued, environment.dateTimeFormat.groupingSeparator)
|
||||
let totalString = presentationStringsFormattedNumber(uniqueGift.availability.total, environment.dateTimeFormat.groupingSeparator)
|
||||
tableItems.insert(.init(
|
||||
id: "availability",
|
||||
title: strings.Gift_Unique_Availability,
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: strings.Gift_Unique_Issued("\(uniqueGift.availability.issued)/\(uniqueGift.availability.total)").string, font: tableFont, textColor: tableTextColor)))
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: strings.Gift_Unique_Issued("\(issuedString)/\(totalString)").string, font: tableFont, textColor: tableTextColor)))
|
||||
)
|
||||
), at: hasOriginalInfo ? tableItems.count - 1 : tableItems.count)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user