Emaıl templates.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
using Wino.Mail.ViewModels;
|
||||
|
||||
namespace Wino.Views.Abstract;
|
||||
|
||||
public abstract class CreateEmailTemplatePageAbstract : SettingsPageBase<CreateEmailTemplatePageViewModel>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using Wino.Mail.ViewModels;
|
||||
|
||||
namespace Wino.Views.Abstract;
|
||||
|
||||
public abstract class EmailTemplatesPageAbstract : SettingsPageBase<EmailTemplatesPageViewModel>
|
||||
{
|
||||
}
|
||||
@@ -138,6 +138,21 @@
|
||||
CommandAlignment="Right"
|
||||
IsDynamicOverflowEnabled="True"
|
||||
OverflowButtonAlignment="Left">
|
||||
<AppBarElementContainer Visibility="{x:Bind helpers:XamlHelpers.CountToVisibilityConverter(ViewModel.AvailableEmailTemplates.Count), Mode=OneWay}">
|
||||
<ComboBox
|
||||
x:Name="EmailTemplatesComboBox"
|
||||
MinWidth="220"
|
||||
Margin="0,8,8,0"
|
||||
ItemsSource="{x:Bind ViewModel.AvailableEmailTemplates, Mode=OneWay}"
|
||||
PlaceholderText="{x:Bind domain:Translator.Composer_EmailTemplatesPlaceholder}"
|
||||
SelectionChanged="EmailTemplateSelectionChanged">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="mail:EmailTemplate">
|
||||
<TextBlock Text="{x:Bind Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</AppBarElementContainer>
|
||||
<AppBarButton
|
||||
MinWidth="40"
|
||||
HorizontalContentAlignment="Center"
|
||||
@@ -145,9 +160,7 @@
|
||||
Visibility="{x:Bind ViewModel.IsDraftBusy, Mode=OneWay}">
|
||||
<ProgressRing IsActive="True" />
|
||||
</AppBarButton>
|
||||
<AppBarButton
|
||||
Click="ToggleEditorThemeClicked"
|
||||
ToolTipService.ToolTip="{x:Bind GetEditorThemeToolTip(WebViewEditor.IsEditorDarkMode), Mode=OneWay}">
|
||||
<AppBarButton Click="ToggleEditorThemeClicked" ToolTipService.ToolTip="{x:Bind GetEditorThemeToolTip(WebViewEditor.IsEditorDarkMode), Mode=OneWay}">
|
||||
<AppBarButton.Icon>
|
||||
<coreControls:WinoFontIcon Icon="{x:Bind GetEditorThemeIcon(WebViewEditor.IsEditorDarkMode), Mode=OneWay}" />
|
||||
</AppBarButton.Icon>
|
||||
|
||||
@@ -18,6 +18,7 @@ using Windows.Foundation;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Core.Preview;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Models.Reader;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
@@ -53,6 +54,15 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
WebViewEditor.ToggleEditorTheme();
|
||||
}
|
||||
|
||||
private async void EmailTemplateSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (sender is not ComboBox comboBox || comboBox.SelectedItem is not EmailTemplate template)
|
||||
return;
|
||||
|
||||
await WebViewEditor.RenderHtmlAsync(template.HtmlContent);
|
||||
comboBox.SelectedItem = null;
|
||||
}
|
||||
|
||||
private async void GlobalFocusManagerGotFocus(object? sender, FocusManagerGotFocusEventArgs e)
|
||||
{
|
||||
// In order to delegate cursor to the inner editor for WebView2.
|
||||
|
||||
@@ -14,11 +14,14 @@
|
||||
|
||||
<ScrollViewer Padding="0,0,16,0" VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Margin="0,8,0,24" Spacing="4">
|
||||
<StackPanel.ChildrenTransitions>
|
||||
<!--<StackPanel.ChildrenTransitions>
|
||||
<TransitionCollection>
|
||||
<EntranceThemeTransition FromVerticalOffset="50" IsStaggeringEnabled="True" />
|
||||
<PopupThemeTransition />
|
||||
-->
|
||||
<!--<EntranceThemeTransition FromVerticalOffset="50" IsStaggeringEnabled="True" />-->
|
||||
<!--
|
||||
</TransitionCollection>
|
||||
</StackPanel.ChildrenTransitions>
|
||||
</StackPanel.ChildrenTransitions>-->
|
||||
|
||||
<!-- Hero Banner - Windows 11 style -->
|
||||
<Grid
|
||||
@@ -46,9 +49,7 @@
|
||||
Margin="20,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Spacing="4">
|
||||
<TextBlock
|
||||
Style="{StaticResource TitleTextBlockStyle}"
|
||||
Text="Wino Mail" />
|
||||
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Wino Mail" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
@@ -62,12 +63,8 @@
|
||||
Margin="0,8,0,0"
|
||||
Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<HyperlinkButton
|
||||
Content="{x:Bind ViewModel.WebsiteUrl, Mode=OneWay}"
|
||||
NavigateUri="{x:Bind ViewModel.WebsiteUrl, Mode=OneWay}" />
|
||||
<HyperlinkButton
|
||||
Content="{x:Bind domain:Translator.SettingsPaypal_Title}"
|
||||
NavigateUri="{x:Bind ViewModel.PaypalUrl, Mode=OneWay}" />
|
||||
<HyperlinkButton Content="{x:Bind ViewModel.WebsiteUrl, Mode=OneWay}" NavigateUri="{x:Bind ViewModel.WebsiteUrl, Mode=OneWay}" />
|
||||
<HyperlinkButton Content="{x:Bind domain:Translator.SettingsPaypal_Title}" NavigateUri="{x:Bind ViewModel.PaypalUrl, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@@ -194,6 +191,17 @@
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard
|
||||
Click="SettingOptionClicked"
|
||||
Description="{x:Bind domain:Translator.SettingsEmailTemplates_Description}"
|
||||
Header="{x:Bind domain:Translator.SettingsEmailTemplates_Title}"
|
||||
IsClickEnabled="True"
|
||||
Tag="{x:Bind enums:WinoPage.EmailTemplatesPage}">
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<FontIcon Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" Glyph="" />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard
|
||||
Click="SettingOptionClicked"
|
||||
Description="{x:Bind domain:Translator.SettingsStorage_Description}"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<abstract:CreateEmailTemplatePageAbstract
|
||||
x:Class="Wino.Views.Settings.CreateEmailTemplatePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:abstract="using:Wino.Views.Abstract"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
xmlns:helpers="using:Wino.Helpers"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mailControls="using:Wino.Mail.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid RowSpacing="12">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<controls:SettingsCard Grid.Row="0" Header="{x:Bind domain:Translator.SettingsEmailTemplates_NameTitle}" IsClickEnabled="False">
|
||||
<TextBox
|
||||
x:Name="TemplateNameTextBox"
|
||||
PlaceholderText="{x:Bind domain:Translator.SettingsEmailTemplates_NamePlaceholder}"
|
||||
Text="{x:Bind ViewModel.TemplateName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard Grid.Row="1" Header="{x:Bind domain:Translator.SettingsEmailTemplates_DescriptionTitle}" IsClickEnabled="False">
|
||||
<TextBox
|
||||
AcceptsReturn="True"
|
||||
PlaceholderText="{x:Bind domain:Translator.SettingsEmailTemplates_DescriptionPlaceholder}"
|
||||
Text="{x:Bind ViewModel.TemplateDescription, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<StackPanel Grid.Row="2" Spacing="8">
|
||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{x:Bind domain:Translator.SettingsEmailTemplates_ContentTitle}" />
|
||||
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}" Text="{x:Bind domain:Translator.SettingsEmailTemplates_ContentDescription}" />
|
||||
<mailControls:EditorTabbedCommandBarControl CommandTarget="{x:Bind WebViewEditor}" />
|
||||
<Border
|
||||
MinHeight="420"
|
||||
Background="{ThemeResource WinoContentZoneBackgroud}"
|
||||
BorderBrush="{StaticResource CardStrokeColorDefaultBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="7">
|
||||
<mailControls:WebViewEditorControl x:Name="WebViewEditor" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="3"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<Button
|
||||
Click="DeleteClicked"
|
||||
Content="{x:Bind domain:Translator.Buttons_Delete}"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Visibility="{x:Bind helpers:XamlHelpers.BoolToVisibilityConverter(ViewModel.IsExistingTemplate), Mode=OneWay}" />
|
||||
<Button
|
||||
Click="SaveClicked"
|
||||
Content="{x:Bind domain:Translator.Buttons_Save}"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</abstract:CreateEmailTemplatePageAbstract>
|
||||
@@ -0,0 +1,42 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using Wino.Views.Abstract;
|
||||
|
||||
namespace Wino.Views.Settings;
|
||||
|
||||
public sealed partial class CreateEmailTemplatePage : CreateEmailTemplatePageAbstract
|
||||
{
|
||||
public CreateEmailTemplatePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected async override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
var htmlContent = await ViewModel.LoadAsync(e.Parameter);
|
||||
await WebViewEditor.RenderHtmlAsync(htmlContent);
|
||||
|
||||
if (!ViewModel.IsExistingTemplate)
|
||||
{
|
||||
TemplateNameTextBox.Focus(FocusState.Programmatic);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
|
||||
{
|
||||
base.OnNavigatingFrom(e);
|
||||
WebViewEditor.Dispose();
|
||||
}
|
||||
|
||||
private async void SaveClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await ViewModel.SaveAsync(await WebViewEditor.GetHtmlBodyAsync() ?? string.Empty);
|
||||
}
|
||||
|
||||
private async void DeleteClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await ViewModel.DeleteAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<abstract:EmailTemplatesPageAbstract
|
||||
x:Class="Wino.Views.Settings.EmailTemplatesPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:abstract="using:Wino.Views.Abstract"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
xmlns:entities="using:Wino.Core.Domain.Entities.Mail"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<ScrollViewer>
|
||||
<StackPanel Spacing="{StaticResource SettingsCardSpacing}">
|
||||
<controls:SettingsCard
|
||||
Click="NewTemplateClicked"
|
||||
Description="{x:Bind domain:Translator.SettingsEmailTemplates_NewTemplateDescription}"
|
||||
Header="{x:Bind domain:Translator.SettingsEmailTemplates_NewTemplateTitle}"
|
||||
IsClickEnabled="True">
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<FontIcon Glyph="" />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
|
||||
<ItemsControl ItemsSource="{x:Bind ViewModel.EmailTemplates, Mode=OneWay}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="entities:EmailTemplate">
|
||||
<controls:SettingsCard
|
||||
Click="TemplateClicked"
|
||||
Description="{x:Bind Description}"
|
||||
Header="{x:Bind Name}"
|
||||
IsClickEnabled="True"
|
||||
Margin="0,0,0,4"
|
||||
Tag="{x:Bind}">
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<FontIcon Glyph="" />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
</controls:SettingsCard>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</abstract:EmailTemplatesPageAbstract>
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Views.Abstract;
|
||||
|
||||
namespace Wino.Views.Settings;
|
||||
|
||||
public sealed partial class EmailTemplatesPage : EmailTemplatesPageAbstract
|
||||
{
|
||||
public EmailTemplatesPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected async override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
await ViewModel.LoadAsync();
|
||||
}
|
||||
|
||||
private void NewTemplateClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.CreateTemplate();
|
||||
}
|
||||
|
||||
private void TemplateClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is FrameworkElement element && element.Tag is EmailTemplate template)
|
||||
{
|
||||
ViewModel.OpenTemplate(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,9 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
|
||||
case WinoPage.StoragePage:
|
||||
WeakReferenceMessenger.Default.Send(new BreadcrumbNavigationRequested(Translator.SettingsStorage_Title, WinoPage.StoragePage));
|
||||
break;
|
||||
case WinoPage.EmailTemplatesPage:
|
||||
WeakReferenceMessenger.Default.Send(new BreadcrumbNavigationRequested(Translator.SettingsEmailTemplates_Title, WinoPage.EmailTemplatesPage));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user