forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement CollectionView grouping on Android (xamarin#7199)
* Move all the header/footer adjustment to IItemsViewSource fixes xamarin#7121 fixes xamarin#7102 partially implements xamarin#3172 fixes xamarin#7243 * Fix selection bugs introduced by header/footer on Android * Implement grouping for CollectionView on Android * Enable grouping tests for Android * Naming and comment cleanup * Update Xamarin.Forms.Platform.Android/CollectionView/ListSource.cs Co-Authored-By: Gerald Versluis <gerald.versluis@microsoft.com> * Update Xamarin.Forms.Platform.Android/CollectionView/ObservableGroupedSource.cs
- Loading branch information
1 parent
8aa0fd3
commit f2dcc9a
Showing
46 changed files
with
1,202 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7102.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...n.Forms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://xamarin.com/schemas/2014/forms/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.GroupingGalleries.GridGrouping"> | ||
<ContentPage.Content> | ||
<CollectionView x:Name="CollectionView" IsGrouped="True" Header="This is a header" Footer="This is a footer."> | ||
|
||
<CollectionView.ItemsLayout> | ||
<GridItemsLayout Span="2" Orientation="Vertical"></GridItemsLayout> | ||
</CollectionView.ItemsLayout> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<StackLayout> | ||
<Label Text="{Binding Name}" Margin="5,0,0,0"/> | ||
</StackLayout> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
|
||
<CollectionView.GroupHeaderTemplate> | ||
<DataTemplate> | ||
|
||
<Label Text="{Binding Name}" BackgroundColor="LightGreen" FontSize="16" FontAttributes="Bold"/> | ||
|
||
</DataTemplate> | ||
</CollectionView.GroupHeaderTemplate> | ||
|
||
<CollectionView.GroupFooterTemplate> | ||
<DataTemplate> | ||
<StackLayout> | ||
<Label Text="{Binding Count, StringFormat='{}Total members: {0:D}'}" BackgroundColor="Orange" | ||
Margin="0,0,0,15"/> | ||
</StackLayout> | ||
</DataTemplate> | ||
</CollectionView.GroupFooterTemplate> | ||
|
||
</CollectionView> | ||
</ContentPage.Content> | ||
</ContentPage> |
14 changes: 14 additions & 0 deletions
14
...orms.Controls/GalleryPages/CollectionViewGalleries/GroupingGalleries/GridGrouping.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...Controls/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:d="http://xamarin.com/schemas/2014/forms/design" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
x:Class="Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.HeaderFooterGalleries.FooterOnlyString"> | ||
<ContentPage.Content> | ||
<CollectionView x:Name="CollectionView" Footer="This is a footer"> | ||
|
||
</CollectionView> | ||
</ContentPage.Content> | ||
</ContentPage> |
25 changes: 25 additions & 0 deletions
25
...trols/GalleryPages/CollectionViewGalleries/HeaderFooterGalleries/FooterOnlyString.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.