Emaıl templates.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user