Skip to content

Commit dfb34bf

Browse files
committed
Start updating AddContactPage
I can't figure out why the list isn't populating correctly though.
1 parent e9350f7 commit dfb34bf

File tree

8 files changed

+289
-95
lines changed

8 files changed

+289
-95
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<UserControl
2+
x:Class="Signal_Windows.Controls.AddContactListElement"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Signal_Windows.Controls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
d:DesignHeight="80"
10+
d:DesignWidth="500">
11+
12+
<Grid>
13+
<Grid.ColumnDefinitions>
14+
<ColumnDefinition Width="Auto" />
15+
<ColumnDefinition Width="*" />
16+
</Grid.ColumnDefinitions>
17+
<Ellipse Grid.Column="0" Width="64" Height="64" Margin="8">
18+
<Ellipse.Fill>
19+
<ImageBrush ImageSource="{x:Bind ContactPhoto}"/>
20+
</Ellipse.Fill>
21+
</Ellipse>
22+
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,0,8,0">
23+
<TextBlock Grid.Column="0" Name="ConversationDisplayName" FontSize="24" FontWeight="SemiLight" Text="{x:Bind DisplayName}" TextTrimming="CharacterEllipsis"/>
24+
<TextBlock Text="{x:Bind PhoneNumber}" FontSize="20"/>
25+
</StackPanel>
26+
</Grid>
27+
</UserControl>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Runtime.InteropServices.WindowsRuntime;
7+
using Signal_Windows.Models;
8+
using Windows.Foundation;
9+
using Windows.Foundation.Collections;
10+
using Windows.UI.Xaml;
11+
using Windows.UI.Xaml.Controls;
12+
using Windows.UI.Xaml.Controls.Primitives;
13+
using Windows.UI.Xaml.Data;
14+
using Windows.UI.Xaml.Input;
15+
using Windows.UI.Xaml.Media;
16+
using Windows.UI.Xaml.Navigation;
17+
18+
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
19+
20+
namespace Signal_Windows.Controls
21+
{
22+
public sealed partial class AddContactListElement : UserControl, INotifyPropertyChanged
23+
{
24+
public event PropertyChangedEventHandler PropertyChanged;
25+
26+
public AddContactListElement()
27+
{
28+
this.InitializeComponent();
29+
this.DataContextChanged += AddContactListElement_DataContextChanged;
30+
}
31+
32+
public string _DisplayName;
33+
public string DisplayName
34+
{
35+
get { return _DisplayName; }
36+
set
37+
{
38+
_DisplayName = value;
39+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DisplayName)));
40+
}
41+
}
42+
43+
public string _PhoneNumber;
44+
public string PhoneNumber
45+
{
46+
get { return _PhoneNumber; }
47+
set
48+
{
49+
_PhoneNumber = value;
50+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(PhoneNumber)));
51+
}
52+
}
53+
54+
public ImageSource _ContactPhoto = null;
55+
public ImageSource ContactPhoto
56+
{
57+
get { return _ContactPhoto; }
58+
set
59+
{
60+
_ContactPhoto = value;
61+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ContactPhoto)));
62+
}
63+
}
64+
65+
public PhoneContact Model
66+
{
67+
get
68+
{
69+
return DataContext as PhoneContact;
70+
}
71+
set
72+
{
73+
DataContext = value;
74+
}
75+
}
76+
77+
private void AddContactListElement_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
78+
{
79+
if (Model != null)
80+
{
81+
Model.View = this;
82+
DisplayName = Model.Name;
83+
PhoneNumber = Model.PhoneNumber;
84+
ContactPhoto = Model.Photo;
85+
}
86+
}
87+
}
88+
}

Signal-Windows/Models/PhoneContact.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Signal_Windows.Controls;
7+
using Windows.UI.Xaml.Media;
8+
9+
namespace Signal_Windows.Models
10+
{
11+
public class PhoneContact
12+
{
13+
public string Name { get; set; }
14+
public string PhoneNumber { get; set; }
15+
public ImageSource Photo { get; set; }
16+
public AddContactListElement View;
17+
}
18+
}

Signal-Windows/Signal-Windows.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
<Compile Include="App.xaml.cs">
142142
<DependentUpon>App.xaml</DependentUpon>
143143
</Compile>
144+
<Compile Include="Controls\AddContactListElement.xaml.cs">
145+
<DependentUpon>AddContactListElement.xaml</DependentUpon>
146+
</Compile>
144147
<Compile Include="Controls\IdentityKeyChangeMessage.xaml.cs">
145148
<DependentUpon>IdentityKeyChangeMessage.xaml</DependentUpon>
146149
</Compile>
@@ -175,6 +178,7 @@
175178
<DependentUpon>20170825082857_m2.cs</DependentUpon>
176179
</Compile>
177180
<Compile Include="Migrations\SignalDB\SignalDBContextModelSnapshot.cs" />
181+
<Compile Include="Models\PhoneContact.cs" />
178182
<Compile Include="Models\SignalEarlyReceipt.cs" />
179183
<Compile Include="Models\SignalIdentity.cs" />
180184
<Compile Include="Models\SignalAttachment.cs" />
@@ -243,6 +247,10 @@
243247
<Generator>MSBuild:Compile</Generator>
244248
<SubType>Designer</SubType>
245249
</ApplicationDefinition>
250+
<Page Include="Controls\AddContactListElement.xaml">
251+
<SubType>Designer</SubType>
252+
<Generator>MSBuild:Compile</Generator>
253+
</Page>
246254
<Page Include="Controls\IdentityKeyChangeMessage.xaml">
247255
<SubType>Designer</SubType>
248256
<Generator>MSBuild:Compile</Generator>

0 commit comments

Comments
 (0)