diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewGrouping.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewGrouping.cs index bf25b99fc..a56335ba1 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewGrouping.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CollectionViewGrouping.cs @@ -29,7 +29,7 @@ namespace Xamarin.Forms.Controls.Issues #endif } -#if UITEST && __IOS__ // Grouping is not implemented on Android yet +#if UITEST [Test] public void RemoveSelectedItem() { @@ -88,8 +88,6 @@ namespace Xamarin.Forms.Controls.Issues RunningApp.WaitForElement("MoveGroup"); RunningApp.Tap("MoveGroup"); } - - #endif } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7102.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7102.cs new file mode 100644 index 000000000..8177ae4b2 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7102.cs @@ -0,0 +1,50 @@ +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.Github, 7102, "[Bug] CollectionView Header cause delay to adding items.", + PlatformAffected.Android)] + public class Issue7102 : TestNavigationPage + { + protected override void Init() + { +#if APP + FlagTestHelpers.SetCollectionViewTestFlag(); + + PushAsync(new GalleryPages.CollectionViewGalleries.ObservableCodeCollectionViewGallery(grid: false)); +#endif + } + +#if UITEST + [Test] + public void HeaderDoesNotBreakIndexes() + { + RunningApp.WaitForElement("entryInsert"); + RunningApp.Tap("entryInsert"); + RunningApp.ClearText(); + RunningApp.EnterText("1"); + RunningApp.Tap("Insert"); + + // If the bug is still present, then there will be + // two "Item: 0" items instead of the newly inserted item + // Or the header will have disappeared + RunningApp.WaitForElement("Inserted"); + RunningApp.WaitForElement("This is the header"); + } +#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 998dbbb02..1711c8f2c 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 @@ -34,6 +34,7 @@ + diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionModifier.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionModifier.cs index fa81807bf..e5b05c789 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionModifier.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/CollectionModifier.cs @@ -17,10 +17,10 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries HorizontalOptions = LayoutOptions.Fill }; - var button = new Button { Text = buttonText, AutomationId = $"btn{buttonText}" }; - var label = new Label { Text = LabelText, VerticalTextAlignment = TextAlignment.Center }; + var button = new Button { Text = buttonText, AutomationId = $"btn{buttonText}", HeightRequest = 20, FontSize = 10 }; + var label = new Label { Text = LabelText, VerticalTextAlignment = TextAlignment.Center, FontSize = 10 }; - Entry = new Entry { Keyboard = Keyboard.Numeric, Text = InitialEntryText, WidthRequest = 100, AutomationId = $"entry{buttonText}" }; + Entry = new Entry { Keyboard = Keyboard.Numeric, Text = InitialEntryText, WidthRequest = 100, FontSize = 10, AutomationId = $"entry{buttonText}" }; layout.Children.Add(label); layout.Children.Add(Entry); diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml index 5332e5420..bc3910b97 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGalleries.BasicGrouping"> - + diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml.cs index 694b66cdc..1b03497ae 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/BasicGrouping.xaml.cs @@ -11,12 +11,12 @@ using Xamarin.Forms.Xaml; namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGalleries { [XamlCompilation(XamlCompilationOptions.Compile)] - [Preserve (AllMembers = true)] + [Preserve(AllMembers = true)] public partial class BasicGrouping : ContentPage { - public BasicGrouping () + public BasicGrouping() { - InitializeComponent (); + InitializeComponent(); CollectionView.ItemsSource = new SuperTeams(); } diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml new file mode 100644 index 000000000..aee064004 --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml.cs new file mode 100644 index 000000000..05ea898a0 --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml.cs @@ -0,0 +1,14 @@ +using Xamarin.Forms.Xaml; + +namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGalleries +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class GridGrouping : ContentPage + { + public GridGrouping() + { + InitializeComponent(); + CollectionView.ItemsSource = new SuperTeams(); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GroupingGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GroupingGallery.cs index 00b91423d..44a346594 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GroupingGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GroupingGallery.cs @@ -32,6 +32,8 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGa new SwitchGrouping(), Navigation), GalleryBuilder.NavButton("Grouping, Observable", () => new ObservableGrouping(), Navigation), + GalleryBuilder.NavButton("Grouping, Grid", () => + new GridGrouping(), Navigation), } } }; diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/ObservableGrouping.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/ObservableGrouping.cs index d97d50889..3dc6047e2 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/ObservableGrouping.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/ObservableGrouping.cs @@ -10,7 +10,7 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGa Title = "Observable Grouped List"; var buttonStyle = new Style(typeof(Button)) { }; - buttonStyle.Setters.Add(new Setter() { Property = Button.HeightRequestProperty, Value = 20 }); + buttonStyle.Setters.Add(new Setter() { Property = Button.HeightRequestProperty, Value = 30 }); buttonStyle.Setters.Add(new Setter() { Property = Button.FontSizeProperty, Value = 10 }); var layout = new Grid @@ -34,6 +34,8 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGa var collectionView = new CollectionView { + Header = "This is a header", + Footer = "Hey, I'm a footer. Look at me!", ItemTemplate = ItemTemplate(), GroupFooterTemplate = GroupFooterTemplate(), GroupHeaderTemplate = GroupHeaderTemplate(), @@ -102,7 +104,15 @@ namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGa Style = buttonStyle }; groupRemover.Clicked += (obj, args) => { itemsSource?.Remove(itemsSource[0]); - groupRemover.Text = $"Remove {itemsSource[0].Name}"; + if (itemsSource.Count > 0) + { + groupRemover.Text = $"Remove {itemsSource[0].Name}"; + } + else + { + groupRemover.Text = ""; + groupRemover.IsEnabled = false; + } mover.Text = $"Move Selected To {itemsSource[0].Name}"; }; diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml new file mode 100644 index 000000000..08286e4af --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml.cs new file mode 100644 index 000000000..c31cfcf4e --- /dev/null +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.HeaderFooterGalleries +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class FooterOnlyString : ContentPage + { + readonly DemoFilteredItemSource _demoFilteredItemSource = new DemoFilteredItemSource(20); + + public FooterOnlyString() + { + InitializeComponent(); + + CollectionView.ItemTemplate = ExampleTemplates.PhotoTemplate(); + CollectionView.ItemsSource = _demoFilteredItemSource.Items; + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGallery.cs index 12e848c51..ee2a11b94 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/HeaderFooterGallery.cs @@ -20,6 +20,7 @@ GalleryBuilder.NavButton("Header/Footer (Forms View)", () => new HeaderFooterView(), Navigation), GalleryBuilder.NavButton("Header/Footer (Template)", () => new HeaderFooterTemplate(), Navigation), GalleryBuilder.NavButton("Header/Footer (Grid)", () => new HeaderFooterGrid(), Navigation), + GalleryBuilder.NavButton("Footer Only (String)", () => new FooterOnlyString(), Navigation), } } }; diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ObservableCodeCollectionViewGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ObservableCodeCollectionViewGallery.cs index 5fac776cf..00517e763 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ObservableCodeCollectionViewGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/ObservableCodeCollectionViewGallery.cs @@ -25,7 +25,8 @@ var itemTemplate = ExampleTemplates.PhotoTemplate(); - var collectionView = new CollectionView {ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, AutomationId = "collectionview" }; + var collectionView = new CollectionView {ItemsLayout = itemsLayout, ItemTemplate = itemTemplate, + AutomationId = "collectionview", Header = "This is the header" }; var generator = new ItemsSourceGenerator(collectionView, initialItems, ItemsSourceType.ObservableCollection); diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/SelectionGalleries/MultipleBoundSelection.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/SelectionGalleries/MultipleBoundSelection.xaml index d78cf9581..b7d8551f9 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/SelectionGalleries/MultipleBoundSelection.xaml +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/SelectionGalleries/MultipleBoundSelection.xaml @@ -17,7 +17,7 @@