* Allow to use SwipeItem only with text or icon * Updated Issue8777 to include Android platform
This commit is contained in:
Родитель
d0c772c2be
Коммит
9cdc2c1379
|
@ -0,0 +1,75 @@
|
|||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
#if UITEST
|
||||
[Category(UITestCategories.SwipeView)]
|
||||
#endif
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 8777, "SwipeView crash if Text not is set on SwipeItem", PlatformAffected.iOS | PlatformAffected.Android)]
|
||||
public class Issue8777 : TestContentPage
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
Title = "Issue 8777";
|
||||
|
||||
var layout = new StackLayout
|
||||
{
|
||||
Margin = new Thickness(12)
|
||||
};
|
||||
|
||||
var instructions = new Label
|
||||
{
|
||||
BackgroundColor = Color.Black,
|
||||
TextColor = Color.White,
|
||||
Text = "Swipe to the right, if can open the SwipeView the test has passed."
|
||||
};
|
||||
|
||||
var swipeItem = new SwipeItem
|
||||
{
|
||||
BackgroundColor = Color.Red,
|
||||
IconImageSource = "calculator.png"
|
||||
};
|
||||
|
||||
swipeItem.Invoked += (sender, e) => { DisplayAlert("SwipeView", "Invoked", "Ok"); };
|
||||
|
||||
var swipeItems = new SwipeItems { swipeItem };
|
||||
|
||||
swipeItems.Mode = SwipeMode.Reveal;
|
||||
|
||||
var swipeContent = new Grid
|
||||
{
|
||||
BackgroundColor = Color.Gray
|
||||
};
|
||||
|
||||
var swipeLabel = new Label
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
Text = "Swipe to Right (No Text)"
|
||||
};
|
||||
|
||||
swipeContent.Children.Add(swipeLabel);
|
||||
|
||||
var swipeView = new SwipeView
|
||||
{
|
||||
HeightRequest = 60,
|
||||
WidthRequest = 300,
|
||||
LeftItems = swipeItems,
|
||||
Content = swipeContent
|
||||
};
|
||||
|
||||
layout.Children.Add(instructions);
|
||||
layout.Children.Add(swipeView);
|
||||
|
||||
Content = layout;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1242,6 +1242,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue8973.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue7924.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue8461.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue8777.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
|
||||
|
|
|
@ -598,7 +598,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
var swipeButton = new AButton(_context)
|
||||
{
|
||||
Background = new ColorDrawable(formsSwipeItem.BackgroundColor.ToAndroid()),
|
||||
Text = formsSwipeItem.Text
|
||||
Text = formsSwipeItem.Text ?? string.Empty
|
||||
};
|
||||
|
||||
var textColor = GetSwipeItemColor(formsSwipeItem.BackgroundColor);
|
||||
|
@ -616,7 +616,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
swipeButton.SetCompoundDrawables(null, drawable, null, null);
|
||||
});
|
||||
|
||||
var textSize = !string.IsNullOrEmpty(formsSwipeItem.Text) ? (int)swipeButton.TextSize : 0;
|
||||
var textSize = !string.IsNullOrEmpty(swipeButton.Text) ? (int)swipeButton.TextSize : 0;
|
||||
var buttonPadding = (contentHeight - (iconSize + textSize + 6)) / 2;
|
||||
swipeButton.SetPadding(0, buttonPadding, 0, buttonPadding);
|
||||
swipeButton.SetOnTouchListener(null);
|
||||
|
|
Загрузка…
Ссылка в новой задаче