Skip to content

Commit e49e46a

Browse files
authored
SwipeItemView won't render FontImageSource on first opening - fix (dotnet#25397)
1 parent e3bf1ce commit e49e46a

File tree

7 files changed

+118
-0
lines changed

7 files changed

+118
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue18806"
5+
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
6+
<Grid RowDefinitions="*,Auto">
7+
<VerticalStackLayout>
8+
<SwipeView x:Name="swipeView1"
9+
Threshold="100">
10+
<SwipeView.RightItems>
11+
<SwipeItems>
12+
<SwipeItemView BackgroundColor="Black">
13+
<Image
14+
HorizontalOptions="Center"
15+
WidthRequest="10"
16+
VerticalOptions="Center">
17+
<Image.Source>
18+
<FontImageSource Color="White"
19+
Glyph="A"/>
20+
</Image.Source>
21+
</Image>
22+
</SwipeItemView>
23+
</SwipeItems>
24+
</SwipeView.RightItems>
25+
26+
<SwipeItemView>
27+
<Label HeightRequest="200"
28+
VerticalTextAlignment="Center"
29+
Text="Swipe view 1"/>
30+
</SwipeItemView>
31+
</SwipeView>
32+
33+
<SwipeView x:Name="swipeView2"
34+
Threshold="100">
35+
<SwipeView.LeftItems>
36+
<SwipeItems>
37+
<SwipeItemView BackgroundColor="Black">
38+
<Image
39+
HorizontalOptions="Center"
40+
WidthRequest="10"
41+
VerticalOptions="Center">
42+
<Image.Source>
43+
<FontImageSource Color="White"
44+
Glyph="A"/>
45+
</Image.Source>
46+
</Image>
47+
</SwipeItemView>
48+
</SwipeItems>
49+
</SwipeView.LeftItems>
50+
51+
<SwipeItemView>
52+
<Label HeightRequest="200"
53+
VerticalTextAlignment="Center"
54+
Text="Swipe view 2"/>
55+
</SwipeItemView>
56+
</SwipeView>
57+
</VerticalStackLayout>
58+
59+
<Button Grid.Row="1"
60+
AutomationId="button"
61+
Text="Open SwipeViews"
62+
Clicked="Button_Clicked"/>
63+
</Grid>
64+
</ContentPage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.ComponentModel;
2+
3+
namespace Maui.Controls.Sample.Issues
4+
{
5+
[Issue(IssueTracker.Github, 18806, "SwipeItemView won't render FontImageSource on first opening", PlatformAffected.Android)]
6+
public partial class Issue18806 : ContentPage
7+
{
8+
public Issue18806()
9+
{
10+
InitializeComponent();
11+
}
12+
13+
private void Button_Clicked(object sender, EventArgs e)
14+
{
15+
swipeView1.Open(OpenSwipeItem.RightItems, false);
16+
swipeView2.Open(OpenSwipeItem.LeftItems, false);
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue18806 : _IssuesUITest
8+
{
9+
public Issue18806(TestDevice testDevice) : base(testDevice)
10+
{
11+
}
12+
13+
public override string Issue => "SwipeItemView won't render FontImageSource on first opening";
14+
15+
[Test]
16+
[Category(UITestCategories.SwipeView)]
17+
public void ItemImageSourceShouldBeVisible()
18+
{
19+
App.WaitForElement("button");
20+
App.Tap("button");
21+
22+
VerifyScreenshot();
23+
}
24+
}
Loading

src/Core/src/Platform/Android/MauiSwipeView.cs

+10
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ protected override void OnAttachedToWindow()
7676
_viewPagerParent = Control.Parent.GetParentOfType<SwipeViewPager>();
7777
}
7878

79+
protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
80+
{
81+
base.OnLayout(changed, left, top, right, bottom);
82+
83+
if (_contentView is null || _actionView is null || GetNativeSwipeItems() is not {Count: > 0} swipeItems)
84+
return;
85+
86+
LayoutSwipeItems(swipeItems);
87+
}
88+
7989
public override bool OnTouchEvent(MotionEvent? e)
8090
{
8191
base.OnTouchEvent(e);

src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ override Microsoft.Maui.Handlers.HybridWebViewHandler.DisconnectHandler(Android.
6363
override Microsoft.Maui.Platform.MauiAppCompatEditText.OnSelectionChanged(int selStart, int selEnd) -> void
6464
override Microsoft.Maui.Platform.MauiHybridWebViewClient.Dispose(bool disposing) -> void
6565
override Microsoft.Maui.Platform.MauiHybridWebViewClient.ShouldInterceptRequest(Android.Webkit.WebView? view, Android.Webkit.IWebResourceRequest? request) -> Android.Webkit.WebResourceResponse?
66+
override Microsoft.Maui.Platform.MauiSwipeView.OnLayout(bool changed, int left, int top, int right, int bottom) -> void
6667
override Microsoft.Maui.Platform.MauiWebViewClient.OnRenderProcessGone(Android.Webkit.WebView? view, Android.Webkit.RenderProcessGoneDetail? detail) -> bool
6768
static Microsoft.Maui.ElementHandlerExtensions.GetRequiredService<T>(this Microsoft.Maui.IElementHandler! handler, System.Type! type) -> T
6869
static Microsoft.Maui.ElementHandlerExtensions.GetRequiredService<T>(this Microsoft.Maui.IElementHandler! handler) -> T

0 commit comments

Comments
 (0)