зеркало из https://github.com/DeGsoft/maui-linux.git
* fix textview flow direction * removed Details from model * Update Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7512.xaml.cs Co-Authored-By: Rui Marinho <me@ruimarinho.net>
This commit is contained in:
Родитель
64c13df471
Коммит
782229fa99
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<controls:TestContentPage
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
|
||||
x:Class="Xamarin.Forms.Controls.Issues.Issue7512">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackLayout Orientation="Vertical" Spacing="5" Grid.Row="0" VerticalOptions="Center" BackgroundColor="Beige">
|
||||
<Label LineBreakMode="WordWrap" Margin="10,0" Text="Verify that when you switch to RTL, images are placed on the right side of the screen and labels are right aligned so that the last character of each label is immediately next to an image." HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
<Label LineBreakMode="WordWrap" Margin="10,0" Text="Verify that when you switch to LTR, images are placed on the left side of the screen and labels are left aligned so that the first character of each label is immediately next to an image." HorizontalTextAlignment="Center" VerticalTextAlignment="Center"/>
|
||||
<Button Text="Switch to RTL" HorizontalOptions="Center" VerticalOptions="Center" Clicked="HandleButtonClick"/>
|
||||
</StackLayout>
|
||||
|
||||
<CollectionView Grid.Row="1" ItemsSource="{Binding Monkeys}" FlowDirection="LeftToRight">
|
||||
<CollectionView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Padding="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image Grid.RowSpan="2"
|
||||
Source="{Binding ImageUrl}"
|
||||
Aspect="AspectFill"
|
||||
HeightRequest="60"
|
||||
WidthRequest="60" />
|
||||
<Label Grid.Column="1"
|
||||
Text="{Binding Name}"
|
||||
FontAttributes="Bold" BackgroundColor="Red" />
|
||||
<Label Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Text="{Binding Location}"
|
||||
FontAttributes="Italic"
|
||||
VerticalOptions="End" BackgroundColor="Yellow" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</CollectionView.ItemTemplate>
|
||||
</CollectionView>
|
||||
</Grid>
|
||||
</controls:TestContentPage>
|
|
@ -0,0 +1,204 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using System;
|
||||
using Xamarin.Forms.Xaml;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.UITest;
|
||||
using Xamarin.UITest.Queries;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
#if UITEST
|
||||
[NUnit.Framework.Category(UITestCategories.CollectionView)]
|
||||
#endif
|
||||
#if APP
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
#endif
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 7512, "RTL CollectionView looks odd", PlatformAffected.Android)]
|
||||
public partial class Issue7512 : TestContentPage
|
||||
{
|
||||
bool isRTL = false;
|
||||
|
||||
#if APP
|
||||
public Issue7512()
|
||||
{
|
||||
Device.SetFlags(new List<string> { CollectionView.CollectionViewExperimental });
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = new ViewModel7512();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HandleButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
var button = sender as Button;
|
||||
var stackLayout = button.Parent as StackLayout;
|
||||
var grid = stackLayout.Parent as Grid;
|
||||
var collectionView = grid.Children[1] as CollectionView;
|
||||
|
||||
isRTL = !isRTL;
|
||||
|
||||
button.Text = isRTL ? "Switch to LTR" : "Switch to RTL";
|
||||
collectionView.FlowDirection = isRTL ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
|
||||
}
|
||||
}
|
||||
|
||||
[Preserve(AllMembers = true)]
|
||||
public class ViewModel7512
|
||||
{
|
||||
public ObservableCollection<Model7512> Monkeys { get; private set; }
|
||||
|
||||
public ViewModel7512()
|
||||
{
|
||||
Monkeys = CreateMonkeyCollection();
|
||||
}
|
||||
|
||||
ObservableCollection<Model7512> CreateMonkeyCollection()
|
||||
{
|
||||
var source = new ObservableCollection<Model7512>();
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Baboon",
|
||||
Location = "Africa & Asia",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Papio_anubis_%28Serengeti%2C_2009%29.jpg/200px-Papio_anubis_%28Serengeti%2C_2009%29.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Capuchin Monkey",
|
||||
Location = "Central & South America",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Blue Monkey",
|
||||
Location = "Central and East Africa",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/83/BlueMonkey.jpg/220px-BlueMonkey.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Squirrel Monkey",
|
||||
Location = "Central & South America",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Saimiri_sciureus-1_Luc_Viatour.jpg/220px-Saimiri_sciureus-1_Luc_Viatour.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Golden Lion Tamarin",
|
||||
Location = "Brazil",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/87/Golden_lion_tamarin_portrait3.jpg/220px-Golden_lion_tamarin_portrait3.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Howler Monkey",
|
||||
Location = "South America",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Alouatta_guariba.jpg/200px-Alouatta_guariba.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Japanese Macaque",
|
||||
Location = "Japan",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Macaca_fuscata_fuscata1.jpg/220px-Macaca_fuscata_fuscata1.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Mandrill",
|
||||
Location = "Southern Cameroon, Gabon, Equatorial Guinea, and Congo",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/7/75/Mandrill_at_san_francisco_zoo.jpg/220px-Mandrill_at_san_francisco_zoo.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Proboscis Monkey",
|
||||
Location = "Borneo",
|
||||
ImageUrl = "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Proboscis_Monkey_in_Borneo.jpg/250px-Proboscis_Monkey_in_Borneo.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Red-shanked Douc",
|
||||
Location = "Vietnam, Laos",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/Portrait_of_a_Douc.jpg/159px-Portrait_of_a_Douc.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Gray-shanked Douc",
|
||||
Location = "Vietnam",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Cuc.Phuong.Primate.Rehab.center.jpg/320px-Cuc.Phuong.Primate.Rehab.center.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Golden Snub-nosed Monkey",
|
||||
Location = "China",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Golden_Snub-nosed_Monkeys%2C_Qinling_Mountains_-_China.jpg/165px-Golden_Snub-nosed_Monkeys%2C_Qinling_Mountains_-_China.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Black Snub-nosed Monkey",
|
||||
Location = "China",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/RhinopitecusBieti.jpg/320px-RhinopitecusBieti.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Tonkin Snub-nosed Monkey",
|
||||
Location = "Vietnam",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9c/Tonkin_snub-nosed_monkeys_%28Rhinopithecus_avunculus%29.jpg/320px-Tonkin_snub-nosed_monkeys_%28Rhinopithecus_avunculus%29.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Thomas's Langur",
|
||||
Location = "Indonesia",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Thomas%27s_langur_Presbytis_thomasi.jpg/142px-Thomas%27s_langur_Presbytis_thomasi.jpg"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Purple-faced Langur",
|
||||
Location = "Sri Lanka",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Semnopithèque_blanchâtre_mâle.JPG/192px-Semnopithèque_blanchâtre_mâle.JPG"
|
||||
});
|
||||
|
||||
source.Add(new Model7512
|
||||
{
|
||||
Name = "Gelada",
|
||||
Location = "Ethiopia",
|
||||
ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Gelada-Pavian.jpg/320px-Gelada-Pavian.jpg"
|
||||
});
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
[Preserve(AllMembers = true)]
|
||||
public class Model7512
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Location { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
}
|
||||
}
|
|
@ -45,6 +45,9 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue7357.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue7512.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue7519.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue7519Xaml.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
|
@ -1396,6 +1399,9 @@
|
|||
<Compile Update="$(MSBuildThisFileDirectory)Issue7621.xaml.cs">
|
||||
<DependentUpon>Issue7621.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="$(MSBuildThisFileDirectory)Issue7512.xaml.cs">
|
||||
<DependentUpon>Issue7512.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue1455.xaml">
|
||||
|
@ -1439,7 +1445,13 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue7512.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue5354.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Android.OS;
|
||||
using Android.Widget;
|
||||
using ALayoutDirection = Android.Views.LayoutDirection;
|
||||
using ATextDirection = Android.Views.TextDirection;
|
||||
using AView = Android.Views.View;
|
||||
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
internal static class FlowDirectionExtensions
|
||||
|
@ -27,9 +27,19 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
// if android:targetSdkVersion < 17 setting these has no effect
|
||||
if (controller.EffectiveFlowDirection.IsRightToLeft())
|
||||
{
|
||||
view.LayoutDirection = ALayoutDirection.Rtl;
|
||||
|
||||
if (view is TextView textView)
|
||||
textView.TextDirection = ATextDirection.Rtl;
|
||||
}
|
||||
else if (controller.EffectiveFlowDirection.IsLeftToRight())
|
||||
{
|
||||
view.LayoutDirection = ALayoutDirection.Ltr;
|
||||
|
||||
if (view is TextView textView)
|
||||
textView.TextDirection = ATextDirection.Ltr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче