Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] FlowDirection property now has an effect on label controls #11596

Merged
merged 2 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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.Issue2447" FlowDirection="RightToLeft">
<ContentPage.Content>
<StackLayout>
<Label Text="English Text" FontSize="Large" FlowDirection="RightToLeft"/>
<Label Text="نووسینی کوردی" FontSize="Large" FlowDirection="RightToLeft" />
<Label Text="English Text" FontSize="Large" FlowDirection="LeftToRight"/>
<Label Text="نووسینی کوردی" FontSize="Large" FlowDirection="LeftToRight"/>
<Label Text="English Text" FontSize="Large"/>
<Label Text="نووسینی کوردی" FontSize="Large"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;
using System.Windows.Input;
using System.Diagnostics;

using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls.Issues
{

#if APP
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Github, 2447, "Force label text direction", PlatformAffected.Android)]
public partial class Issue2447 : ContentPage
{
public Issue2447 ()
{
InitializeComponent();
}
}
#endif
}
10 changes: 10 additions & 0 deletions Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
UpdateLineHeight();
UpdateGravity();
UpdateMaxLines();
UpdateFlowDirection();
}
else
{
Expand All @@ -134,6 +135,8 @@ protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
UpdateMaxLines();
if (e.OldElement.CharacterSpacing != e.NewElement.CharacterSpacing)
UpdateCharacterSpacing();
if (e.OldElement.FlowDirection != e.NewElement.FlowDirection)
UpdateFlowDirection();
}
UpdateTextDecorations();
UpdatePadding();
Expand Down Expand Up @@ -169,6 +172,13 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
UpdateMaxLines();
else if (e.PropertyName == Label.PaddingProperty.PropertyName)
UpdatePadding();
else if (e.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
UpdateFlowDirection();
}

void UpdateFlowDirection()
memu8 marked this conversation as resolved.
Show resolved Hide resolved
{
Control.UpdateFlowDirection(Element);
}

void UpdateColor()
Expand Down