Modernize color changed toast

This commit is contained in:
Isaac
2023-11-27 17:05:20 +04:00
parent d5e7012bd6
commit 58eb4ce2bb
7 changed files with 135 additions and 50 deletions

View File

@@ -122,7 +122,7 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
case themes(PresentationTheme, PresentationStrings, [PresentationThemeReference], PresentationThemeReference, Bool, [String: [StickerPackItem]], [Int64: PresentationThemeAccentColor], [Int64: TelegramWallpaper])
case chatTheme(PresentationTheme, String)
case wallpaper(PresentationTheme, String)
case nameColor(PresentationTheme, String, String, UIColor)
case nameColor(PresentationTheme, String, String, PeerNameColors.Colors?, PeerNameColors.Colors?)
case autoNight(PresentationTheme, String, Bool, Bool)
case autoNightTheme(PresentationTheme, String, String)
case textSize(PresentationTheme, String, String)
@@ -217,8 +217,8 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .nameColor(lhsTheme, lhsText, lhsName, lhsColor):
if case let .nameColor(rhsTheme, rhsText, rhsName, rhsColor) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsName == rhsName, lhsColor == rhsColor {
case let .nameColor(lhsTheme, lhsText, lhsName, lhsNameColor, lhsProfileColor):
if case let .nameColor(rhsTheme, rhsText, rhsName, rhsNameColor, rhsProfileColor) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsName == rhsName, lhsNameColor == rhsNameColor, lhsProfileColor == rhsProfileColor {
return true
} else {
return false
@@ -321,8 +321,18 @@ private enum ThemeSettingsControllerEntry: ItemListNodeEntry {
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: {
arguments.openWallpaperSettings()
})
case let .nameColor(_, text, name, color):
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: name, labelStyle: .semitransparentBadge(color), sectionId: self.section, style: .blocks, action: {
case let .nameColor(_, text, _, nameColor, profileColor):
var colors: [PeerNameColors.Colors] = []
if let nameColor {
colors.append(nameColor)
}
if let profileColor {
colors.append(profileColor)
}
let colorImage = generateSettingsMenuPeerColorsLabelIcon(colors: colors)
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", labelStyle: .image(image: colorImage, size: colorImage.size), sectionId: self.section, style: .blocks, action: {
arguments.openNameColorSettings()
})
case let .autoNight(_, title, value, enabled):
@@ -377,14 +387,17 @@ private func themeSettingsControllerEntries(presentationData: PresentationData,
entries.append(.themeListHeader(presentationData.theme, title))
let nameColor: PeerNameColor
let profileColor: 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)
}
profileColor = accountPeer.profileColor
} else {
nameColor = .blue
profileColor = nil
}
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)]))
@@ -393,8 +406,10 @@ private func themeSettingsControllerEntries(presentationData: PresentationData,
entries.append(.chatTheme(presentationData.theme, strings.Settings_ChatThemes))
entries.append(.wallpaper(presentationData.theme, strings.Settings_ChatBackground))
let colors = nameColors.get(nameColor)
entries.append(.nameColor(presentationData.theme, strings.Appearance_NameColor, accountPeer?.compactDisplayTitle ?? "", colors.main))
let colors = nameColors.get(nameColor, dark: presentationData.theme.overallDarkAppearance)
let profileColors = profileColor.flatMap { nameColors.getProfile($0, dark: presentationData.theme.overallDarkAppearance, subject: .palette) }
//TODO:localize
entries.append(.nameColor(presentationData.theme, "Your Color", accountPeer?.compactDisplayTitle ?? "", colors, profileColors))
entries.append(.autoNight(presentationData.theme, strings.Appearance_NightTheme, presentationThemeSettings.automaticThemeSwitchSetting.force, !presentationData.autoNightModeTriggered || presentationThemeSettings.automaticThemeSwitchSetting.force))
let autoNightMode: String