@@ -9,6 +9,8 @@
import UIKit
struct Constants {
+ // see: https://core.telegram.org/blackberry/chat
+ static let chatColors:[UIColor] = ["#ee4928", "#41a903", "#e09602", "#0f94ed", "#8f3bf7", "#fc4380", "#00a1c4", "#eb7002"].map {s in UIColor(hexString: s)}
struct Color {
static let bubble = UIColor(netHex: 0xefffde)
}
@@ -19,3 +21,4 @@ struct Constants {
static let deltachatImapPasswordKey = "__DELTACHAT_IMAP_PASSWORD_KEY__"
+
@@ -41,6 +41,10 @@ class ContactCell: UITableViewCell {
nameLabel.centerYAnchor.constraint(equalTo: initialsLabel.centerYAnchor).isActive = true
+ func setColor(_ color: UIColor) {
+ self.initialsLabel.backgroundColor = color
+ }
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
@@ -98,6 +98,8 @@ class NewChatViewController: UITableViewController {
cell.nameLabel.text = contact.name
// cell.detailTextLabel?.text = contact.email
cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
+ let contactColor = Utils.color(row: contactRow, colors: Constants.chatColors)
+ cell.setColor(contactColor)
return cell
@@ -10,6 +10,15 @@ import Foundation
struct Utils {
+ static func colorIndex(row: Int, colors:[UIColor]) -> Int {
+ return row % colors.count
+ static func color(row: Int, colors:[UIColor]) -> UIColor {
+ let index = colorIndex(row: row, colors: colors)
+ return colors[index]
static func getContactIds() -> [Int] {
let c_contacts = mrmailbox_get_known_contacts(mailboxPointer, nil)
return Utils.copyAndFreeArray(inputArray: c_contacts)