New attachment templates that support saving and opening attachment when composing message.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Toolkit.Uwp.Helpers;
|
||||
using Windows.Storage;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
|
||||
namespace Wino.Extensions
|
||||
{
|
||||
public static class MimeKitExtensions
|
||||
{
|
||||
public static async Task<MailAttachmentViewModel> ToAttachmentViewModelAsync(this StorageFile storageFile)
|
||||
{
|
||||
if (storageFile == null) return null;
|
||||
|
||||
var bytes = await storageFile.ReadBytesAsync();
|
||||
|
||||
return new MailAttachmentViewModel(storageFile.Name, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:abstract="using:Wino.Views.Abstract"
|
||||
xmlns:controls="using:Wino.Controls"
|
||||
xmlns:coreControls="using:Wino.Core.UWP.Controls"
|
||||
xmlns:customcontrols="using:Wino.Core.UWP.Controls.CustomControls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:data="using:Wino.Mail.ViewModels.Data"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
@@ -15,6 +16,7 @@
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:reader="using:Wino.Core.Domain.Models.Reader"
|
||||
xmlns:toolkit="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:ui="using:CommunityToolkit.WinUI"
|
||||
x:Name="root"
|
||||
d:Background="White"
|
||||
Loaded="ComposerLoaded"
|
||||
@@ -74,8 +76,24 @@
|
||||
<Grid
|
||||
Height="50"
|
||||
Margin="-8,0,0,0"
|
||||
Padding="0"
|
||||
Background="Transparent"
|
||||
ColumnSpacing="3">
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem
|
||||
Command="{Binding ElementName=root, Path=ViewModel.OpenAttachmentCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Text="{x:Bind domain:Translator.Buttons_Open}" />
|
||||
<MenuFlyoutItem
|
||||
Command="{Binding ElementName=root, Path=ViewModel.SaveAttachmentCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Text="{x:Bind domain:Translator.Buttons_Save}" />
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
<ToolTipService.ToolTip>
|
||||
<ToolTip Content="{x:Bind FileName}" />
|
||||
</ToolTipService.ToolTip>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="36" />
|
||||
<ColumnDefinition Width="*" />
|
||||
@@ -113,11 +131,21 @@
|
||||
Text="{x:Bind ReadableSize}" />
|
||||
</Grid>
|
||||
|
||||
<SymbolIcon
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource DeleteBrush}"
|
||||
Symbol="Cancel" />
|
||||
Margin="0,4,-8,4"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
Command="{Binding ElementName=root, Path=ViewModel.RemoveAttachmentCommand}"
|
||||
CommandParameter="{Binding}">
|
||||
<SymbolIcon
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{StaticResource DeleteBrush}"
|
||||
Symbol="Delete" />
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
@@ -333,7 +361,7 @@
|
||||
<toolkit:TabbedCommandBarItem Header="{x:Bind domain:Translator.EditorToolbarOption_Insert}">
|
||||
<AppBarButton
|
||||
x:Name="FilesButton"
|
||||
Click="AddFilesClicked"
|
||||
Command="{x:Bind ViewModel.AttachFilesCommand}"
|
||||
Label="{x:Bind domain:Translator.Files}">
|
||||
<AppBarButton.Icon>
|
||||
<PathIcon Data="{StaticResource AttachPathIcon}" />
|
||||
@@ -402,7 +430,7 @@
|
||||
<!-- Mime Info -->
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Padding="16,0,16,10"
|
||||
Padding="16,0,16,4"
|
||||
ColumnSpacing="12"
|
||||
RowSpacing="3">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -550,15 +578,15 @@
|
||||
x:Name="AttachmentsListView"
|
||||
Grid.Row="5"
|
||||
Grid.ColumnSpan="2"
|
||||
ui:ListViewExtensions.Command="{x:Bind ViewModel.OpenAttachmentCommand}"
|
||||
x:Load="{x:Bind helpers:XamlHelpers.CountToBooleanConverter(ViewModel.IncludedAttachments.Count), Mode=OneWay}"
|
||||
IsItemClickEnabled="True"
|
||||
ItemClick="AttachmentClicked"
|
||||
ItemTemplate="{StaticResource ComposerFileAttachmentTemplate}"
|
||||
ItemsSource="{x:Bind ViewModel.IncludedAttachments, Mode=OneWay}"
|
||||
SelectionMode="None">
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<toolkit:WrapPanel Orientation="Horizontal" />
|
||||
<customcontrols:CustomWrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
</ListView>
|
||||
|
||||
@@ -17,7 +17,6 @@ using MimeKit;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
using Windows.Foundation;
|
||||
using Windows.Storage;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.ViewManagement.Core;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
@@ -28,7 +27,7 @@ using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Reader;
|
||||
using Wino.Extensions;
|
||||
using Wino.Core.UWP.Extensions;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Messaging.Client.Mails;
|
||||
using Wino.Messaging.Client.Shell;
|
||||
@@ -109,20 +108,6 @@ namespace Wino.Views
|
||||
});
|
||||
}
|
||||
|
||||
private async void AddFilesClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// TODO: Pick files
|
||||
var picker = new FileOpenPicker()
|
||||
{
|
||||
SuggestedStartLocation = PickerLocationId.Desktop
|
||||
};
|
||||
|
||||
picker.FileTypeFilter.Add("*");
|
||||
var files = await picker.PickMultipleFilesAsync();
|
||||
|
||||
await AttachFiles(files);
|
||||
}
|
||||
|
||||
private void OnComposeGridDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
ViewModel.IsDraggingOverComposerGrid = true;
|
||||
@@ -250,9 +235,9 @@ namespace Wino.Views
|
||||
// Convert files to MailAttachmentViewModel.
|
||||
foreach (var file in files)
|
||||
{
|
||||
var attachmentViewModel = await file.ToAttachmentViewModelAsync();
|
||||
var sharedFile = await file.ToSharedFileAsync();
|
||||
|
||||
ViewModel.IncludedAttachments.Add(attachmentViewModel);
|
||||
ViewModel.IncludedAttachments.Add(new MailAttachmentViewModel(sharedFile));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,14 +613,6 @@ namespace Wino.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void AttachmentClicked(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
if (e.ClickedItem is MailAttachmentViewModel attachmentViewModel)
|
||||
{
|
||||
ViewModel.RemoveAttachmentCommand.Execute(attachmentViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
private async void AddressBoxLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Automatically add current text as item if it is valid mail address.
|
||||
|
||||
@@ -238,7 +238,6 @@
|
||||
<Compile Include="Dialogs\SystemFolderConfigurationDialog.xaml.cs">
|
||||
<DependentUpon>SystemFolderConfigurationDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Extensions\MimeKitExtensions.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="MenuFlyouts\AccountSelectorFlyout.cs" />
|
||||
<Compile Include="MenuFlyouts\FolderOperationFlyout.cs" />
|
||||
@@ -623,7 +622,9 @@
|
||||
<Name>Windows Desktop Extensions for the UWP</Name>
|
||||
</SDKReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Extensions\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user