Skip to content

Commit 1d6a8ee

Browse files
Modified the fix and the test case, and re-enabled the Windows test
1 parent ca6d08e commit 1d6a8ee

File tree

10 files changed

+35
-11
lines changed

10 files changed

+35
-11
lines changed

src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public MauiCarouselRecyclerView(Context context, Func<IItemsLayout> getItemsLayo
3434

3535
public override bool OnInterceptTouchEvent(MotionEvent ev)
3636
{
37-
if (!IsSwipeEnabled || !Carousel.IsEnabled)
37+
if (!IsSwipeEnabled || !Enabled)
3838
{
3939
return false;
4040
}

src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,5 +637,15 @@ void RemoveScrollListener()
637637
ClearOnScrollListeners();
638638
RecyclerViewScrollListener = null;
639639
}
640+
641+
public override bool OnInterceptTouchEvent(MotionEvent ev)
642+
{
643+
if (!Enabled)
644+
{
645+
return false;
646+
}
647+
648+
return base.OnInterceptTouchEvent(ev);
649+
}
640650
}
641651
}

src/Controls/src/Core/Handlers/Items/CarouselViewHandler.iOS.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ protected override void ScrollToRequested(object sender, ScrollToRequestEventArg
3939
internal static void MapIsEnabled(CarouselViewHandler handler, CarouselView carouselView)
4040
{
4141
handler.Controller?.CollectionView?.UpdateIsEnabled(carouselView);
42-
ViewHandler.MapIsEnabled(handler, carouselView);
4342
}
4443

4544
public static void MapIsSwipeEnabled(CarouselViewHandler handler, CarouselView carouselView)

src/Controls/src/Core/Handlers/Items/ItemsViewHandler.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ public ItemsViewHandler(PropertyMapper mapper = null) : base(mapper ?? ItemsView
2828
[Controls.ItemsView.EmptyViewTemplateProperty.PropertyName] = MapEmptyViewTemplate,
2929
[Controls.ItemsView.FlowDirectionProperty.PropertyName] = MapFlowDirection,
3030
[Controls.ItemsView.IsVisibleProperty.PropertyName] = MapIsVisible,
31-
[Controls.ItemsView.ItemsUpdatingScrollModeProperty.PropertyName] = MapItemsUpdatingScrollMode
31+
[Controls.ItemsView.ItemsUpdatingScrollModeProperty.PropertyName] = MapItemsUpdatingScrollMode,
32+
#if IOS || MACCATALYST
33+
[Controls.VisualElement.IsEnabledProperty.PropertyName] = MapIsEnabled,
34+
#endif
3235
};
3336
}
3437
}

src/Controls/src/Core/Handlers/Items/ItemsViewHandler.iOS.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public static void MapItemsUpdatingScrollMode(ItemsViewHandler<TItemsView> handl
9191
handler._layout.ItemsUpdatingScrollMode = itemsView.ItemsUpdatingScrollMode;
9292
}
9393

94+
// TODO: Change the modifier to public in .NET 11.
95+
internal static void MapIsEnabled(ItemsViewHandler<TItemsView> handler, ItemsView itemsView)
96+
{
97+
handler.Controller?.CollectionView?.UpdateIsEnabled(itemsView);
98+
}
99+
94100
protected virtual void UpdateLayout()
95101
{
96102
_layout = SelectLayout();

src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ protected override void ScrollToRequested(object sender, ScrollToRequestEventArg
7373
internal static void MapIsEnabled(CarouselViewHandler2 handler, CarouselView carouselView)
7474
{
7575
handler.Controller?.CollectionView?.UpdateIsEnabled(carouselView);
76-
ViewHandler.MapIsEnabled(handler, carouselView);
7776
}
7877

7978
public static void MapIsSwipeEnabled(CarouselViewHandler2 handler, CarouselView carouselView)

src/Controls/src/Core/Handlers/Items2/ItemsViewHandler2.iOS.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public ItemsViewHandler2(PropertyMapper mapper = null) : base(mapper ?? ItemsVie
3333
[Controls.ItemsView.EmptyViewTemplateProperty.PropertyName] = MapEmptyViewTemplate,
3434
[Controls.ItemsView.FlowDirectionProperty.PropertyName] = MapFlowDirection,
3535
[Controls.ItemsView.IsVisibleProperty.PropertyName] = MapIsVisible,
36-
[Controls.ItemsView.ItemsUpdatingScrollModeProperty.PropertyName] = MapItemsUpdatingScrollMode
37-
};
38-
36+
[Controls.ItemsView.ItemsUpdatingScrollModeProperty.PropertyName] = MapItemsUpdatingScrollMode,
37+
[Controls.VisualElement.IsEnabledProperty.PropertyName] = MapIsEnabled
38+
};
39+
3940
UICollectionViewLayout _layout;
4041

4142
protected override void DisconnectHandler(UIView platformView)
@@ -115,6 +116,12 @@ public static void MapIsVisible(ItemsViewHandler2<TItemsView> handler, ItemsView
115116
handler.Controller?.UpdateVisibility();
116117
}
117118

119+
// TODO: Change the modifier to public in .NET 11.
120+
internal static void MapIsEnabled(ItemsViewHandler2<TItemsView> handler, ItemsView itemsView)
121+
{
122+
handler.Controller?.CollectionView?.UpdateIsEnabled(itemsView);
123+
}
124+
118125
public static void MapItemsUpdatingScrollMode(ItemsViewHandler2<TItemsView> handler, ItemsView itemsView)
119126
{
120127
if (handler.ItemsView is StructuredItemsView structuredItemsView && structuredItemsView.ItemsLayout is ItemsLayout itemsLayout)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ virtual Microsoft.Maui.Controls.BindableProperty.CreateDefaultValueDelegate<TDec
1616
~virtual Microsoft.Maui.Controls.BindableProperty.ValidateValueDelegate<TPropertyType>.Invoke(Microsoft.Maui.Controls.BindableObject bindable, TPropertyType value) -> bool
1717
~virtual Microsoft.Maui.Controls.CollectionSynchronizationCallback.Invoke(System.Collections.IEnumerable collection, object context, System.Action accessMethod, bool writeAccess) -> void
1818
~virtual Microsoft.Maui.Controls.Internals.EvaluateJavaScriptDelegate.Invoke(string script) -> System.Threading.Tasks.Task<string>
19-
~virtual Microsoft.Maui.Controls.PropertyChangingEventHandler.Invoke(object sender, Microsoft.Maui.Controls.PropertyChangingEventArgs e) -> void
19+
~virtual Microsoft.Maui.Controls.PropertyChangingEventHandler.Invoke(object sender, Microsoft.Maui.Controls.PropertyChangingEventArgs e) -> void
20+
~override Microsoft.Maui.Controls.Handlers.Items.MauiRecyclerView<TItemsView, TAdapter, TItemsViewSource>.OnInterceptTouchEvent(Android.Views.MotionEvent ev) -> bool

src/Controls/tests/TestCases.HostApp/Issues/Issue14184.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public Issue14184()
1212
AutomationId = "DisabledCarouselView",
1313
HeightRequest = 300,
1414
IsEnabled = false,
15+
Loop = false,
1516
ItemsSource = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" },
1617
ItemTemplate = new DataTemplate(() =>
1718
{

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14184.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if TEST_FAILS_ON_WINDOWS
21
using NUnit.Framework;
32
using UITest.Appium;
43
using UITest.Core;
@@ -23,5 +22,4 @@ public void VerifyCarouselViewPreventsSwipingWhenDisabled()
2322
var statusText = App.WaitForElement("Issue14184StatusLabel").GetText();
2423
Assert.That(statusText, Is.EqualTo("Success"));
2524
}
26-
}
27-
#endif
25+
}

0 commit comments

Comments
 (0)