diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 8ce095bd44..59a6c6c2bc 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -10143,6 +10143,7 @@ Sorry for the inconvenience."; "NameColor.TooltipPremium.Account" = "Subscribe to [Telegram Premium]() to choose a custom color for your name."; "NameColor.BackgroundEmoji.Title" = "ADD ICONS TO REPLIES"; +"NameColor.BackgroundEmoji.Remove" = "REMOVE ICON"; "Chat.ErrorQuoteOutdatedTitle" = "Quote Outdated"; "Chat.ErrorQuoteOutdatedText" = "**%@** updated the message you are quoting. Edit your quote to make it up-to-date."; diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 0a228fcdb6..9639af7f89 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -1262,8 +1262,10 @@ public class PeerNameColors: Equatable { public let darkColors: [Int32: Colors] public let displayOrder: [Int32] - public func get(_ color: PeerNameColor) -> Colors { - if let colors = self.colors[color.rawValue] { + public func get(_ color: PeerNameColor, dark: Bool = false) -> Colors { + if dark, let colors = self.darkColors[color.rawValue] { + return colors + } else if let colors = self.colors[color.rawValue] { return colors } else { return PeerNameColors.defaultSingleColors[5]! diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift index 515e760b58..d3c49d26c7 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageAttachedContentNode/Sources/ChatMessageAttachedContentNode.swift @@ -177,7 +177,7 @@ public final class ChatMessageAttachedContentNode: ASDisplayNode { let messageTheme = incoming ? presentationData.theme.theme.chat.message.incoming : presentationData.theme.theme.chat.message.outgoing let author = message.author - let nameColors = author?.nameColor.flatMap { context.peerNameColors.get($0) } + let nameColors = author?.nameColor.flatMap { context.peerNameColors.get($0, dark: presentationData.theme.theme.overallDarkAppearance) } let mainColor: UIColor var secondaryColor: UIColor? diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 6662e142bb..e93526f73e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -1882,11 +1882,11 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI if let peer = firstMessage.peers[firstMessage.id.peerId] as? TelegramChannel, case .broadcast = peer.info, item.content.firstMessage.adAttribute == nil { let peer = (peer as Peer) - let nameColors = peer.nameColor.flatMap { item.context.peerNameColors.get($0) } + let nameColors = peer.nameColor.flatMap { item.context.peerNameColors.get($0, dark: item.presentationData.theme.theme.overallDarkAppearance) } authorNameColor = nameColors?.main } else if let effectiveAuthor = effectiveAuthor { let nameColor = effectiveAuthor.nameColor ?? .blue - let nameColors = item.context.peerNameColors.get(nameColor) + let nameColors = item.context.peerNameColors.get(nameColor, dark: item.presentationData.theme.theme.overallDarkAppearance) let color: UIColor if incoming { color = nameColors.main @@ -1901,13 +1901,13 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI authorNameString = EnginePeer(peer).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) let peer = (peer as Peer) - let nameColors = peer.nameColor.flatMap { item.context.peerNameColors.get($0) } + let nameColors = peer.nameColor.flatMap { item.context.peerNameColors.get($0, dark: item.presentationData.theme.theme.overallDarkAppearance) } authorNameColor = nameColors?.main } else if let effectiveAuthor = effectiveAuthor { authorNameString = EnginePeer(effectiveAuthor).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) let nameColor = effectiveAuthor.nameColor ?? .blue - let nameColors = item.context.peerNameColors.get(nameColor) + let nameColors = item.context.peerNameColors.get(nameColor, dark: item.presentationData.theme.theme.overallDarkAppearance) let color: UIColor if incoming { color = nameColors.main diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift index 0359b0d89b..9ff63e0b98 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageForwardInfoNode/Sources/ChatMessageForwardInfoNode.swift @@ -165,7 +165,7 @@ public class ChatMessageForwardInfoNode: ASDisplayNode { } else { if incoming { if let nameColor = peer?.nameColor { - titleColor = context.peerNameColors.get(nameColor).main + titleColor = context.peerNameColors.get(nameColor, dark: presentationData.theme.theme.overallDarkAppearance).main } else { titleColor = presentationData.theme.theme.chat.message.incoming.accentTextColor } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode/Sources/ChatMessageReplyInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode/Sources/ChatMessageReplyInfoNode.swift index 01b21089e9..1645b42d4d 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode/Sources/ChatMessageReplyInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode/Sources/ChatMessageReplyInfoNode.swift @@ -201,7 +201,7 @@ public class ChatMessageReplyInfoNode: ASDisplayNode { let author = arguments.message?.effectiveAuthor - let colors = author?.nameColor.flatMap { arguments.context.peerNameColors.get($0) } + let colors = author?.nameColor.flatMap { arguments.context.peerNameColors.get($0, dark: arguments.presentationData.theme.theme.overallDarkAppearance) } authorNameColor = colors?.main dashSecondaryColor = colors?.secondary dashTertiaryColor = colors?.tertiary diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift index b8680f093a..61d07dac19 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageTextBubbleContentNode/Sources/ChatMessageTextBubbleContentNode.swift @@ -385,7 +385,7 @@ public class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { var secondaryColor: UIColor? = nil var tertiaryColor: UIColor? = nil - let nameColors = author?.nameColor.flatMap { item.context.peerNameColors.get($0) } + let nameColors = author?.nameColor.flatMap { item.context.peerNameColors.get($0, dark: item.presentationData.theme.theme.overallDarkAppearance) } if !incoming { mainColor = messageTheme.accentTextColor if let _ = nameColors?.secondary { diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorItem.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorItem.swift index e573d9f435..edbd18161b 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorItem.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorItem.swift @@ -138,14 +138,14 @@ private func generateFillImage(nameColor: PeerNameColors.Colors) -> UIImage? { context.setFillColor(secondColor.cgColor) context.fill(circleBounds) - context.move(to: .zero) - context.addLine(to: CGPoint(x: size.width, y: 0.0)) - context.addLine(to: CGPoint(x: 0.0, y: size.height)) - context.closePath() - context.setFillColor(nameColor.main.cgColor) - context.fillPath() - if let thirdColor = nameColor.tertiary { + context.move(to: CGPoint(x: size.width, y: 0.0)) + context.addLine(to: CGPoint(x: size.width, y: size.height)) + context.addLine(to: CGPoint(x: 0.0, y: size.height)) + context.closePath() + context.setFillColor(nameColor.main.cgColor) + context.fillPath() + context.setFillColor(thirdColor.cgColor) context.translateBy(x: size.width / 2.0, y: size.height / 2.0) context.rotate(by: .pi / 4.0) @@ -153,6 +153,13 @@ private func generateFillImage(nameColor: PeerNameColors.Colors) -> UIImage? { let path = UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: -9.0, y: -9.0), size: CGSize(width: 18.0, height: 18.0)), cornerRadius: 4.0) context.addPath(path.cgPath) context.fillPath() + } else { + context.move(to: .zero) + context.addLine(to: CGPoint(x: size.width, y: 0.0)) + context.addLine(to: CGPoint(x: 0.0, y: size.height)) + context.closePath() + context.setFillColor(nameColor.main.cgColor) + context.fillPath() } } else { context.setFillColor(nameColor.main.cgColor) diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift index be6b4473be..7b046d4972 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/PeerNameColorScreen.swift @@ -49,7 +49,7 @@ private enum PeerNameColorScreenEntry: ItemListNodeEntry { case colorMessage(wallpaper: TelegramWallpaper, fontSize: PresentationFontSize, bubbleCorners: PresentationChatBubbleCorners, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, items: [PeerNameColorChatPreviewItem.MessageItem]) case colorPicker(colors: PeerNameColors, currentColor: PeerNameColor) case colorDescription(String) - case backgroundEmojiHeader(String) + case backgroundEmojiHeader(String, String?) case backgroundEmoji(EmojiPagerContentComponent, UIColor) var section: ItemListSectionId { @@ -121,8 +121,8 @@ private enum PeerNameColorScreenEntry: ItemListNodeEntry { } else { return false } - case let .backgroundEmojiHeader(text): - if case .backgroundEmojiHeader(text) = rhs { + case let .backgroundEmojiHeader(text, action): + if case .backgroundEmojiHeader(text, action) = rhs { return true } else { return false @@ -170,8 +170,10 @@ private enum PeerNameColorScreenEntry: ItemListNodeEntry { ) case let .colorDescription(text): return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) - case let .backgroundEmojiHeader(text): - return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) + case let .backgroundEmojiHeader(text, action): + return ItemListSectionHeaderItem(presentationData: presentationData, text: text, actionText: action, action: action != nil ? { + arguments.updateBackgroundEmojiId(0) + } : nil, sectionId: self.section) case let .backgroundEmoji(emojiContent, backgroundIconColor): return EmojiPickerItem(context: arguments.context, theme: presentationData.theme, strings: presentationData.strings, emojiContent: emojiContent, backgroundIconColor: backgroundIconColor, sectionId: self.section) } @@ -204,7 +206,7 @@ private func peerNameColorScreenEntries( nameColor = .blue } - let colors = nameColors.get(nameColor) + let colors = nameColors.get(nameColor, dark: presentationData.theme.overallDarkAppearance) let backgroundEmojiId: Int64? if let updatedBackgroundEmojiId = state.updatedBackgroundEmojiId { @@ -254,7 +256,7 @@ private func peerNameColorScreenEntries( entries.append(.colorDescription(presentationData.strings.NameColor_ChatPreview_Description_Account)) if let emojiContent { - entries.append(.backgroundEmojiHeader(presentationData.strings.NameColor_BackgroundEmoji_Title)) + entries.append(.backgroundEmojiHeader(presentationData.strings.NameColor_BackgroundEmoji_Title, backgroundEmojiId != nil ? presentationData.strings.NameColor_BackgroundEmoji_Remove : nil)) entries.append(.backgroundEmoji(emojiContent, colors.main)) } } @@ -312,12 +314,12 @@ public func PeerNameColorScreen( peerId = channelId } - let emojiContent = combineLatest( + context.sharedContext.presentationData, statePromise.get(), context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) ) - |> mapToSignal { state, peer -> Signal in + |> mapToSignal { presentationData, state, peer -> Signal in var selectedEmojiId: Int64? if let updatedBackgroundEmojiId = state.updatedBackgroundEmojiId { selectedEmojiId = updatedBackgroundEmojiId @@ -330,7 +332,7 @@ public func PeerNameColorScreen( } else { nameColor = (peer?.nameColor ?? .blue) } - let color = context.peerNameColors.get(nameColor) + let color = context.peerNameColors.get(nameColor, dark: presentationData.theme.overallDarkAppearance) let selectedItems: [EngineMedia.Id] if let selectedEmojiId, selectedEmojiId != 0 { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index bd89764d6b..85a6d239ec 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -1621,7 +1621,7 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL } if isCreator || (channel.adminRights?.rights.contains(.canChangeInfo) == true) { - let colors = context.peerNameColors.get(data.peer?.nameColor ?? .blue) + let colors = context.peerNameColors.get(data.peer?.nameColor ?? .blue, dark: presentationData.theme.overallDarkAppearance) items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemNameColor, label: .semitransparentBadge(EnginePeer(channel).compactDisplayTitle, colors.main), text: "Channel Color", icon: UIImage(bundleImageName: "Chat/Info/NameColorIcon"), action: { interaction.editingOpenNameColorSetup() }))