Skip to content

Commit

Permalink
feat: create EditMessageControl
Browse files Browse the repository at this point in the history
References: Eppie-io#382
  • Loading branch information
al-kau committed Nov 4, 2024
1 parent 05890bf commit 293ce01
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 19 deletions.
19 changes: 4 additions & 15 deletions source/Eppie.App/Eppie.App.Shared/Views/NewMessagePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:android="http://uno.ui/android"
xmlns:behaviors="using:Tuvi.App.Shared.Behaviors"
xmlns:controls="using:Tuvi.App.Shared.Controls"
xmlns:eppie_controls="using:Eppie.App.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:entities="using:Tuvi.Core.Entities"
xmlns:extensions="using:Tuvi.App.Shared.Extensions"
Expand Down Expand Up @@ -235,21 +236,9 @@
BorderBrush="#FFE0E0E0"
BorderThickness="1">

<!-- ToDo: controls:RichTextEditor is off (now only uwp) -->
<!--<win:Grid>
<controls:RichTextEditor Text="{x:Bind ViewModel.TextBody, Mode=TwoWay}"
Html="{x:Bind ViewModel.HtmlBody, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.LoadingContent, Mode=OneWay, Converter={StaticResource InverseBoolConverter}}" />
</win:Grid>-->

<xamarin:WebView HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
android:IsTapEnabled="True"
android:Tapped="OnEmailBodyTapped"
extensions:WebViewExtension.StringSource="{x:Bind ViewModel.HtmlBody, Mode=OneWay}"
ios:IsTapEnabled="True"
ios:Tapped="OnEmailBodyTapped"
IsEnabled="{x:Bind ViewModel.LoadingContent, Mode=OneWay, Converter={StaticResource InverseBoolConverter}}" />
<eppie_controls:EditMessageControl Text="{x:Bind ViewModel.TextBody, Mode=TwoWay}"
Html="{x:Bind ViewModel.HtmlBody, Mode=TwoWay}"
IsEnabled="{x:Bind ViewModel.LoadingContent, Mode=OneWay, Converter={StaticResource InverseBoolConverter}}" />

</Grid>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
#else
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
#endif

namespace Eppie.App.UI.Controls
{
public sealed partial class EditMessageControl : UserControl
{
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}

public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(nameof(Text), typeof(string), typeof(MessageControl), new PropertyMetadata(null));

public string Html
{
get { return (string)GetValue(HtmlProperty); }
set { SetValue(HtmlProperty, value); }
}

public static readonly DependencyProperty HtmlProperty =
DependencyProperty.Register(nameof(Html), typeof(string), typeof(MessageControl), new PropertyMetadata(null));

public EditMessageControl()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\DecentralizedAccountSettingsControl.xaml.cs">
<DependentUpon>DecentralizedAccountSettingsControl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Controls\EditMessageControl.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\EmailProvidersListControl.xaml.cs">
<DependentUpon>EmailProvidersListControl.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -62,7 +63,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\ProtonAccountSettingsControl.xaml.cs">
<DependentUpon>ProtonAccountSettingsControl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Controls\RichTextEditor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\BitmapSourceConverters.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\BoolToValueConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\ConverterChain.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<UserControl x:Class="Eppie.App.UI.Controls.EditMessageControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Eppie.App.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">

<Grid>
<local:RichTextEditor Html="{x:Bind Html, Mode=TwoWay}"
Text="{x:Bind Text, Mode=TwoWay}" />

</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#if WINDOWS_UWP
using Tuvi.App.Shared.Extensions;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Tuvi.App.Shared.Controls
namespace Eppie.App.UI.Controls
{
public class RichTextEditor : RichEditBox
{
Expand Down Expand Up @@ -72,4 +71,3 @@ private void UpdateDocumentAsText(string text)
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="Controls\RichTextEditor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Eppie.App.UI.UWP.rd.xml" />
</ItemGroup>
Expand All @@ -121,6 +122,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Controls\EditMessageControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\MessageControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<UserControl x:Class="Eppie.App.UI.Controls.EditMessageControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Eppie.App.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">

<Grid>

<!-- ToDo: Control is not implemented -->
<!-- WebView2 should be used in WinUI and WebAssembly -->

<!--<xamarin:WebView HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
android:IsTapEnabled="True"
android:Tapped="OnEmailBodyTapped"
extensions:WebViewExtension.StringSource="{x:Bind ViewModel.HtmlBody, Mode=OneWay}"
ios:IsTapEnabled="True"
ios:Tapped="OnEmailBodyTapped"
IsEnabled="{x:Bind ViewModel.LoadingContent, Mode=OneWay, Converter={StaticResource InverseBoolConverter}}" />-->

<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Not Implemented"
TextAlignment="Center" />
</Grid>
</UserControl>

0 comments on commit 293ce01

Please sign in to comment.