iOS: Setting FormattedText doesn't use TextDecorations (#5803)
authorAndrei Nitescu <nitescua@yahoo.com>
Wed, 29 May 2019 00:50:52 +0000 (03:50 +0300)
committerSamantha Houts <samhouts@users.noreply.github.com>
Wed, 29 May 2019 00:50:52 +0000 (17:50 -0700)
fixes #5801

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5801.xaml [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5801.xaml.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.iOS/Renderers/LabelRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5801.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5801.xaml
new file mode 100644 (file)
index 0000000..aa2493c
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="Xamarin.Forms.Controls.Issues.Issue5801">
+    <StackLayout Padding="50, 100">
+        <Label Text="When switch sets Label's FormattedText, text should have the strikethrough."/>
+        <Switch x:Name="_switch" />
+        <Label TextDecorations="Strikethrough">
+            <Label.Triggers>
+                <DataTrigger TargetType="Label"
+                             Binding="{Binding IsToggled, Source={x:Reference _switch}}"
+                             Value="True">
+                    <Setter Property="FormattedText">
+                        <FormattedString>
+                            <Span Text="This is test text" />
+                        </FormattedString>
+                    </Setter>
+                </DataTrigger>
+            </Label.Triggers>
+        </Label>
+    </StackLayout>
+</ContentPage>  
\ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5801.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue5801.xaml.cs
new file mode 100644 (file)
index 0000000..ed17515
--- /dev/null
@@ -0,0 +1,18 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Controls.Issues
+{
+#if APP
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Github, 5801, "TextDecorations Strikethrough not called for FormattedText in iOS", PlatformAffected.iOS)]
+
+       public partial class Issue5801 : ContentPage
+       {
+               public Issue5801 ()
+               {
+                       InitializeComponent ();
+               }
+       }
+#endif
+}
\ No newline at end of file
index bdd2727..231b507 100644 (file)
       <DependentUpon>Issue5003.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="$(MSBuildThisFileDirectory)Issue5801.xaml.cs">
+      <DependentUpon>Issue5801.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)Issue5695.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue5535.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue5949.cs" />
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue5801.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </EmbeddedResource>
     <EmbeddedResource Include="$(MSBuildThisFileDirectory)A11yTabIndex.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
index b0424ef..6b1ca8d 100644 (file)
@@ -194,7 +194,10 @@ namespace Xamarin.Forms.Platform.MacOS
                        else if (e.PropertyName == Label.TextDecorationsProperty.PropertyName)
                                UpdateTextDecorations();
                        else if (e.PropertyName == Label.FormattedTextProperty.PropertyName)
+                       {
                                UpdateText();
+                               UpdateTextDecorations();
+                       }
                        else if (e.PropertyName == Label.LineBreakModeProperty.PropertyName)
                                UpdateLineBreakMode();
                        else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)