mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Name color improvements
This commit is contained in:
parent
d5065e41e9
commit
4c010cb5d2
8 changed files with 51 additions and 12 deletions
|
|
@ -10150,6 +10150,8 @@ Sorry for the inconvenience.";
|
|||
"NameColor.UnsavedChanges.Discard" = "Discard";
|
||||
"NameColor.UnsavedChanges.Apply" = "Apply";
|
||||
|
||||
"NameColor.YourColorUpdated" = "Your name color has been updated.";
|
||||
|
||||
"Chat.ErrorQuoteOutdatedTitle" = "Quote Outdated";
|
||||
"Chat.ErrorQuoteOutdatedText" = "**%@** updated the message you are quoting. Edit your quote to make it up-to-date.";
|
||||
"Chat.ErrorQuoteOutdatedActionEdit" = "Edit";
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ private func themePickerControllerEntries(presentationData: PresentationData, pr
|
|||
entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, nightMode, animatedEmojiStickers, presentationThemeSettings.themeSpecificAccentColors, presentationThemeSettings.themeSpecificChatWallpapers))
|
||||
|
||||
entries.append(.customHeader(presentationData.theme, presentationData.strings.Themes_BuildOwn.uppercased()))
|
||||
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
|
||||
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText, nameColor: .blue, backgroundEmojiId: nil), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText, nameColor: .blue, backgroundEmojiId: nil)]))
|
||||
|
||||
let generalThemes: [PresentationThemeReference] = availableThemes.filter { reference in
|
||||
if case let .cloud(theme) = reference {
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ private func editThemeControllerEntries(presentationData: PresentationData, stat
|
|||
entries.append(.slugInfo(presentationData.theme, infoText))
|
||||
|
||||
entries.append(.chatPreviewHeader(presentationData.theme, presentationData.strings.EditTheme_Preview.uppercased()))
|
||||
entries.append(.chatPreview(presentationData.theme, previewTheme, previewTheme.chat.defaultWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (previewIncomingReplyName, previewIncomingReplyText), text: previewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: previewOutgoingText)]))
|
||||
entries.append(.chatPreview(presentationData.theme, previewTheme, previewTheme.chat.defaultWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (previewIncomingReplyName, previewIncomingReplyText), text: previewIncomingText, nameColor: .blue, backgroundEmojiId: nil), ChatPreviewMessageItem(outgoing: true, reply: nil, text: previewOutgoingText, nameColor: .blue, backgroundEmojiId: nil)]))
|
||||
|
||||
entries.append(.changeColors(presentationData.theme, presentationData.strings.EditTheme_ChangeColors))
|
||||
if hasSettings {
|
||||
|
|
|
|||
|
|
@ -25,12 +25,20 @@ struct ChatPreviewMessageItem: Equatable {
|
|||
if lhs.text != rhs.text {
|
||||
return false
|
||||
}
|
||||
if lhs.nameColor != rhs.nameColor {
|
||||
return false
|
||||
}
|
||||
if lhs.backgroundEmojiId != rhs.backgroundEmojiId {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
let outgoing: Bool
|
||||
let reply: (String, String)?
|
||||
let text: String
|
||||
let nameColor: PeerNameColor
|
||||
let backgroundEmojiId: Int64?
|
||||
}
|
||||
|
||||
class ThemeSettingsChatPreviewItem: ListViewItem, ItemListItem {
|
||||
|
|
@ -155,7 +163,7 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode {
|
|||
|
||||
let replyMessageId = MessageId(peerId: peerId, namespace: 0, id: 3)
|
||||
if let (author, text) = messageItem.reply {
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: author, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: .blue, backgroundEmojiId: nil)
|
||||
peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: author, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: messageItem.nameColor, backgroundEmojiId: messageItem.backgroundEmojiId)
|
||||
messages[replyMessageId] = Message(stableId: 3, stableVersion: 0, id: replyMessageId, globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: text, attributes: [], media: [], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:])
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -375,16 +375,26 @@ private func themeSettingsControllerEntries(presentationData: PresentationData,
|
|||
let strings = presentationData.strings
|
||||
let title = presentationData.autoNightModeTriggered ? strings.Appearance_ColorThemeNight.uppercased() : strings.Appearance_ColorTheme.uppercased()
|
||||
entries.append(.themeListHeader(presentationData.theme, title))
|
||||
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (presentationData.strings.Appearance_PreviewReplyAuthor, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText)]))
|
||||
|
||||
let nameColor: PeerNameColor
|
||||
var authorName = presentationData.strings.Appearance_PreviewReplyAuthor
|
||||
if let accountPeer {
|
||||
nameColor = accountPeer.nameColor ?? .blue
|
||||
if accountPeer._asPeer().hasCustomNameColor {
|
||||
authorName = accountPeer.displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
}
|
||||
} else {
|
||||
nameColor = .blue
|
||||
}
|
||||
|
||||
entries.append(.chatPreview(presentationData.theme, presentationData.chatWallpaper, presentationData.chatFontSize, presentationData.chatBubbleCorners, presentationData.strings, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, [ChatPreviewMessageItem(outgoing: false, reply: (authorName, presentationData.strings.Appearance_PreviewReplyText), text: presentationData.strings.Appearance_PreviewIncomingText, nameColor: nameColor, backgroundEmojiId: accountPeer?.backgroundEmojiId), ChatPreviewMessageItem(outgoing: true, reply: nil, text: presentationData.strings.Appearance_PreviewOutgoingText, nameColor: .blue, backgroundEmojiId: nil)]))
|
||||
|
||||
entries.append(.themes(presentationData.theme, presentationData.strings, chatThemes, themeReference, presentationThemeSettings.automaticThemeSwitchSetting.force || presentationData.autoNightModeTriggered, animatedEmojiStickers, presentationThemeSettings.themeSpecificAccentColors, presentationThemeSettings.themeSpecificChatWallpapers))
|
||||
entries.append(.chatTheme(presentationData.theme, strings.Settings_ChatThemes))
|
||||
entries.append(.wallpaper(presentationData.theme, strings.Settings_ChatBackground))
|
||||
|
||||
if let accountPeer {
|
||||
let colors = nameColors.get(accountPeer.nameColor ?? .blue)
|
||||
entries.append(.nameColor(presentationData.theme, strings.Appearance_NameColor, accountPeer.compactDisplayTitle, colors.main))
|
||||
}
|
||||
let colors = nameColors.get(nameColor)
|
||||
entries.append(.nameColor(presentationData.theme, strings.Appearance_NameColor, accountPeer?.compactDisplayTitle ?? "", colors.main))
|
||||
|
||||
entries.append(.autoNight(presentationData.theme, strings.Appearance_NightTheme, presentationThemeSettings.automaticThemeSwitchSetting.force, !presentationData.autoNightModeTriggered || presentationThemeSettings.automaticThemeSwitchSetting.force))
|
||||
let autoNightMode: String
|
||||
|
|
|
|||
|
|
@ -236,6 +236,14 @@ public extension Peer {
|
|||
}
|
||||
}
|
||||
|
||||
var hasCustomNameColor: Bool {
|
||||
let defaultNameColor = PeerNameColor(rawValue: Int32(self.id.id._internalGetInt64Value() % 7))
|
||||
if self.nameColor != defaultNameColor {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var backgroundEmojiId: Int64? {
|
||||
switch self {
|
||||
case let user as TelegramUser:
|
||||
|
|
|
|||
|
|
@ -523,9 +523,9 @@ final class PeerNameColorItemNode: ListViewItemNode, ItemListItemNode {
|
|||
var i: Int = 0
|
||||
for index in item.colors.displayOrder {
|
||||
let color = PeerNameColor(rawValue: index)
|
||||
if let colors = item.colors.colors[index] {
|
||||
entries.append(.color(i, color, colors, color == item.currentColor))
|
||||
}
|
||||
let colors = item.colors.get(color, dark: item.theme.overallDarkAppearance)
|
||||
entries.append(.color(i, color, colors, color == item.currentColor))
|
||||
|
||||
i += 1
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -576,7 +576,7 @@ public func PeerNameColorScreen(
|
|||
return true
|
||||
}
|
||||
}
|
||||
applyChangesImpl = {
|
||||
applyChangesImpl = { [weak controller] in
|
||||
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|
||||
|> deliverOnMainQueue).startStandalone(next: { peer in
|
||||
guard let peer else {
|
||||
|
|
@ -590,6 +590,17 @@ public func PeerNameColorScreen(
|
|||
switch subject {
|
||||
case .account:
|
||||
let _ = context.engine.accountData.updateNameColorAndEmoji(nameColor: nameColor ?? .blue, backgroundEmojiId: backgroundEmojiId ?? 0).startStandalone()
|
||||
|
||||
if let navigationController = controller?.navigationController as? NavigationController {
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
Queue.mainQueue().after(0.25) {
|
||||
if let lastController = navigationController.viewControllers.last as? ViewController {
|
||||
let tipController = UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.NameColor_YourColorUpdated, timeout: nil, customUndoText: nil), elevatedLayout: false, position: .bottom, animateInAsReplacement: false, action: { _ in return false })
|
||||
lastController.present(tipController, in: .window(.root))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dismissImpl?()
|
||||
case let .channel(peerId):
|
||||
updateState { state in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue