mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Name colors improvements
This commit is contained in:
parent
44e737d837
commit
4432135259
@ -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.";
|
||||
|
@ -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]!
|
||||
|
@ -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?
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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<EmojiPagerContentComponent, NoError> in
|
||||
|> mapToSignal { presentationData, state, peer -> Signal<EmojiPagerContentComponent, NoError> 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 {
|
||||
|
@ -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()
|
||||
}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user