Skip to content

Commit 9bd3db4

Browse files
committed
Add BlockedContactsPage
1 parent ccd79f4 commit 9bd3db4

9 files changed

+220
-11
lines changed

Signal-Windows/Controls/ConversationListElement.xaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
<Ellipse Grid.Column="0" Width="64" Height="64" Margin="8" Fill="{x:Bind FillBrush, Mode=OneWay}"/>
1919
<TextBlock Foreground="White" FontWeight="Light" FontSize="26" Text="{x:Bind Initials, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
2020
</Grid>
21-
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,0,8,0">
22-
<Grid>
21+
<Grid Grid.Column="1" VerticalAlignment="Center" Margin="0,0,8,0">
22+
<Grid.RowDefinitions>
23+
<RowDefinition Height="Auto"/>
24+
<RowDefinition Height="Auto"/>
25+
</Grid.RowDefinitions>
26+
<Grid Grid.Row="0">
2327
<Grid.ColumnDefinitions>
2428
<ColumnDefinition Width="Auto"/>
2529
<ColumnDefinition Width="*"/>
@@ -29,17 +33,17 @@
2933
<TextBlock Grid.Column="1" Name="ConversationDisplayName" FontSize="15" FontWeight="SemiLight" Text="{x:Bind Model.ThreadDisplayName, Mode=OneWay}" TextTrimming="CharacterEllipsis"/>
3034
<TextBlock x:Name="LastActiveTextBlock" Grid.Column="2" Text="{x:Bind LastMessageTimestamp, Mode=OneWay}" FontSize="11" Foreground="#999999" TextTrimming="CharacterEllipsis"/>
3135
</Grid>
32-
<Grid>
36+
<Grid Grid.Row="1">
3337
<Grid.ColumnDefinitions>
3438
<ColumnDefinition Width="*"/>
3539
<ColumnDefinition Width="Auto"/>
3640
</Grid.ColumnDefinitions>
37-
<TextBlock Grid.Column="0" Text="{x:Bind LastMessage, Mode=OneWay}" FontSize="12"/>
38-
<Grid Grid.Column="1" Width="20" Height="20" Margin="10 0 0 0">
39-
<Ellipse Fill="#2190EA" Visibility="{x:Bind UnreadStringVisibility, Mode=TwoWay}"/>
40-
<TextBlock Text="{x:Bind UnreadString, Mode=TwoWay}" FontWeight="Bold" FontSize="12" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
41+
<TextBlock Grid.Column="0" Text="{x:Bind LastMessage, Mode=OneWay}" Visibility="{x:Bind LastMessageVisibility, Mode=OneWay}" FontSize="12"/>
42+
<Grid Grid.Column="1" Margin="10 0 0 0">
43+
<Ellipse Fill="#2190EA" Visibility="{x:Bind UnreadStringVisibility, Mode=OneWay}" Width="20" Height="20"/>
44+
<TextBlock Text="{x:Bind UnreadString, Mode=TwoWay}" Visibility="{x:Bind UnreadStringVisibility, Mode=OneWay}" FontWeight="Bold" FontSize="12" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
4145
</Grid>
4246
</Grid>
43-
</StackPanel>
47+
</Grid>
4448
</Grid>
4549
</UserControl>

Signal-Windows/Controls/ConversationListElement.xaml.cs

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Signal_Windows.Models;
2+
using Signal_Windows.Views;
23
using System.ComponentModel;
34
using System.Diagnostics;
45
using Windows.UI.Xaml;
@@ -95,6 +96,25 @@ public string LastMessage
9596
{
9697
_LastMessage = value;
9798
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LastMessage)));
99+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LastMessageVisibility)));
100+
}
101+
}
102+
103+
public Visibility LastMessageVisibility
104+
{
105+
get
106+
{
107+
if (string.IsNullOrEmpty(LastMessage))
108+
{
109+
return Visibility.Collapsed;
110+
}
111+
else
112+
{
113+
return Visibility.Visible;
114+
}
115+
}
116+
set
117+
{
98118
}
99119
}
100120

@@ -144,8 +164,20 @@ private void ThreadListItem_DataContextChanged(FrameworkElement sender, DataCont
144164
{
145165
if (Model != null)
146166
{
147-
UpdateConversationDisplay();
148-
Model.UpdateUI = UpdateConversationDisplay;
167+
var frame = Window.Current.Content as Frame;
168+
if (frame != null)
169+
{
170+
if (frame.CurrentSourcePageType == typeof(BlockedContactsPage))
171+
{
172+
UpdateBlockedContactElement();
173+
Model.UpdateUI = UpdateBlockedContactElement;
174+
}
175+
else if (frame.CurrentSourcePageType == typeof(MainPage))
176+
{
177+
UpdateConversationDisplay();
178+
Model.UpdateUI = UpdateConversationDisplay;
179+
}
180+
}
149181
}
150182
}
151183

@@ -170,5 +202,18 @@ public void UpdateConversationDisplay()
170202
LastMessageTimestamp = Utils.GetTimestamp(Model.LastActiveTimestamp);
171203
}
172204
}
205+
206+
public void UpdateBlockedContactElement()
207+
{
208+
if (Model != null)
209+
{
210+
SignalContact contact = (SignalContact)Model;
211+
FillBrush = contact.Color != null ? Utils.GetBrushFromColor((contact.Color)) :
212+
Utils.GetBrushFromColor(Utils.CalculateDefaultColor(Model.ThreadDisplayName));
213+
ConversationDisplayName.Text = Model.ThreadDisplayName;
214+
Initials = Utils.GetInitials(Model.ThreadDisplayName);
215+
LastMessage = null;
216+
}
217+
}
173218
}
174219
}

Signal-Windows/Signal-Windows.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
<Compile Include="ViewModels\AddContactPageViewModel.cs" />
177177
<Compile Include="ViewModels\AdvancedSettingsPageViewModel.cs" />
178178
<Compile Include="ViewModels\AppearanceSettingsPageViewModel.cs" />
179+
<Compile Include="ViewModels\BlockedContactsPageViewModel.cs" />
179180
<Compile Include="ViewModels\ChatsAndMediaSettingsPageViewModel.cs" />
180181
<Compile Include="ViewModels\ConversationSettingsPageViewModel.cs" />
181182
<Compile Include="ViewModels\FinishRegistrationPageViewModel.cs" />
@@ -200,6 +201,9 @@
200201
<Compile Include="Views\AppearanceSettingsPage.xaml.cs">
201202
<DependentUpon>AppearanceSettingsPage.xaml</DependentUpon>
202203
</Compile>
204+
<Compile Include="Views\BlockedContactsPage.xaml.cs">
205+
<DependentUpon>BlockedContactsPage.xaml</DependentUpon>
206+
</Compile>
203207
<Compile Include="Views\ChatsAndMediaSettingsPage.xaml.cs">
204208
<DependentUpon>ChatsAndMediaSettingsPage.xaml</DependentUpon>
205209
</Compile>
@@ -303,6 +307,10 @@
303307
<SubType>Designer</SubType>
304308
<Generator>MSBuild:Compile</Generator>
305309
</Page>
310+
<Page Include="Views\BlockedContactsPage.xaml">
311+
<SubType>Designer</SubType>
312+
<Generator>MSBuild:Compile</Generator>
313+
</Page>
306314
<Page Include="Views\ChatsAndMediaSettingsPage.xaml">
307315
<SubType>Designer</SubType>
308316
<Generator>MSBuild:Compile</Generator>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using GalaSoft.MvvmLight;
8+
using Signal_Windows.Models;
9+
using Signal_Windows.Storage;
10+
11+
namespace Signal_Windows.ViewModels
12+
{
13+
public class BlockedContactsPageViewModel : ViewModelBase
14+
{
15+
public ObservableCollection<SignalContact> BlockedContacts { get; set; } = new ObservableCollection<SignalContact>();
16+
17+
public bool NoBlockedContacts
18+
{
19+
get
20+
{
21+
if (BlockedContacts != null)
22+
{
23+
return BlockedContacts.Count == 0;
24+
}
25+
else
26+
{
27+
return true;
28+
}
29+
}
30+
set
31+
{
32+
}
33+
}
34+
35+
public void OnNavigatedTo()
36+
{
37+
List<SignalContact> blockedContacts = SignalDBContext.GetAllContactsLocked()
38+
.Where(contact => contact.Blocked)
39+
.ToList();
40+
BlockedContacts = new ObservableCollection<SignalContact>(blockedContacts);
41+
}
42+
}
43+
}

Signal-Windows/ViewModels/ViewModelLocator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public ViewModelLocator()
4646
SimpleIoc.Default.Register<AppearanceSettingsPageViewModel>();
4747
SimpleIoc.Default.Register<ChatsAndMediaSettingsPageViewModel>();
4848
SimpleIoc.Default.Register<AdvancedSettingsPageViewModel>();
49+
SimpleIoc.Default.Register<BlockedContactsPageViewModel>();
4950
}
5051

5152
// <summary>
@@ -142,6 +143,11 @@ public AdvancedSettingsPageViewModel AdvancedSettingsPageInstance
142143
get { return ServiceLocator.Current.GetInstance<AdvancedSettingsPageViewModel>(Key.ToString()); }
143144
}
144145

146+
public BlockedContactsPageViewModel BlockedContactsPageInstance
147+
{
148+
get { return ServiceLocator.Current.GetInstance<BlockedContactsPageViewModel>(Key.ToString()); }
149+
}
150+
145151
// <summary>
146152
// The cleanup.
147153
// </summary>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Page
2+
x:Class="Signal_Windows.Views.BlockedContactsPage"
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.Views"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:controls="using:Signal_Windows.Controls"
9+
mc:Ignorable="d"
10+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
11+
DataContext="{Binding BlockedContactsPageInstance, Source={StaticResource Locator}}">
12+
13+
<Grid>
14+
<Grid.RowDefinitions>
15+
<RowDefinition Height="1*"/>
16+
<RowDefinition Height="8*"/>
17+
</Grid.RowDefinitions>
18+
<TextBlock Text="Blocked Contacts" Style="{StaticResource TitleTextBlockStyle}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
19+
<TextBlock Grid.Row="1" Text="No blocked contacts" Visibility="{x:Bind Vm.NoBlockedContacts, Mode=OneWay}" Style="{StaticResource SubtitleTextBlockStyle}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
20+
<ListView Grid.Row="1" x:Name="BlockedContactsListView" SelectionMode="Single" ItemsSource="{x:Bind Vm.BlockedContacts, Mode=OneWay}" HorizontalAlignment="Stretch" Margin="32,0" SelectionChanged="BlockedContactsListView_SelectionChanged">
21+
<ListView.ItemTemplate>
22+
<DataTemplate>
23+
<controls:ConversationListElement/>
24+
</DataTemplate>
25+
</ListView.ItemTemplate>
26+
</ListView>
27+
</Grid>
28+
</Page>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Signal_Windows.Models;
7+
using Signal_Windows.ViewModels;
8+
using Windows.Foundation;
9+
using Windows.Foundation.Collections;
10+
using Windows.UI.Core;
11+
using Windows.UI.ViewManagement;
12+
using Windows.UI.Xaml;
13+
using Windows.UI.Xaml.Controls;
14+
using Windows.UI.Xaml.Controls.Primitives;
15+
using Windows.UI.Xaml.Data;
16+
using Windows.UI.Xaml.Input;
17+
using Windows.UI.Xaml.Media;
18+
using Windows.UI.Xaml.Navigation;
19+
20+
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
21+
22+
namespace Signal_Windows.Views
23+
{
24+
/// <summary>
25+
/// An empty page that can be used on its own or navigated to within a Frame.
26+
/// </summary>
27+
public sealed partial class BlockedContactsPage : Page
28+
{
29+
public BlockedContactsPage()
30+
{
31+
this.InitializeComponent();
32+
}
33+
34+
public BlockedContactsPageViewModel Vm
35+
{
36+
get { return (BlockedContactsPageViewModel)DataContext; }
37+
}
38+
39+
protected override void OnNavigatedTo(NavigationEventArgs e)
40+
{
41+
Utils.EnableBackButton(BackButton_Click);
42+
Vm.OnNavigatedTo();
43+
}
44+
45+
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
46+
{
47+
Utils.DisableBackButton(BackButton_Click);
48+
}
49+
50+
private void BackButton_Click(object sender, BackRequestedEventArgs e)
51+
{
52+
Frame.GoBack();
53+
e.Handled = true;
54+
}
55+
56+
private void BlockedContactsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
57+
{
58+
if (e.AddedItems.Count == 1)
59+
{
60+
var contact = e.AddedItems[0] as SignalContact;
61+
App.CurrentSignalWindowsFrontend(ApplicationView.GetForCurrentView().Id).Locator.ConversationSettingsPageInstance.Contact = contact;
62+
Frame.Navigate(typeof(ConversationSettingsPage));
63+
}
64+
}
65+
}
66+
}

Signal-Windows/Views/PrivacySettingsPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<TextBlock Text="If read receipts are disabled you won't be able to see read receipts from others." Style="{StaticResource CaptionTextBlockStyle}"/>
3333
<ToggleSwitch x:Name="ReadReceiptsToggleSwitch" Toggled="ReadReceiptsToggleSwitch_Toggled" IsEnabled="False" IsOn="{x:Bind Vm.ReadReceipts, Mode=TwoWay}"/>
3434
</StackPanel>
35-
<Button Grid.Row="2" Content="Blocked contacts" Margin="0,8,0,8" IsEnabled="False"/>
35+
<Button x:Name="BlockedContactsButton" Grid.Row="2" Content="Blocked contacts" Margin="0,8,0,8" Click="BlockedContactsButton_Click" />
3636
</Grid>
3737
</ScrollViewer>
3838
</Grid>

Signal-Windows/Views/PrivacySettingsPage.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
34
using System.IO;
45
using System.Linq;
56
using System.Runtime.InteropServices.WindowsRuntime;
67
using Signal_Windows.Lib;
8+
using Signal_Windows.Models;
9+
using Signal_Windows.Storage;
710
using Signal_Windows.ViewModels;
811
using Windows.Foundation;
912
using Windows.Foundation.Collections;
1013
using Windows.UI.Core;
14+
using Windows.UI.ViewManagement;
1115
using Windows.UI.Xaml;
1216
using Windows.UI.Xaml.Controls;
1317
using Windows.UI.Xaml.Controls.Primitives;
@@ -63,5 +67,10 @@ private void ReadReceiptsToggleSwitch_Toggled(object sender, RoutedEventArgs e)
6367
var toggleSwitch = sender as ToggleSwitch;
6468
Vm.ReadReceiptsToggleSwitch_Toggled(toggleSwitch.IsOn);
6569
}
70+
71+
private void BlockedContactsButton_Click(object sender, RoutedEventArgs e)
72+
{
73+
Frame.Navigate(typeof(BlockedContactsPage));
74+
}
6675
}
6776
}

0 commit comments

Comments
 (0)