From dd04bdb4e26f9b8c7d141ba641a118c59ccf1793 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 25 Aug 2019 21:46:01 +0300 Subject: [PATCH] Various UI fixes --- .../AvatarNode/Sources/PeerAvatar.swift | 11 +++-- .../Sources/Node/ChatListItem.swift | 6 +-- submodules/Display/Display/TabBarNode.swift | 4 +- submodules/Display/Display/TextNode.swift | 11 +---- .../Sources/SettingsController.swift | 5 +- .../TelegramCore/ChannelMembers.swift | 1 - .../TelegramPeerNotificationSettings.swift | 6 +-- .../TelegramCore/TelegramCore/Themes.swift | 12 ++--- .../AddChannelIcon.imageset/Contents.json | 2 +- ...c_addchannel.pdf => ic_addchannel (2).pdf} | Bin 4747 -> 4745 bytes .../ChatChannelSubscriberInputPanelNode.swift | 2 +- .../TelegramUI/ChatController.swift | 43 +++++++++++++----- .../TelegramUI/ChatInfoTitlePanelNode.swift | 2 +- .../Sources/ChatTextInputAttributes.swift | 6 ++- 14 files changed, 59 insertions(+), 52 deletions(-) rename submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/{ic_addchannel.pdf => ic_addchannel (2).pdf} (71%) diff --git a/submodules/AvatarNode/Sources/PeerAvatar.swift b/submodules/AvatarNode/Sources/PeerAvatar.swift index 1e74de1103..7550b7367f 100644 --- a/submodules/AvatarNode/Sources/PeerAvatar.swift +++ b/submodules/AvatarNode/Sources/PeerAvatar.swift @@ -63,7 +63,7 @@ public func peerAvatarImageData(account: Account, peer: Peer, authorOfMessage: M } } -public func peerAvatarImage(account: Account, peer: Peer, authorOfMessage: MessageReference?, representation: TelegramMediaImageRepresentation?, displayDimensions: CGSize = CGSize(width: 60.0, height: 60.0), emptyColor: UIColor? = nil, synchronousLoad: Bool = false) -> Signal? { +public func peerAvatarImage(account: Account, peer: Peer, authorOfMessage: MessageReference?, representation: TelegramMediaImageRepresentation?, displayDimensions: CGSize = CGSize(width: 60.0, height: 60.0), inset: CGFloat = 0.0, emptyColor: UIColor? = nil, synchronousLoad: Bool = false) -> Signal? { if let imageData = peerAvatarImageData(account: account, peer: peer, authorOfMessage: authorOfMessage, representation: representation, synchronousLoad: synchronousLoad) { return imageData |> mapToSignal { data -> Signal in @@ -74,21 +74,22 @@ public func peerAvatarImage(account: Account, peer: Peer, authorOfMessage: Messa return .single(generateImage(displayDimensions, contextGenerator: { size, context -> Void in if let data = data { if let imageSource = CGImageSourceCreateWithData(data as CFData, nil), let dataImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil) { + context.clear(CGRect(origin: CGPoint(), size: displayDimensions)) context.setBlendMode(.copy) - context.draw(dataImage, in: CGRect(origin: CGPoint(), size: displayDimensions)) + context.draw(dataImage, in: CGRect(origin: CGPoint(), size: displayDimensions).insetBy(dx: inset, dy: inset)) context.setBlendMode(.destinationOut) - context.draw(roundCorners.cgImage!, in: CGRect(origin: CGPoint(), size: displayDimensions)) + context.draw(roundCorners.cgImage!, in: CGRect(origin: CGPoint(), size: displayDimensions).insetBy(dx: inset, dy: inset)) } else { if let emptyColor = emptyColor { context.clear(CGRect(origin: CGPoint(), size: displayDimensions)) context.setFillColor(emptyColor.cgColor) - context.fillEllipse(in: CGRect(origin: CGPoint(), size: displayDimensions)) + context.fillEllipse(in: CGRect(origin: CGPoint(), size: displayDimensions).insetBy(dx: inset, dy: inset)) } } } else if let emptyColor = emptyColor { context.clear(CGRect(origin: CGPoint(), size: displayDimensions)) context.setFillColor(emptyColor.cgColor) - context.fillEllipse(in: CGRect(origin: CGPoint(), size: displayDimensions)) + context.fillEllipse(in: CGRect(origin: CGPoint(), size: displayDimensions).insetBy(dx: inset, dy: inset)) } })) } diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 129717df82..e0fcb1d545 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -915,9 +915,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if let mutedCount = unreadCount.mutedCount, mutedCount > 0 { let mutedUnreadCountText = compactNumericCountString(Int(mutedCount), decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator) - currentMentionBadgeImage = PresentationResourcesChatList.badgeBackgroundInactive(item.presentationData.theme) - mentionBadgeContent = .text(NSAttributedString(string: mutedUnreadCountText, font: badgeFont, textColor: theme.unreadBadgeInactiveTextColor)) } } @@ -1331,8 +1329,8 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { if let currentMutedIconImage = currentMutedIconImage { strongSelf.mutedIconNode.image = currentMutedIconImage strongSelf.mutedIconNode.isHidden = false - transition.updateFrame(node: strongSelf.mutedIconNode, frame: CGRect(origin: CGPoint(x: nextTitleIconOrigin, y: contentRect.origin.y + 5.0), size: currentMutedIconImage.size)) - nextTitleIconOrigin += currentMutedIconImage.size.width + 3.0 + transition.updateFrame(node: strongSelf.mutedIconNode, frame: CGRect(origin: CGPoint(x: nextTitleIconOrigin - 4.0, y: contentRect.origin.y - 2.0), size: currentMutedIconImage.size)) + nextTitleIconOrigin += currentMutedIconImage.size.width + 1.0 } else { strongSelf.mutedIconNode.image = nil strongSelf.mutedIconNode.isHidden = true diff --git a/submodules/Display/Display/TabBarNode.swift b/submodules/Display/Display/TabBarNode.swift index deca7413c1..99f37b694f 100644 --- a/submodules/Display/Display/TabBarNode.swift +++ b/submodules/Display/Display/TabBarNode.swift @@ -434,10 +434,10 @@ class TabBarNode: ASDisplayNode { let backgroundSize = CGSize(width: hasSingleLetterValue ? 18.0 : max(18.0, badgeSize.width + 10.0 + 1.0), height: 18.0) let backgroundFrame: CGRect if horizontal { - backgroundFrame = CGRect(origin: CGPoint(x: originX + 8.0, y: 2.0), size: backgroundSize) + backgroundFrame = CGRect(origin: CGPoint(x: originX + 10.0, y: 2.0), size: backgroundSize) } else { let contentWidth = node.contentWidth ?? node.frame.width - backgroundFrame = CGRect(origin: CGPoint(x: floor(originX + node.frame.width / 2.0) - 1.0 + contentWidth - backgroundSize.width - 1.0, y: 2.0), size: backgroundSize) + backgroundFrame = CGRect(origin: CGPoint(x: floor(originX + node.frame.width / 2.0) + contentWidth - backgroundSize.width - 5.0, y: 2.0), size: backgroundSize) } transition.updateFrame(node: container.badgeContainerNode, frame: backgroundFrame) container.badgeBackgroundNode.frame = CGRect(origin: CGPoint(), size: backgroundFrame.size) diff --git a/submodules/Display/Display/TextNode.swift b/submodules/Display/Display/TextNode.swift index 2b5fa41930..77b59c9d30 100644 --- a/submodules/Display/Display/TextNode.swift +++ b/submodules/Display/Display/TextNode.swift @@ -60,9 +60,9 @@ private func displayLineFrame(frame: CGRect, isRTL: Bool, boundingRect: CGRect, return frame } var lineFrame = frame - let intersectionFrame = lineFrame.offsetBy(dx: 0.0, dy: -lineFrame.height) if isRTL { lineFrame.origin.x = max(0.0, floor(boundingRect.width - lineFrame.size.width)) + let intersectionFrame = lineFrame.offsetBy(dx: 0.0, dy: -lineFrame.height / 4.5) if let topRight = cutout?.topRight { let topRightRect = CGRect(origin: CGPoint(x: boundingRect.width - topRight.width, y: 0.0), size: topRight) if intersectionFrame.intersects(topRightRect) { @@ -225,9 +225,6 @@ public final class TextNodeLayout: NSObject { case .center: lineFrame.origin.x = floor((self.size.width - lineFrame.size.width) / 2.0) case .natural: - if line.isRTL { - lineFrame.origin.x = self.size.width - lineFrame.size.width - } lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: self.size), cutout: self.cutout) default: break @@ -296,9 +293,6 @@ public final class TextNodeLayout: NSObject { case .center: lineFrame.origin.x = floor((self.size.width - lineFrame.size.width) / 2.0) case .natural: - if line.isRTL { - lineFrame.origin.x = self.size.width - lineFrame.size.width - } lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: self.size), cutout: self.cutout) default: break @@ -374,9 +368,6 @@ public final class TextNodeLayout: NSObject { case .center: lineFrame.origin.x = floor((self.size.width - lineFrame.size.width) / 2.0) case .natural: - if line.isRTL { - lineFrame.origin.x = floor(self.size.width - lineFrame.size.width) - } lineFrame = displayLineFrame(frame: lineFrame, isRTL: line.isRTL, boundingRect: CGRect(origin: CGPoint(), size: self.size), cutout: self.cutout) default: break diff --git a/submodules/SettingsUI/Sources/SettingsController.swift b/submodules/SettingsUI/Sources/SettingsController.swift index d7f09ae637..2c17680d08 100644 --- a/submodules/SettingsUI/Sources/SettingsController.swift +++ b/submodules/SettingsUI/Sources/SettingsController.swift @@ -1220,7 +1220,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM |> distinctUntilChanged(isEqual: { $0?.0 === $1?.0 && arePeersEqual($0?.1, $1?.1) }) |> mapToSignal { primary -> Signal in if let primary = primary { - if let signal = peerAvatarImage(account: primary.0, peer: primary.1, authorOfMessage: nil, representation: primary.1.profileImageRepresentations.first, displayDimensions: CGSize(width: 25.0, height: 25.0), emptyColor: nil, synchronousLoad: false) { + if let signal = peerAvatarImage(account: primary.0, peer: primary.1, authorOfMessage: nil, representation: primary.1.profileImageRepresentations.first, displayDimensions: CGSize(width: 31.0, height: 31.0), inset: 3.0, emptyColor: nil, synchronousLoad: false) { return signal |> map { image -> UIImage? in return image.flatMap { image -> UIImage in @@ -1229,9 +1229,10 @@ public func settingsController(context: AccountContext, accountManager: AccountM } } else { return Signal { subscriber in - let size = CGSize(width: 25.0, height: 25.0) + let size = CGSize(width: 31.0, height: 31.0) let image = generateImage(size, rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) + context.translateBy(x: 3.0, y: 3.0) drawPeerAvatarLetters(context: context, size: size, font: avatarFont, letters: primary.1.displayLetters, accountPeerId: primary.1.id, peerId: primary.1.id) })?.withRenderingMode(.alwaysOriginal) subscriber.putNext(image) diff --git a/submodules/TelegramCore/TelegramCore/ChannelMembers.swift b/submodules/TelegramCore/TelegramCore/ChannelMembers.swift index 858abfb1ba..2cc891484f 100644 --- a/submodules/TelegramCore/TelegramCore/ChannelMembers.swift +++ b/submodules/TelegramCore/TelegramCore/ChannelMembers.swift @@ -92,7 +92,6 @@ public func channelMembers(postbox: Postbox, network: Network, accountPeerId: Pe if let peer = peers[participant.peerId] { items.append(RenderedChannelParticipant(participant: participant, peer: peer, peers: peers, presences: presences)) } - } case .channelParticipantsNotModified: return nil diff --git a/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift b/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift index aa6e6fa00a..b61e6a3346 100644 --- a/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift +++ b/submodules/TelegramCore/TelegramCore/TelegramPeerNotificationSettings.swift @@ -286,11 +286,7 @@ extension PeerMessageSound { case .default: return nil case let .bundledModern(id): - if id == 0 { - return "default" - } else { - return "\(id + 100)" - } + return "\(id + 100)" case let .bundledClassic(id): return "\(id + 2)" } diff --git a/submodules/TelegramCore/TelegramCore/Themes.swift b/submodules/TelegramCore/TelegramCore/Themes.swift index bfbc5c46fb..d41b0a4918 100644 --- a/submodules/TelegramCore/TelegramCore/Themes.swift +++ b/submodules/TelegramCore/TelegramCore/Themes.swift @@ -1,12 +1,12 @@ import Foundation #if os(macOS) -import PostboxMac -import SwiftSignalKitMac -import TelegramApiMac + import PostboxMac + import SwiftSignalKitMac + import TelegramApiMac #else -import Postbox -import SwiftSignalKit -import TelegramApi + import Postbox + import SwiftSignalKit + import TelegramApi #endif final class CachedThemesConfiguration: PostboxCoding { diff --git a/submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/Contents.json index 8033bd89cd..44f25d3edd 100644 --- a/submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/Contents.json +++ b/submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "ic_addchannel.pdf" + "filename" : "ic_addchannel (2).pdf" } ], "info" : { diff --git a/submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/ic_addchannel.pdf b/submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/ic_addchannel (2).pdf similarity index 71% rename from submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/ic_addchannel.pdf rename to submodules/TelegramUI/Images.xcassets/Item List/AddChannelIcon.imageset/ic_addchannel (2).pdf index 0eb106737a906a74754ee7d31d74c31073932ba7..aed51ac2c7e85a5ec0d4a1442f203f56990406be 100644 GIT binary patch delta 1297 zcmeBH?Npr*SU=4-PgYT&<$E!go`93H^I;EZt+c>t@k{HIcfuGE#qqJkRg- zdFHTQ*5TB>qebfb88xlVZ=dkt6*ylTxkRq}PT$3uZ!6-fwkkT+vp>BWH2d_al9ca9 z47Y@N_ILlPQ_EMqb!Ye8+ibU92ind&{&K}L>(4u^cR7@$MI_61{_ec(VDD)9U32Mq z79mH|^-9-XoL+cMf4%JL^SM{UkFWERDV2BhdsHaY?DD8keV>BPEUtauy6#6`6mGHF zzHGVdgbQCLz6yMOE4MbNhyuKN)5{OICM*Jg00e7SmY(bH6Cku2H6>I$2= zX3k@u8JV+cr}(>ai+R0a$B)K^2lh-Wv|RgJIw?pxDIn-j&y>*8zZsj%4*vO~bFKb0 z!@?^4uZwct3iF+axN?M@rN?KroOb$UkCEN%ri4@QNvXxtQ0R`|5=ZfWy20l7GrsM28H zJi%Q@EKfgEfBiSzWzKK0<;Q~juD{=GC~}-}(avA-R?m1vZg7h$M{h2ZJHnxSfbSM_ z?d5v^a-VngWlSph`3^tXi}q}Ef4b=G#rJ`MdQEW;o+sq_uub4(oY*EGDYEBXeRcNn z>DfAo^Gvi4>4?wMYz%aXzUiWSCZTer5L4SR9)^_3r>92jjFhin|F!e=tEU|6TQ>G> z=)1eEr(^FlotO!46||2{vzh$9ap{dXiys@OAKaqz;)6fG9#?(1bRNsfj!cQ}qXz^G zc^H5D3S1W9+x_Tg?~1E)58q$7rtnzD%j5^;9U6xXbPaRO-al@h-SuDMx3-U%%p&70 zdVS1oGFuN%zrC%%-onUw8B2r_PozYAsGeR&$YZ|4=?ObzMDMDG-Mx2b%Y;{jXJU@} z_JwFSiO2fh=&(rt9+Q7B=*qr@8^68g+9Pp4j{g*w=BlCa9>-v~_q0dw6 zmae~l?`Ou|Wqxd(e)ZznqsIkF|aU0S7%~q3>D);I1}gx!^!Ui?c$S64a^gb zQvmEGnreN=@T3F*dT` LQdM>JcjE#8wIVJE delta 1299 zcmeBF?N*%-SU)weOV*Od^?$bLy#p0G(c9jlJKIKA=0?{>>cv0trBOs`0 zStd%k*lZu`7EbP z_S7#A*BHzSzG-vl)*Z78^Hx_?*GXKx{rT(*rknFtN?`J%ja zcl32WN!43dZ#k6ww0joTrT607vih|xJyqeM6C!iAzPOl?taT)>@8Ts6ckg%q_Fd{% znV07ubm5`pdYh=PO^MqRSL9Zn)nEC$faTGB8HT+T!T0#L_g=mrR4(R}9W3zqb=1y? zXqTxuuD4a{>-BZ{V-@ciu%ADF_RQWFA^qXg7Bo%TeQw``sBM-d7DjF>Lit0kt? z2d;eUpR)Cnf>F`cw8us4Zn+ztztWCdV|v9l==ZvZ*FsJxT%Gmt)P^hbN<%+KB*ZSc z%AI4Rya8*dkrum|ivkTA1xR~7?b8gl0m`;B3*@*3I?YrjP=dVrp zy7R@mN3(YFonokWESLCQDBu6)gP*9MUt<3%R6xdRL0X zrA3=oX>{3K6%eI%Q+h@{H^_ivT=%d|v-0Bn3YB#LEAo{X6;pGRB*%qeTxlUW}*MkpRz(ds0|aj^gE@wo14 z_qrwZm+Qr?b^iL)|NngQ{M~e|kKcbz{CA5f_vxC2@tun|S5COzJI6o%y5$`+#(m54 z|1+DjUf}I^#aYqH=s;j>n7XTkaMrQy3 diff --git a/submodules/TelegramUI/TelegramUI/ChatChannelSubscriberInputPanelNode.swift b/submodules/TelegramUI/TelegramUI/ChatChannelSubscriberInputPanelNode.swift index 9ab304082f..8fff6f82f6 100644 --- a/submodules/TelegramUI/TelegramUI/ChatChannelSubscriberInputPanelNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatChannelSubscriberInputPanelNode.swift @@ -198,7 +198,7 @@ final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode { guard let strongSelf = self, let interfaceState = strongSelf.presentationInterfaceState, let image = strongSelf.badgeBackground.image else { return } - let text = "\(value ?? 0)" + let text = compactNumericCountString(value ?? 0, decimalSeparator: interfaceState.dateTimeFormat.decimalSeparator) strongSelf.badgeText.attributedText = NSAttributedString(string: text, font: badgeFont, textColor: interfaceState.theme.chatList.unreadBadgeActiveTextColor) let textSize = strongSelf.badgeText.updateLayout(CGSize(width: 100.0, height: 100.0)) diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index ab65a9a81f..3171b30f15 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -1653,24 +1653,35 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G var hasScheduledMessages: Signal = .single(false) if peerId.namespace == Namespaces.Peer.CloudChannel { - let recentOnlineSignal: Signal = context.account.viewTracker.peerView(peerId) - |> map { view -> Bool in - if let cachedData = view.cachedData as? CachedChannelData, let memberCount = cachedData.participantsSummary.memberCount, memberCount > 50 { - return true + let recentOnlineSignal: Signal = peerView.get() + |> map { view -> Bool? in + if let cachedData = view.cachedData as? CachedChannelData, let peer = peerViewMainPeer(view) as? TelegramChannel { + if case .broadcast = peer.info { + return nil + } else if let memberCount = cachedData.participantsSummary.memberCount, memberCount > 50 { + return true + } else { + return false + } } else { return false } } |> distinctUntilChanged - |> mapToSignal { isLarge -> Signal in - if isLarge { - return context.peerChannelMemberCategoriesContextsManager.recentOnline(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) + |> mapToSignal { isLarge -> Signal in + if let isLarge = isLarge { + if isLarge { + return context.peerChannelMemberCategoriesContextsManager.recentOnline(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) + |> map(Optional.init) + } else { + return context.peerChannelMemberCategoriesContextsManager.recentOnlineSmall(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) + |> map(Optional.init) + } } else { - return context.peerChannelMemberCategoriesContextsManager.recentOnlineSmall(postbox: context.account.postbox, network: context.account.network, accountPeerId: context.account.peerId, peerId: peerId) + return .single(nil) } } onlineMemberCount = recentOnlineSignal - |> map(Optional.init) self.reportIrrelvantGeoNoticePromise.set(context.account.postbox.transaction { transaction -> Bool? in if let _ = transaction.getNoticeEntry(key: ApplicationSpecificNotice.irrelevantPeerGeoReportKey(peerId: peerId)) as? ApplicationSpecificBoolNotice { @@ -1684,9 +1695,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if !isScheduledMessages && peerId.namespace != Namespaces.Peer.SecretChat { - hasScheduledMessages = context.account.viewTracker.scheduledMessagesViewForLocation(chatLocation) - |> map { view, _, _ in - return !view.entries.isEmpty + hasScheduledMessages = peerView.get() + |> take(1) + |> mapToSignal { view -> Signal in + if let peer = peerViewMainPeer(view) as? TelegramChannel, !peer.hasPermission(.sendMessages) { + return .single(false) + } else { + return context.account.viewTracker.scheduledMessagesViewForLocation(chatLocation) + |> map { view, _, _ in + return !view.entries.isEmpty + } + } } } diff --git a/submodules/TelegramUI/TelegramUI/ChatInfoTitlePanelNode.swift b/submodules/TelegramUI/TelegramUI/ChatInfoTitlePanelNode.swift index 047c31cfd3..2307d269dd 100644 --- a/submodules/TelegramUI/TelegramUI/ChatInfoTitlePanelNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatInfoTitlePanelNode.swift @@ -99,7 +99,7 @@ private func peerButtons(_ peer: Peer, interfaceState: ChatPresentationInterface } } -private let buttonFont = Font.regular(10.0) +private let buttonFont = Font.medium(10.0) private final class ChatInfoTitlePanelButtonNode: HighlightableButtonNode { override init() { diff --git a/submodules/TextFormat/Sources/ChatTextInputAttributes.swift b/submodules/TextFormat/Sources/ChatTextInputAttributes.swift index db52c8c553..82cc311a45 100644 --- a/submodules/TextFormat/Sources/ChatTextInputAttributes.swift +++ b/submodules/TextFormat/Sources/ChatTextInputAttributes.swift @@ -510,11 +510,13 @@ private func trimRangesForChatInputText(_ text: NSAttributedString) -> (Int, Int var lower = 0 var upper = 0 + let trimmedCharacters: [UnicodeScalar] = [" ", "\t", "\n", "\u{200C}"] + let nsString: NSString = text.string as NSString for i in 0 ..< nsString.length { if let c = UnicodeScalar(nsString.character(at: i)) { - if c == " " as UnicodeScalar || c == "\t" as UnicodeScalar || c == "\n" as UnicodeScalar { + if trimmedCharacters.contains(c) { lower += 1 } else { break @@ -527,7 +529,7 @@ private func trimRangesForChatInputText(_ text: NSAttributedString) -> (Int, Int if lower != nsString.length { for i in (lower ..< nsString.length).reversed() { if let c = UnicodeScalar(nsString.character(at: i)) { - if c == " " as UnicodeScalar || c == "\t" as UnicodeScalar || c == "\n" as UnicodeScalar { + if trimmedCharacters.contains(c) { upper += 1 } else { break