Skip to content

Commit 4c9f381

Browse files
pawelsudo1golf1052
authored andcommitted
first letter of contact as contact icon
checking if the threaddisplayname is blank, setting the color from the contact remove whitespaces
1 parent 01a9eb0 commit 4c9f381

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

Signal-Windows/Controls/ConversationListElement.xaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
<ColumnDefinition Width="Auto" />
1414
<ColumnDefinition Width="*" />
1515
</Grid.ColumnDefinitions>
16-
<Ellipse Grid.Column="0" Width="64" Height="64" Margin="8">
17-
<Ellipse.Fill>
18-
<ImageBrush ImageSource="ms-appx:///Assets/gambino.png"/>
19-
</Ellipse.Fill>
20-
</Ellipse>
16+
<Grid>
17+
<Ellipse Grid.Column="0" Width="64" Height="64" Margin="8" Fill="{x:Bind FillBrush, Mode=OneWay}"/>
18+
<TextBlock Foreground="White" FontWeight="Light" FontSize="26" Text="{x:Bind Initials, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
19+
</Grid>
2120
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,0,8,0">
2221
<Grid>
2322
<Grid.ColumnDefinitions>

Signal-Windows/Controls/ConversationListElement.xaml.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using Windows.UI.Xaml;
55
using Windows.UI.Xaml.Controls;
6+
using Windows.UI.Xaml.Media;
67

78
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
89

@@ -75,6 +76,36 @@ public string LastMessage
7576
}
7677
}
7778

79+
private Brush _FillBrush = Utils.Blue;
80+
81+
public Brush FillBrush
82+
{
83+
get
84+
{
85+
return _FillBrush;
86+
}
87+
set
88+
{
89+
_FillBrush = value;
90+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FillBrush)));
91+
}
92+
}
93+
94+
private string _Initials = string.Empty;
95+
96+
public string Initials
97+
{
98+
get
99+
{
100+
return _Initials;
101+
}
102+
set
103+
{
104+
_Initials = value;
105+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Initials)));
106+
}
107+
}
108+
78109
private void ThreadListItem_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
79110
{
80111
if (Model != null)
@@ -83,6 +114,8 @@ private void ThreadListItem_DataContextChanged(FrameworkElement sender, DataCont
83114
ConversationDisplayName.Text = Model.ThreadDisplayName;
84115
UnreadCount = Model.UnreadCount;
85116
LastMessage = Model.LastMessage?.Content.Content;
117+
Initials = Model.ThreadDisplayName.Length == 0 ? "#" : Model.ThreadDisplayName.Substring(0, 1);
118+
FillBrush = Model is SignalContact ? Utils.GetBrushFromColor(((SignalContact)Model).Color) : Utils.Blue;
86119
}
87120
}
88121

0 commit comments

Comments
 (0)