From: E.Z. Hart Date: Tue, 16 Jul 2019 17:40:26 +0000 (-0600) Subject: Implement ItemsUpdatingScrollMode on Android and iOS (#6879) X-Git-Tag: accepted/tizen/5.5/unified/20200421.150457~232^2~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d045c356b647a9e4d925b7895b8d1d71b70e9f8;p=platform%2Fcore%2Fcsapi%2Fxsf.git Implement ItemsUpdatingScrollMode on Android and iOS (#6879) --- diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewItemsUpdatingScrollMode.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewItemsUpdatingScrollMode.cs new file mode 100644 index 0000000..2d6896b --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewItemsUpdatingScrollMode.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.Forms.Core.UITests; +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ +#if UITEST + [Category(UITestCategories.CollectionView)] +#endif + [Preserve(AllMembers = true)] + [Issue(IssueTracker.None, 8888888, "CollectionView ItemsUpdatingScrollMode", PlatformAffected.All)] + public class CollectionViewItemsUpdatingScrollMode : TestNavigationPage + { + protected override void Init() + { +#if APP + Device.SetFlags(new List(Device.Flags ?? new List()) { "CollectionView_Experimental" }); + + PushAsync(new GalleryPages.CollectionViewGalleries.ScrollModeGalleries.ScrollModeTestGallery()); +#endif + } + +#if UITEST + [Test] + public void KeepItemsInView() + { + RunningApp.WaitForElement("ScrollToMiddle"); + RunningApp.Tap("ScrollToMiddle"); + RunningApp.WaitForElement("Vegetables.jpg, 10"); + RunningApp.Tap("AddItemAbove"); + RunningApp.WaitForNoElement("photo.jpg, 9"); + } + + [Test] + public void KeepScrollOffset() + { + RunningApp.WaitForElement("SelectScrollMode"); + RunningApp.Tap("SelectScrollMode"); + RunningApp.Tap("KeepScrollOffset"); + + RunningApp.WaitForElement("ScrollToMiddle"); + RunningApp.Tap("ScrollToMiddle"); + RunningApp.WaitForElement("Vegetables.jpg, 10"); + RunningApp.Tap("AddItemAbove"); + RunningApp.WaitForElement("photo.jpg, 9"); + } + + [Test] + public void KeepLastItemInView() + { + RunningApp.WaitForElement("SelectScrollMode"); + RunningApp.Tap("SelectScrollMode"); + RunningApp.Tap("KeepLastItemInView"); + + RunningApp.WaitForElement("ScrollToMiddle"); + RunningApp.Tap("ScrollToMiddle"); + RunningApp.WaitForElement("Vegetables.jpg, 10"); + RunningApp.Tap("AddItemToEnd"); + RunningApp.WaitForElement("Added item"); + } +#endif + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 8fa5d61..e250e29 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -9,6 +9,7 @@ Xamarin.Forms.Controls.Issues + Issue5046.xaml Code diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionViewGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionViewGallery.cs index 1e06a83..285ecf1 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionViewGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionViewGallery.cs @@ -1,6 +1,7 @@ using Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.EmptyViewGalleries; using Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGalleries; using Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.SelectionGalleries; +using Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.ScrollModeGalleries; namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries { @@ -23,6 +24,7 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries GalleryBuilder.NavButton("Selection Galleries", () => new SelectionGallery(), Navigation), GalleryBuilder.NavButton("Propagation Galleries", () => new PropagationGallery(), Navigation), GalleryBuilder.NavButton("Grouping Galleries", () => new GroupingGallery(), Navigation), + GalleryBuilder.NavButton("Scroll Mode Galleries", () => new ScrollModeGallery(), Navigation), } }; } diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EnumSelector.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EnumSelector.cs index d92c9e1..e2b0016 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EnumSelector.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EnumSelector.cs @@ -8,7 +8,7 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries readonly Picker _picker; - public EnumSelector(Func getValue, Action setValue) + public EnumSelector(Func getValue, Action setValue, string automationId = "") { _setValue = setValue; @@ -26,7 +26,8 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries { WidthRequest = 200, ItemsSource = source, - SelectedItem = getValue().ToString() + SelectedItem = getValue().ToString(), + AutomationId = automationId }; _picker.SelectedIndexChanged += PickerOnSelectedIndexChanged; diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ScrollModeGalleries/ScrollModeGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ScrollModeGalleries/ScrollModeGallery.cs new file mode 100644 index 0000000..a1f3780 --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ScrollModeGalleries/ScrollModeGallery.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.ScrollModeGalleries +{ + internal class ScrollModeGallery : ContentPage + { + public ScrollModeGallery() + { + var descriptionLabel = + new Label { Text = "Scroll Mode Galleries", Margin = new Thickness(2, 2, 2, 2) }; + + Title = "Scroll Mode Galleries"; + + Content = new ScrollView + { + Content = new StackLayout + { + Children = + { + descriptionLabel, + GalleryBuilder.NavButton("Scroll Modes Testing", () => + new ScrollModeTestGallery(), Navigation) + } + } + }; + } + } +} diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml new file mode 100644 index 0000000..7ea33f0 --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ScrollModeGalleries/ScrollModeTestGallery.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + +