Skip to content

Commit 34ad701

Browse files
committed
Add very basic AttachmentDetailsPage
1 parent 75855bc commit 34ad701

File tree

6 files changed

+108
-8
lines changed

6 files changed

+108
-8
lines changed

Signal-Windows/Controls/Attachment.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<StackPanel Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="8,0,0,0">
1313
<Grid Width="200" Height="200">
14-
<Image Name="AttachmentImage" Stretch="UniformToFill">
14+
<Image Name="AttachmentImage" Stretch="UniformToFill" Tapped="AttachmentImage_Tapped">
1515
<Image.Source>
1616
<BitmapImage UriSource="{x:Bind ImagePath, Mode=TwoWay}"/>
1717
</Image.Source>

Signal-Windows/Controls/Attachment.xaml.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using Windows.Foundation;
1212
using Windows.Foundation.Collections;
1313
using Windows.Storage;
14-
14+
using Windows.UI.ViewManagement;
1515
using Windows.UI.Xaml;
1616
using Windows.UI.Xaml.Controls;
1717
using Windows.UI.Xaml.Controls.Primitives;
@@ -88,18 +88,28 @@ private void AttachmentDownloadIcon_Tapped(object sender, TappedRoutedEventArgs
8888
App.Handle.StartAttachmentDownload(Model);
8989
}
9090

91-
private static HashSet<string> IMAGE_TYPES = new HashSet<string>()
91+
private void AttachmentImage_Tapped(object sender, TappedRoutedEventArgs e)
9292
{
93-
"image/jpeg",
94-
"image/png",
95-
"image/gif",
96-
"image/bmp"
97-
};
93+
if (IsDetailsPageEnabled)
94+
{
95+
App.CurrentSignalWindowsFrontend(ApplicationView.GetForCurrentView().Id).Locator.MainPageInstance.OpenAttachment(Model);
96+
}
97+
}
9898

9999
public bool HandleUpdate(SignalAttachment sa)
100100
{
101101
DataContext = sa;
102102
return Model.Status != SignalAttachmentStatus.Finished && Model.Status != SignalAttachmentStatus.Failed_Permanently;
103103
}
104+
105+
private bool IsDetailsPageEnabled => IMAGE_TYPES.Contains(Model.ContentType);
106+
107+
private static HashSet<string> IMAGE_TYPES = new HashSet<string>()
108+
{
109+
"image/jpeg",
110+
"image/png",
111+
"image/gif",
112+
"image/bmp"
113+
};
104114
}
105115
}

Signal-Windows/Signal-Windows.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@
209209
<Compile Include="Views\AppearanceSettingsPage.xaml.cs">
210210
<DependentUpon>AppearanceSettingsPage.xaml</DependentUpon>
211211
</Compile>
212+
<Compile Include="Views\AttachmentDetailsPage.xaml.cs">
213+
<DependentUpon>AttachmentDetailsPage.xaml</DependentUpon>
214+
</Compile>
212215
<Compile Include="Views\BlockedContactsPage.xaml.cs">
213216
<DependentUpon>BlockedContactsPage.xaml</DependentUpon>
214217
</Compile>
@@ -323,6 +326,10 @@
323326
<SubType>Designer</SubType>
324327
<Generator>MSBuild:Compile</Generator>
325328
</Page>
329+
<Page Include="Views\AttachmentDetailsPage.xaml">
330+
<SubType>Designer</SubType>
331+
<Generator>MSBuild:Compile</Generator>
332+
</Page>
326333
<Page Include="Views\BlockedContactsPage.xaml">
327334
<SubType>Designer</SubType>
328335
<Generator>MSBuild:Compile</Generator>

Signal-Windows/ViewModels/MainPageViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ public void ConversationsList_SelectionChanged(object sender, SelectionChangedEv
169169
}
170170

171171
#region SignalFrontend API
172+
public void OpenAttachment(SignalAttachment sa)
173+
{
174+
View.Frame.Navigate(typeof(AttachmentDetailsPage), sa);
175+
}
176+
172177
public void AddOrUpdateConversation(SignalConversation conversation, SignalMessage updateMessage)
173178
{
174179
SignalConversation uiConversation;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Page
2+
x:Class="Signal_Windows.Views.AttachmentDetailsPage"
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+
mc:Ignorable="d"
9+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
10+
11+
<!-- https://www.goedware.com/index.php/blog/3-pinch-zoom-image-in-uwp-app -->
12+
<FlipView Name="ImageFlipView" ItemsSource="{x:Bind Attachments}" Width="Auto" Height="Auto">
13+
<FlipView.ItemTemplate>
14+
<DataTemplate>
15+
<Image Source="{Binding}" />
16+
</DataTemplate>
17+
</FlipView.ItemTemplate>
18+
</FlipView>
19+
20+
</Page>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using Signal_Windows.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Collections.ObjectModel;
5+
using System.IO;
6+
using System.Linq;
7+
using System.Runtime.InteropServices.WindowsRuntime;
8+
using Windows.Foundation;
9+
using Windows.Foundation.Collections;
10+
using Windows.Storage;
11+
using Windows.UI.Core;
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 AttachmentDetailsPage : Page
28+
{
29+
public ObservableCollection<string> Attachments { get; set; } = new ObservableCollection<string>();
30+
31+
public AttachmentDetailsPage()
32+
{
33+
this.InitializeComponent();
34+
}
35+
36+
public string Path { get; set; }
37+
38+
protected override void OnNavigatedTo(NavigationEventArgs e)
39+
{
40+
base.OnNavigatedTo(e);
41+
Utils.EnableBackButton(BackButton_Click);
42+
Attachments.Clear();
43+
Attachments.Add($"{ApplicationData.Current.LocalCacheFolder.Path}/Attachments/{(e.Parameter as SignalAttachment).Id}.plain");
44+
}
45+
46+
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
47+
{
48+
base.OnNavigatingFrom(e);
49+
Utils.DisableBackButton(BackButton_Click);
50+
}
51+
52+
private void BackButton_Click(object sender, BackRequestedEventArgs e)
53+
{
54+
Frame.GoBack();
55+
e.Handled = true;
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)