* Added repro sample * Fixed issue with default SwipeView BackgroundColor on iOS * Updated the sample * Avoid to set the Content BackgroundColor updating the SwipeView BackgroundColor * Fixed build error * Fixed build error * Fix build error Co-authored-by: Rui Marinho <me@ruimarinho.net>
This commit is contained in:
Родитель
6c88a4c957
Коммит
1b495da2c5
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<controls:TestContentPage
|
||||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
x:Class="Xamarin.Forms.Controls.Issues.Issue11831"
|
||||
x:Name="Issue11831Page"
|
||||
Title="Issue 11831">
|
||||
<controls:TestContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
<Style x:Key="CollectionSwipeSelectedStyle" TargetType="SwipeView">
|
||||
<Setter Property="VisualStateManager.VisualStateGroups">
|
||||
<VisualStateGroupList>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="Selected">
|
||||
<VisualState.Setters>
|
||||
<Setter Property="BackgroundColor" Value="Green" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateGroupList>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
</controls:TestContentPage.Resources>
|
||||
<Grid
|
||||
RowSpacing="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label
|
||||
Padding="12"
|
||||
BackgroundColor="Black"
|
||||
TextColor="White"
|
||||
Text="Select am item from the list. If the selection background color is green, the test has passed."/>
|
||||
<Grid
|
||||
Grid.Row="1">
|
||||
<CollectionView
|
||||
x:Name="DataListView"
|
||||
SelectionMode="Single"
|
||||
ItemsSource="{Binding Data}">
|
||||
<CollectionView.ItemTemplate>
|
||||
<DataTemplate x:DataType="x:String">
|
||||
<SwipeView
|
||||
BackgroundColor="Red"
|
||||
Style="{StaticResource CollectionSwipeSelectedStyle}">
|
||||
<SwipeView.RightItems>
|
||||
<SwipeItems>
|
||||
<SwipeItemView
|
||||
Command="{Binding BindingContext.DeleteCommand, Source={x:Reference Issue11831Page}}"
|
||||
CommandParameter="{Binding}">
|
||||
<Grid
|
||||
BackgroundColor="LightSlateGray">
|
||||
<Frame
|
||||
BackgroundColor="#de3f45"
|
||||
BorderColor="White"
|
||||
Margin="8"
|
||||
Padding="10"
|
||||
CornerRadius="5">
|
||||
<StackLayout
|
||||
Orientation="Vertical"
|
||||
VerticalOptions="Center"
|
||||
HorizontalOptions="Center">
|
||||
<Label
|
||||
Text="Delete"
|
||||
TextColor="White"
|
||||
FontSize="Medium"
|
||||
FontAttributes="Bold"
|
||||
LineBreakMode="NoWrap"
|
||||
WidthRequest="64"
|
||||
HorizontalTextAlignment="Center" />
|
||||
</StackLayout>
|
||||
</Frame>
|
||||
</Grid>
|
||||
</SwipeItemView>
|
||||
</SwipeItems>
|
||||
</SwipeView.RightItems>
|
||||
<Frame
|
||||
Padding="1"
|
||||
BorderColor="Silver"
|
||||
BackgroundColor="WhiteSmoke"
|
||||
HeightRequest="60"
|
||||
CornerRadius="12">
|
||||
<Label
|
||||
Text="{Binding}"
|
||||
TextColor="Black"
|
||||
FontAttributes="Bold"
|
||||
FontSize="Medium"
|
||||
HorizontalTextAlignment="Center"
|
||||
VerticalOptions="Center"/>
|
||||
</Frame>
|
||||
</SwipeView>
|
||||
</DataTemplate>
|
||||
</CollectionView.ItemTemplate>
|
||||
</CollectionView>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</controls:TestContentPage>
|
|
@ -0,0 +1,53 @@
|
|||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.Xaml;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using System;
|
||||
|
||||
#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.SwipeView)]
|
||||
#endif
|
||||
#if APP
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
#endif
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 11831, "[Bug] SwipeView removes Frame borders on Android", PlatformAffected.Android)]
|
||||
public partial class Issue11831 : TestContentPage
|
||||
{
|
||||
public Issue11831()
|
||||
{
|
||||
#if APP
|
||||
Title = "Issue 11831";
|
||||
InitializeComponent();
|
||||
|
||||
var random = new Random();
|
||||
for (var i = 0; i < 16; i++)
|
||||
Data.Add($"Entry #{i + 1} - {random.Next(0, 999999)}");
|
||||
|
||||
DeleteCommand = new Command<string>(input => DisplayAlert("Delete entry", $"Delete: {input}", "OK"));
|
||||
|
||||
BindingContext = this;
|
||||
#endif
|
||||
}
|
||||
|
||||
public ObservableCollection<string> Data { get; } = new ObservableCollection<string>();
|
||||
|
||||
public ICommand DeleteCommand { get; }
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1587,6 +1587,7 @@
|
|||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue11869.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue11723.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue11831.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue11496.xaml.cs" >
|
||||
<DependentUpon>Issue11496.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -1900,6 +1901,9 @@
|
|||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11209.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11831.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11081.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
|
|
|
@ -76,8 +76,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
UpdateContent();
|
||||
UpdateIsSwipeEnabled();
|
||||
UpdateSwipeTransitionMode();
|
||||
UpdateBackgroundColor();
|
||||
UpdateBackground();
|
||||
}
|
||||
|
||||
if (e.OldElement != null)
|
||||
|
@ -100,10 +98,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
if (e.PropertyName == ContentView.ContentProperty.PropertyName)
|
||||
UpdateContent();
|
||||
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
|
||||
UpdateBackgroundColor();
|
||||
else if (e.PropertyName == VisualElement.BackgroundProperty.PropertyName)
|
||||
UpdateBackground();
|
||||
else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
|
||||
UpdateIsSwipeEnabled();
|
||||
else if (e.PropertyName == Specifics.SwipeTransitionModeProperty.PropertyName)
|
||||
|
@ -137,29 +131,19 @@ namespace Xamarin.Forms.Platform.Android
|
|||
protected override void UpdateBackgroundColor()
|
||||
{
|
||||
if (Element.BackgroundColor != Color.Default)
|
||||
{
|
||||
var backgroundColor = Element.BackgroundColor.ToAndroid();
|
||||
|
||||
SetBackgroundColor(backgroundColor);
|
||||
|
||||
if (Element.Content == null || (Element.Content != null && Element.Content.BackgroundColor == Color.Default))
|
||||
_contentView?.SetBackgroundColor(backgroundColor);
|
||||
}
|
||||
SetBackgroundColor(Element.BackgroundColor.ToAndroid());
|
||||
else
|
||||
Control.SetWindowBackground();
|
||||
|
||||
if (_contentView != null && _contentView.Background == null)
|
||||
_contentView?.SetWindowBackground();
|
||||
Control?.SetWindowBackground();
|
||||
}
|
||||
|
||||
protected override void UpdateBackground()
|
||||
{
|
||||
Brush background = Element.Background;
|
||||
|
||||
this.UpdateBackground(background);
|
||||
if (Brush.IsNullOrEmpty(background))
|
||||
return;
|
||||
|
||||
if (Element.Content == null)
|
||||
_contentView?.UpdateBackground(background);
|
||||
this.UpdateBackground(background);
|
||||
}
|
||||
|
||||
protected override void OnAttachedToWindow()
|
||||
|
|
|
@ -87,7 +87,6 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
UpdateContent();
|
||||
UpdateIsSwipeEnabled();
|
||||
UpdateSwipeTransitionMode();
|
||||
SetBackgroundColor(Element.BackgroundColor);
|
||||
}
|
||||
|
||||
if (e.OldElement != null)
|
||||
|
@ -152,10 +151,6 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
|
||||
if (e.PropertyName == ContentView.ContentProperty.PropertyName)
|
||||
UpdateContent();
|
||||
else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
|
||||
SetBackgroundColor(Element.BackgroundColor);
|
||||
else if (e.PropertyName == VisualElement.BackgroundProperty.PropertyName)
|
||||
SetBackground(Element.Background);
|
||||
else if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
|
||||
UpdateIsSwipeEnabled();
|
||||
else if (e.PropertyName == Specifics.SwipeTransitionModeProperty.PropertyName)
|
||||
|
@ -164,31 +159,21 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
|
||||
protected override void SetBackgroundColor(Color color)
|
||||
{
|
||||
UIColor backgroundColor = ColorExtensions.BackgroundColor;
|
||||
|
||||
if (Element.BackgroundColor != Color.Default)
|
||||
{
|
||||
BackgroundColor = Element.BackgroundColor.ToUIColor();
|
||||
|
||||
if (_contentView != null && (Element.Content == null || (Element.Content != null && Element.Content.BackgroundColor == Color.Default)))
|
||||
_contentView.BackgroundColor = Element.BackgroundColor.ToUIColor();
|
||||
}
|
||||
else
|
||||
BackgroundColor = backgroundColor;
|
||||
|
||||
if (_contentView != null && _contentView.BackgroundColor == UIColor.Clear)
|
||||
_contentView.BackgroundColor = backgroundColor;
|
||||
BackgroundColor = ColorExtensions.BackgroundColor;
|
||||
}
|
||||
|
||||
protected override void SetBackground(Brush brush)
|
||||
{
|
||||
Brush background = Element.Background;
|
||||
|
||||
if (Brush.IsNullOrEmpty(background))
|
||||
return;
|
||||
|
||||
if (Control != null)
|
||||
Control.UpdateBackground(background);
|
||||
|
||||
if (_contentView != null && Element.Content == null && HasSwipeItems())
|
||||
_contentView.UpdateBackground(background);
|
||||
}
|
||||
|
||||
public override void TouchesEnded(NSSet touches, UIEvent evt)
|
||||
|
|
Загрузка…
Ссылка в новой задаче