|
|
@ -26,7 +26,7 @@ class AddressBook extends React.Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function nameToColor(name: string) {
|
|
|
|
function getContactColor(contact: ContactType) {
|
|
|
|
const colorOptions = [
|
|
|
|
const colorOptions = [
|
|
|
|
colors.red500,
|
|
|
|
colors.red500,
|
|
|
|
colors.pink500,
|
|
|
|
colors.pink500,
|
|
|
@ -47,8 +47,9 @@ class AddressBook extends React.Component {
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
let sum = 0;
|
|
|
|
let sum = 0;
|
|
|
|
for (let i = 0 ; i < name.length ; i++) {
|
|
|
|
const uid = contact.uid;
|
|
|
|
sum += name.charCodeAt(i);
|
|
|
|
for (let i = 0 ; i < uid.length ; i++) {
|
|
|
|
|
|
|
|
sum += uid.charCodeAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return colorOptions[sum % colorOptions.length];
|
|
|
|
return colorOptions[sum % colorOptions.length];
|
|
|
@ -61,7 +62,7 @@ class AddressBook extends React.Component {
|
|
|
|
let itemProps: any = {
|
|
|
|
let itemProps: any = {
|
|
|
|
leftAvatar: (
|
|
|
|
leftAvatar: (
|
|
|
|
<Avatar
|
|
|
|
<Avatar
|
|
|
|
backgroundColor={nameToColor(name)}
|
|
|
|
backgroundColor={getContactColor(entry)}
|
|
|
|
style={{left: 8}}
|
|
|
|
style={{left: 8}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{name[0].toUpperCase()}
|
|
|
|
{name[0].toUpperCase()}
|
|
|
|