mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various improvements
This commit is contained in:
@@ -80,6 +80,7 @@ public struct ChatTextFontAttributes: OptionSet, Hashable, Sequence {
|
||||
public static let italic = ChatTextFontAttributes(rawValue: 1 << 1)
|
||||
public static let monospace = ChatTextFontAttributes(rawValue: 1 << 2)
|
||||
public static let blockQuote = ChatTextFontAttributes(rawValue: 1 << 3)
|
||||
public static let smaller = ChatTextFontAttributes(rawValue: 1 << 4)
|
||||
|
||||
public func makeIterator() -> AnyIterator<ChatTextFontAttributes> {
|
||||
var index = 0
|
||||
|
||||
@@ -59,6 +59,7 @@ private let validTimecodePreviousSet: CharacterSet = {
|
||||
|
||||
public struct ApplicationSpecificEntityType {
|
||||
public static let Timecode: Int32 = 1
|
||||
public static let Button: Int32 = 2
|
||||
}
|
||||
|
||||
private enum CurrentEntityType {
|
||||
|
||||
@@ -253,6 +253,9 @@ public func stringWithAppliedEntities(_ text: String, entities: [MessageTextEnti
|
||||
if let time = parseTimecodeString(text) {
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.Timecode), value: TelegramTimecode(time: time, text: text), range: range)
|
||||
}
|
||||
} else if type == ApplicationSpecificEntityType.Button {
|
||||
string.addAttribute(NSAttributedString.Key(rawValue: TelegramTextAttributes.Button), value: true as NSNumber, range: range)
|
||||
addFontAttributes(range, .smaller)
|
||||
}
|
||||
case let .CustomEmoji(_, fileId):
|
||||
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)
|
||||
@@ -284,6 +287,8 @@ public func stringWithAppliedEntities(_ text: String, entities: [MessageTextEnti
|
||||
font = italicFont
|
||||
} else if fontAttributes == [.monospace] {
|
||||
font = fixedFont
|
||||
} else if fontAttributes == [.smaller] {
|
||||
font = baseFont.withSize(floor(baseFont.pointSize * 0.9))
|
||||
} else {
|
||||
font = baseFont
|
||||
}
|
||||
|
||||
@@ -43,4 +43,5 @@ public struct TelegramTextAttributes {
|
||||
public static let Pre = "TelegramPre"
|
||||
public static let Spoiler = "TelegramSpoiler"
|
||||
public static let Code = "TelegramCode"
|
||||
public static let Button = "TelegramButton"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user