* Allow transparent background color in SwipeView * Update Xamarin.Forms.Controls.Issues.Shared.projitems Co-authored-by: Rui Marinho <me@ruimarinho.net>
This commit is contained in:
Родитель
c5e3a46dae
Коммит
515c4553db
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<controls:TestContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls"
|
||||
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.Issue9305">
|
||||
<ContentPage.Content>
|
||||
<Grid>
|
||||
<Image
|
||||
Aspect="AspectFill"
|
||||
Source="Fruits.jpg"/>
|
||||
<StackLayout>
|
||||
<SwipeView>
|
||||
<SwipeView.LeftItems>
|
||||
<SwipeItems>
|
||||
<SwipeItem
|
||||
Text="Favorite"
|
||||
BackgroundColor="LightGreen" />
|
||||
<SwipeItem
|
||||
Text="Delete"
|
||||
BackgroundColor="LightPink" />
|
||||
</SwipeItems>
|
||||
</SwipeView.LeftItems>
|
||||
<Grid
|
||||
HeightRequest="60"
|
||||
WidthRequest="300">
|
||||
<Label
|
||||
Text="Swipe right"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center" />
|
||||
</Grid>
|
||||
</SwipeView>
|
||||
<SwipeView
|
||||
BackgroundColor="Transparent">
|
||||
<SwipeView.LeftItems>
|
||||
<SwipeItems>
|
||||
<SwipeItem
|
||||
Text="Favorite"
|
||||
BackgroundColor="LightGreen" />
|
||||
<SwipeItem
|
||||
Text="Delete"
|
||||
BackgroundColor="LightPink" />
|
||||
</SwipeItems>
|
||||
</SwipeView.LeftItems>
|
||||
<Grid
|
||||
HeightRequest="60"
|
||||
WidthRequest="300">
|
||||
<Label
|
||||
Text="Swipe right"
|
||||
HorizontalOptions="Center"
|
||||
VerticalOptions="Center" />
|
||||
</Grid>
|
||||
</SwipeView>
|
||||
</StackLayout>
|
||||
</Grid>
|
||||
</ContentPage.Content>
|
||||
</controls:TestContentPage>
|
|
@ -0,0 +1,29 @@
|
|||
using Xamarin.Forms.CustomAttributes;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Issue(IssueTracker.Github, 9305, "Swipe View BackgroundColor Issues", PlatformAffected.Android | PlatformAffected.iOS)]
|
||||
public partial class Issue9305 : TestContentPage
|
||||
{
|
||||
public Issue9305()
|
||||
{
|
||||
#if APP
|
||||
Device.SetFlags(new List<string> { ExperimentalFlags.SwipeViewExperimental });
|
||||
Title = "Issue 9305";
|
||||
InitializeComponent();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1268,6 +1268,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue8777.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue9588.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue9329.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue9305.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue9767.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1418,6 +1419,10 @@
|
|||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue8326.xaml" />
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue8449.xaml" />
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue7924.xaml" />
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue9305.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue9588.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
|
@ -1834,4 +1839,4 @@
|
|||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
public class SwipeViewRenderer : ViewRenderer<SwipeView, AView>, GestureDetector.IOnGestureListener
|
||||
{
|
||||
const int SwipeThreshold = 250;
|
||||
const int SwipeThresholdMargin = 0;
|
||||
const int SwipeItemWidth = 100;
|
||||
const long SwipeAnimationDuration = 200;
|
||||
const float SwipeMinimumDelta = 10f;
|
||||
|
@ -141,7 +140,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
SetBackgroundColor(backgroundColor);
|
||||
|
||||
if (Element.Content == null)
|
||||
if (Element.Content == null || (Element.Content != null && Element.Content.BackgroundColor == Color.Default))
|
||||
_contentView?.SetBackgroundColor(backgroundColor);
|
||||
}
|
||||
else
|
||||
|
@ -578,7 +577,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
void UpdateSwipeItems()
|
||||
{
|
||||
if (_contentView == null)
|
||||
if (_contentView == null || _actionView != null)
|
||||
return;
|
||||
|
||||
var items = GetSwipeItemsByDirection();
|
||||
|
@ -730,7 +729,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
{
|
||||
if (_actionView != null)
|
||||
{
|
||||
RemoveView(_actionView);
|
||||
_actionView.RemoveFromParent();
|
||||
_actionView.Dispose();
|
||||
_actionView = null;
|
||||
}
|
||||
|
@ -1019,13 +1018,13 @@ namespace Xamarin.Forms.Platform.Android
|
|||
if (swipeThreshold > contentWidth)
|
||||
swipeThreshold = contentWidth;
|
||||
|
||||
return swipeThreshold - SwipeThresholdMargin;
|
||||
return swipeThreshold;
|
||||
}
|
||||
|
||||
if (swipeThreshold > contentHeight)
|
||||
swipeThreshold = contentHeight;
|
||||
|
||||
return swipeThreshold - SwipeThresholdMargin / 2;
|
||||
return swipeThreshold;
|
||||
}
|
||||
|
||||
Size GetSwipeItemSize(ISwipeItem swipeItem)
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
public class SwipeViewRenderer : ViewRenderer<SwipeView, UIView>
|
||||
{
|
||||
const double SwipeThreshold = 250;
|
||||
const int SwipeThresholdMargin = 0;
|
||||
const double SwipeItemWidth = 100;
|
||||
const double SwipeAnimationDuration = 0.2;
|
||||
const double SwipeMinimumDelta = 10;
|
||||
|
@ -148,7 +147,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
{
|
||||
BackgroundColor = Element.BackgroundColor.ToUIColor();
|
||||
|
||||
if (_contentView != null && Element.Content == null)
|
||||
if (_contentView != null && (Element.Content == null || (Element.Content != null && Element.Content.BackgroundColor == Color.Default)))
|
||||
_contentView.BackgroundColor = Element.BackgroundColor.ToUIColor();
|
||||
}
|
||||
else
|
||||
|
@ -916,13 +915,13 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
if (swipeThreshold > _contentView.Frame.Width)
|
||||
swipeThreshold = _contentView.Frame.Width;
|
||||
|
||||
return swipeThreshold - SwipeThresholdMargin;
|
||||
return swipeThreshold;
|
||||
}
|
||||
|
||||
if (swipeThreshold > _contentView.Frame.Height)
|
||||
swipeThreshold = _contentView.Frame.Height;
|
||||
|
||||
return swipeThreshold - SwipeThresholdMargin / 2;
|
||||
return swipeThreshold;
|
||||
}
|
||||
|
||||
Size GetSwipeItemSize(ISwipeItem swipeItem)
|
||||
|
|
Загрузка…
Ссылка в новой задаче