diff --git a/CollectionView.Droid/CollectionView.Droid.csproj b/CollectionView.Droid/CollectionView.Droid.csproj index 0b5a0c5..d24092c 100644 --- a/CollectionView.Droid/CollectionView.Droid.csproj +++ b/CollectionView.Droid/CollectionView.Droid.csproj @@ -142,7 +142,7 @@ - {6E8E8AAC-E482-4E9C-9759-27B03E4DC309} + {D5C93D88-A5D6-4843-935B-CC72F073B54E} CollectionView diff --git a/CollectionView.Droid/GridCollectionViewRenderer.cs b/CollectionView.Droid/GridCollectionViewRenderer.cs index 149cbf3..30b5cd4 100644 --- a/CollectionView.Droid/GridCollectionViewRenderer.cs +++ b/CollectionView.Droid/GridCollectionViewRenderer.cs @@ -468,7 +468,7 @@ public override void GetItemOffsets(Android.Graphics.Rect outRect, Android.Views outRect.Right = _parentRenderer.ColumnSpacing - (spanIndex + 1) * _parentRenderer.ColumnSpacing / _spanCount; // spacing - (column + 1) * ((1f / spanCount) * spacing) } - if(position == 0 || _parentRenderer.Adapter.FirstSectionItems.Contains(position)) { + if(position < _spanCount || _parentRenderer.Adapter.FirstSectionItems.Contains(position - spanIndex)) { return; } diff --git a/Sample/Sample.Droid/MainActivity.cs b/Sample/Sample.Droid/MainActivity.cs index 4e42ed6..526a16e 100644 --- a/Sample/Sample.Droid/MainActivity.cs +++ b/Sample/Sample.Droid/MainActivity.cs @@ -1,5 +1,4 @@ -using AiForms.Extras; -using Android.App; +using Android.App; using Android.Content.PM; using Android.OS; using CarouselView.FormsPlugin.Android; @@ -23,7 +22,7 @@ protected override void OnCreate(Bundle bundle) Xamarin.Forms.Svg.Droid.SvgImage.Init(); FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true); CarouselViewRenderer.Init(); - AiForms.Extras.Extras.Init(this); + AiForms.Dialogs.Dialogs.Init(this); LoadApplication(new App(new AndroidInitializer())); @@ -34,7 +33,7 @@ public class AndroidInitializer : IPlatformInitializer { public void RegisterTypes(IContainerRegistry containerRegistry) { - containerRegistry.RegisterInstance(Toast.Instance); + containerRegistry.RegisterInstance(AiForms.Dialogs.Toast.Instance); } } } diff --git a/Sample/Sample.Droid/Sample.Droid.csproj b/Sample/Sample.Droid/Sample.Droid.csproj index 717ef02..4104bb3 100644 --- a/Sample/Sample.Droid/Sample.Droid.csproj +++ b/Sample/Sample.Droid/Sample.Droid.csproj @@ -208,11 +208,17 @@ ..\packages\Xamarin.Forms.3.2.0.839982\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll - - ..\packages\AiForms.Extras.0.1.0-pre1\lib\MonoAndroid\AiForms.Extras.Abstractions.dll + + ..\packages\AiForms.SettingsView.0.3.2\lib\MonoAndroid\SettingsView.dll - - ..\packages\AiForms.Extras.0.1.0-pre1\lib\MonoAndroid\AiForms.Extras.dll + + ..\packages\AiForms.SettingsView.0.3.2\lib\MonoAndroid\SettingsView.Droid.dll + + + ..\packages\AiForms.Dialogs.0.3.2-pre\lib\MonoAndroid\AiForms.Dialogs.Abstractions.dll + + + ..\packages\AiForms.Dialogs.0.3.2-pre\lib\MonoAndroid\AiForms.Dialogs.dll diff --git a/Sample/Sample.Droid/packages.config b/Sample/Sample.Droid/packages.config index 4090463..0f58cd3 100644 --- a/Sample/Sample.Droid/packages.config +++ b/Sample/Sample.Droid/packages.config @@ -1,8 +1,9 @@  + - + diff --git a/Sample/Sample.iOS/AppDelegate.cs b/Sample/Sample.iOS/AppDelegate.cs index a475f65..d9eb375 100644 --- a/Sample/Sample.iOS/AppDelegate.cs +++ b/Sample/Sample.iOS/AppDelegate.cs @@ -5,8 +5,7 @@ using FFImageLoading.Forms; using FFImageLoading.Forms.Touch; using CarouselView.FormsPlugin.iOS; -using AiForms.Extras.Abstractions; -using AiForms.Extras; +using AiForms.Dialogs; namespace Sample.iOS { @@ -29,9 +28,11 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options) AiForms.Effects.iOS.Effects.Init(); AiForms.Renderers.iOS.CollectionViewInit.Init(); + AiForms.Renderers.iOS.SettingsViewInit.Init(); Xamarin.Forms.Svg.iOS.SvgImage.Init(); FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); CarouselViewRenderer.Init(); + AiForms.Dialogs.Dialogs.Init(); LoadApplication(new App(new iOSInitializer())); diff --git a/Sample/Sample.iOS/Sample.iOS.csproj b/Sample/Sample.iOS/Sample.iOS.csproj index dc952de..d9f6f33 100644 --- a/Sample/Sample.iOS/Sample.iOS.csproj +++ b/Sample/Sample.iOS/Sample.iOS.csproj @@ -181,11 +181,17 @@ ..\packages\Xamarin.Forms.3.2.0.839982\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll - - ..\packages\AiForms.Extras.0.1.0-pre1\lib\Xamarin.iOS10\AiForms.Extras.Abstractions.dll + + ..\packages\AiForms.SettingsView.0.3.2\lib\Xamarin.iOS10\SettingsView.dll - - ..\packages\AiForms.Extras.0.1.0-pre1\lib\Xamarin.iOS10\AiForms.Extras.dll + + ..\packages\AiForms.SettingsView.0.3.2\lib\Xamarin.iOS10\SettingsView.iOS.dll + + + ..\packages\AiForms.Dialogs.0.3.2-pre\lib\Xamarin.iOS10\AiForms.Dialogs.Abstractions.dll + + + ..\packages\AiForms.Dialogs.0.3.2-pre\lib\Xamarin.iOS10\AiForms.Dialogs.dll diff --git a/Sample/Sample.iOS/packages.config b/Sample/Sample.iOS/packages.config index 950b220..1e1521f 100644 --- a/Sample/Sample.iOS/packages.config +++ b/Sample/Sample.iOS/packages.config @@ -1,8 +1,9 @@  + - + diff --git a/Sample/Sample/Sample.csproj b/Sample/Sample/Sample.csproj index df12cf4..3e5461a 100644 --- a/Sample/Sample/Sample.csproj +++ b/Sample/Sample/Sample.csproj @@ -14,7 +14,8 @@ - + + @@ -22,4 +23,7 @@ + + + \ No newline at end of file diff --git a/Sample/Sample/ViewModels/CollectionViewGroupTestViewModel.cs b/Sample/Sample/ViewModels/CollectionViewGroupTestViewModel.cs index 0eee5e0..8b9a50f 100644 --- a/Sample/Sample/ViewModels/CollectionViewGroupTestViewModel.cs +++ b/Sample/Sample/ViewModels/CollectionViewGroupTestViewModel.cs @@ -13,13 +13,10 @@ namespace Sample.ViewModels { public class CollectionViewGroupTestViewModel:CollectionViewTestViewModel { - public ObservableCollection ItemsGroupSource { get; set; } + public ReactiveCommand AddSecCommand { get; set; } = new ReactiveCommand(); public ReactiveCommand DelSecCommand { get; set; } = new ReactiveCommand(); - public ReactivePropertySlim HeaderHeight { get; } = new ReactivePropertySlim(36); - - PhotoGroup _additionalGroup; IPageDialogService _pageDlg; public CollectionViewGroupTestViewModel(IPageDialogService pageDialog):base(pageDialog) @@ -29,153 +26,6 @@ public CollectionViewGroupTestViewModel(IPageDialogService pageDialog):base(page } - public override void IndividualTest() - { - TestList.Add("Test Start").Add( - "Manipulation Test1. Has SectionB been scrolled to Top to Bottom To Center?", - async () => - { - ScrollController.ScrollToStart(); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Start, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.End, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Center, false); - } - ).Add( - "Manipulation Test2. Has SectionB been scrolled to Top to Bottom To Center with animation?", - async () => - { - - ScrollController.ScrollToStart(true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Start, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.End, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Center, true); - - } - ).Add( - "Manipulation Test3. Has SectionC - Title14 been scrolled to Top to Bottom To Center?", - async () => - { - ScrollController.ScrollToStart(false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Start, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.End, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Center, false); - } - ).Add( - "Manipulation Test4. Has SectionC - Title14 been scrolled to Top to Bottom To Center with animation?", - async () => - { - ScrollController.ScrollToStart(true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Start, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.End, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Center, true); - } - ).Add( - "Manipulation Test5. Has new cell been inserted before Title1?", - async () => - { - ScrollController.ScrollToStart(true); - await Task.Delay(2000); - ItemsGroupSource[0].Insert(0, GetAdditionalItem()); - } - ).Add( - "Manipulation Test6. Has new cell been inserted after Title20?", - async () => - { - ScrollController.ScrollTo(ItemsGroupSource[0][20],ItemsGroupSource[0], ScrollToPosition.End, true); - await Task.Delay(2000); - ItemsGroupSource[0].Add(GetAdditionalItem()); - } - ).Add( - "Manipulation Test7. Has new cell been inserted between Title8 and Title9?", - async () => - { - ScrollController.ScrollTo(ItemsGroupSource[0][8],ItemsGroupSource[0], ScrollToPosition.Center, true); - await Task.Delay(2000); - ItemsGroupSource[0].Insert(9, GetAdditionalItem()); - } - ).Add( - "Manipulation Test8. Has the first cell been deleted?", - async () => - { - ScrollController.ScrollToStart(true); - await Task.Delay(2000); - ItemsGroupSource[0].RemoveAt(0); - } - ).Add( - "Manipulation Test9. Has the last cell in SectionA been deleted?", - async () => - { - ScrollController.ScrollTo(ItemsGroupSource[0][21], ItemsGroupSource[0], ScrollToPosition.End, true); - await Task.Delay(2000); - ItemsGroupSource[0].RemoveAt(ItemsGroupSource[0].Count - 1); - } - ).Add( - "Manipulation Test10. Has the cell between Title8 and Title9 in SectionA been deleted?", - async () => - { - ScrollController.ScrollTo(ItemsGroupSource[0][8], ItemsGroupSource[0], ScrollToPosition.Center, true); - await Task.Delay(2000); - ItemsGroupSource[0].RemoveAt(8); - } - ).Add( - "Manipulation Test11. Has the first cell been changed to AddItem?", - async () => - { - ScrollController.ScrollToStart(true); - await Task.Delay(2000); - ItemsGroupSource[0][0] = GetAdditionalItem(); - } - ).Add( - "Manipulation Test12. Has the first cell been moved to after Title5?", - async () => - { - ScrollController.ScrollToStart(true); - await Task.Delay(2000); - ItemsGroupSource[0].Move(0, 4); - } - ).Add( - "Manipulation Test13. Has new section been inserted at last?", - async () => - { - await Task.Delay(2000); - ItemsGroupSource.Add(_additionalGroup); - await Task.Delay(2000); - ScrollController.ScrollToEnd(true); - } - ).Add( - "Manipulation Test14. Has the last section been deleted?", - async () => - { - await Task.Delay(2000); - ItemsGroupSource.Remove(_additionalGroup); - await Task.Delay(2000); - ScrollController.ScrollToEnd(true); - } - ).Add( - "Has GroupHeaderHeight been twice as large as the privious?", - async () => - { - await Task.Delay(2000); - HeaderHeight.Value *= 2; - }, - () => { - HeaderHeight.Value /= 2; - } - ); - } - void InitializeProperties() { ItemsGroupSource = new ObservableCollection(); @@ -209,101 +59,14 @@ void InitializeProperties() { Category = "CCC", }); } - var list4 = new List(); - for (var i = 5; i < 15; i++) - { - list4.Add(new PhotoItem - { - PhotoUrl = $"https://kamusoft.jp/openimage/nativecell/{i + 1}.jpg", - Title = $"Title {i + 1}", - Category = "DDD", - }); - } var group1 = new PhotoGroup(list1) { Head = "SectionA" }; var group2 = new PhotoGroup(list2) { Head = "SectionB" }; var group3 = new PhotoGroup(list3) { Head = "SectionC" }; - _additionalGroup = new PhotoGroup(list4) { Head = "SectionD" }; + ItemsGroupSource.Add(group1); ItemsGroupSource.Add(group2); ItemsGroupSource.Add(group3); - - } - - public override void InitializeCommand() - { - var addItem = new PhotoItem - { - PhotoUrl = $"https://kamusoft.jp/openimage/nativecell/1.jpg", - Title = $"AddItem", - Category = "AAA" - }; - - var addPtn = 0; - AddCommand.Subscribe(_ => - { - switch (addPtn) - { - case 0: - ItemsGroupSource[0].Insert(0, addItem); - break; - case 1: - ItemsGroupSource[0].Add(addItem); - break; - case 2: - ItemsGroupSource[0].Insert(ItemsGroupSource[0].Count / 2, addItem); - break; - } - - addPtn++; - if (addPtn > 2) - { - addPtn = 0; - } - }); - - var delPtn = 0; - DelCommand.Subscribe(_ => - { - switch (delPtn) - { - case 0: - ItemsGroupSource[0].RemoveAt(0); - break; - case 1: - ItemsGroupSource[0].RemoveAt(ItemsGroupSource[0].Count - 1); - break; - case 2: - ItemsGroupSource[0].RemoveAt(ItemsGroupSource[0].Count / 2); - break; - } - delPtn++; - if (delPtn > 2) - { - delPtn = 0; - } - }); - - RepCommand.Subscribe(_ => - { - ItemsGroupSource[0][0] = addItem; - }); - - MoveCommand.Subscribe(_ => - { - ItemsGroupSource[0].Move(0, 4); - }); - - - AddSecCommand.Subscribe(_ => - { - ItemsGroupSource.Add(_additionalGroup); - }); - - DelSecCommand.Subscribe(_ => - { - ItemsGroupSource.RemoveAt(ItemsSource.Count - 1); - }); } } } diff --git a/Sample/Sample/ViewModels/CollectionViewTestViewModel.cs b/Sample/Sample/ViewModels/CollectionViewTestViewModel.cs index fe4a156..f62db08 100644 --- a/Sample/Sample/ViewModels/CollectionViewTestViewModel.cs +++ b/Sample/Sample/ViewModels/CollectionViewTestViewModel.cs @@ -8,12 +8,14 @@ using AiForms.Renderers; using Prism.Navigation; using System.Linq; +using Prism.Mvvm; namespace Sample.ViewModels { - public class CollectionViewTestViewModel:INavigatingAware + public class CollectionViewTestViewModel:BindableBase, INavigatingAware { public PhotoGroup ItemsSource { get; set; } + public ObservableCollection ItemsGroupSource { get; set; } public ReactiveCommand TapCommand { get; } = new ReactiveCommand(); public ReactiveCommand LongTapCommand { get; } = new ReactiveCommand(); public ReactiveProperty IsRefreshing { get; } = new ReactiveProperty(false); @@ -25,7 +27,10 @@ public class CollectionViewTestViewModel:INavigatingAware public ReactiveCommand DelCommand { get; set; } = new ReactiveCommand(); public ReactiveCommand RepCommand { get; set; } = new ReactiveCommand(); public ReactiveCommand MoveCommand { get; set; } = new ReactiveCommand(); + public ReactiveCommand NextCommand { get; set; } = new ReactiveCommand(); + public ReactiveCommand RepeatCommand { get; set; } = new ReactiveCommand(); + public ReactivePropertySlim HeaderHeight { get; } = new ReactivePropertySlim(36); public ReactivePropertySlim Background { get; } = new ReactivePropertySlim(Color.Transparent); public ReactivePropertySlim FeedbackColor { get; } = new ReactivePropertySlim(Color.Yellow); public ReactivePropertySlim GridType { get; } = new ReactivePropertySlim(AiForms.Renderers.GridType.UniformGrid); @@ -45,6 +50,9 @@ public class CollectionViewTestViewModel:INavigatingAware public ReactivePropertySlim IsGroupHeaderSticky { get; } = new ReactivePropertySlim(true); public ReactivePropertySlim BothSidesMargin { get; } = new ReactivePropertySlim(0); + public List TestSections { get; set; } + IEnumerator _testEnumerator; + IPageDialogService _pageDlg; public CollectionViewTestViewModel(IPageDialogService pageDialog) @@ -52,245 +60,33 @@ public CollectionViewTestViewModel(IPageDialogService pageDialog) _pageDlg = pageDialog; InitializeProperties(); - TestSource = new TestFormViewModel + Action currentAction = null; + NextCommand.Subscribe(async _ => { - ItemsSource = TestList, - PageDialog = pageDialog - }; - + if (!_testEnumerator.MoveNext()) + { + await pageDialog.DisplayAlertAsync("", "Finished", "OK"); + return; + } + currentAction = _testEnumerator.Current.Run; + currentAction?.Invoke(); + }); + RepeatCommand.Subscribe(_ => + { + currentAction?.Invoke(); + }); } - void CommontTest() { - TestList.Add( - "PullToRefresh can't be work." - ).Add( - "Can PullToRefresh be work?", - () => { - EnabledPullToRefresh.Value = true; - } - ).Add( - "Has Refresh icon turned red?", - () => { - RefreshIconColor.Value = Color.Red; - }, - () => { - RefreshIconColor.Value = Color.DimGray; - } - ).Add( - "Has RowSpacing become much larger?", - () => { - RowSpacing.Value = 25; - }, - () => { - RowSpacing.Value = 4; - } - ).Add( - "Has Group First Spacing been 30px in Grouped?", - () => - { - GroupFirstSpacing.Value = 30; - } - ).Add( - "Has Group Last Spacing been 30px in Grouped?", - () => - { - GroupLastSpacing.Value = 30; - } - ).Add( - "Has HeaderCell position been released from sticky?", - () => { - IsGroupHeaderSticky.Value = false; - }, - () => { - IsGroupHeaderSticky.Value = true; - } - ).Add( - "Has ColumnHeight been changed to absolute value(250px)?", - () => { - ColumnHeight.Value = 250; - } - ).Add( - "Has ColumnHeight been changed to relative value(0.5)?", - () => { - ColumnHeight.Value = 0.5; - }, - () => { - ColumnHeight.Value = 1.0; - } - ).Add( - "Has ColumnHeight been changed to 1.0 + 50px by AdditionalHeight?", - () => { - AdditionalHeight.Value = 50; - }, - () => { - AdditionalHeight.Value = 0; - } - ).Add( - "Has Background turned from Yellow to White to Green to transparent?", - async () => - { - Background.Value = Color.Yellow; - await Task.Delay(1000); - Background.Value = Color.White; - await Task.Delay(1000); - Background.Value = Color.Green; - await Task.Delay(1000); - Background.Value = Color.Transparent; - } - ).Add( - "Tap some cells. Has FeedBack color turned Red?", - () => - { - FeedbackColor.Value = Color.Red; - }, - () => - { - FeedbackColor.Value = Color.Yellow; - } - ).Add( - "UniformGrid Test1. GridType is UniformGrid. PortraitColumns are 2.", - () => { - GridType.Value = AiForms.Renderers.GridType.UniformGrid; - PortraitColumns.Value = 2; - BothSidesMargin.Value = 10; - } - ).Add( - "UniformGrid Test2. Has Colums number been changed 2 to 3 to 4 to 5 to 6 on Portrait?", - async () => { - PortraitColumns.Value = 3; - await Task.Delay(1000); - PortraitColumns.Value = 4; - await Task.Delay(1000); - PortraitColumns.Value = 5; - await Task.Delay(1000); - PortraitColumns.Value = 6; - } - ).Add( - "UniformGrid Test3. Has ColumnSpacing / BothSidesMargin been changed 0?", - () => { - ColumnSpacing.Value = 0; - BothSidesMargin.Value = 0; - } - ).Add( - "UniformGrid Test4. Has Colums number been changed 6 to 5 to 4 to 3 to 2 on Portrait?", - async () => { - PortraitColumns.Value = 5; - await Task.Delay(1000); - PortraitColumns.Value = 4; - await Task.Delay(1000); - PortraitColumns.Value = 3; - await Task.Delay(1000); - PortraitColumns.Value = 2; - } - ).Add( - "AutoSpacingGrid Test1. Column width is 150px. SpacingType is Between.", - () => { - GridType.Value = AiForms.Renderers.GridType.AutoSpacingGrid; - ColumnWidth.Value = 150; - SpacingType.Value = AiForms.Renderers.SpacingType.Between; - ColumnSpacing.Value = 4; - } - ).Add( - "AutoSpacingGrid Test2. Has Colum width been changed 150 to 120 to 90 to 60 with keeping Between?", - async () => { - ColumnWidth.Value = 120; - await Task.Delay(1000); - ColumnWidth.Value = 90; - await Task.Delay(1000); - ColumnWidth.Value = 60; - } - ).Add( - "AutoSpacingGrid Test3. Has SpacingType been changed to Center?", - () => { - SpacingType.Value = AiForms.Renderers.SpacingType.Center; - } - ).Add( - "AutoSpacingGrid Test4. Has Colum width been changed 60 to 90 to 120 to 150 with keeping Center?", - async () => { - ColumnWidth.Value = 90; - await Task.Delay(1000); - ColumnWidth.Value = 120; - await Task.Delay(1000); - ColumnWidth.Value = 150; - } - ).Add( - "AutoSpacingGrid Test5. Has ColumnSpacing been changed 0?", - () => { - ColumnSpacing.Value = 0; - } - ).Add( - "AutoSpacingGrid Test6. Has Colum width been changed 150 to 120 to 90 to 60 with keeping Center?", - async () => { - ColumnWidth.Value = 120; - await Task.Delay(1000); - ColumnWidth.Value = 90; - await Task.Delay(1000); - ColumnWidth.Value = 60; - } - ).Add( - "UniformGrid Test5. Change Landscape", - () => { - GridType.Value = AiForms.Renderers.GridType.UniformGrid; - ColumnSpacing.Value = 4; - } - ).Add( - "UniformGrid Test6. Has Colums number been changed 5 to 6 to 7 to 8 on Landscape?", - async () => { - LandscapeColumns.Value = 6; - await Task.Delay(1000); - LandscapeColumns.Value = 7; - await Task.Delay(1000); - LandscapeColumns.Value = 8; - await Task.Delay(1000); - } - ).Add( - "UniformGrid Test7. Has ColumnSpacing been changed 0?", - () => { - ColumnSpacing.Value = 0; - } - ).Add( - "UniformGrid Test8. Has Colums number been changed 8 to 7 to 6 to 5 to 4 on Landscape?", - async () => { - LandscapeColumns.Value = 7; - await Task.Delay(1000); - LandscapeColumns.Value = 6; - await Task.Delay(1000); - LandscapeColumns.Value = 5; - await Task.Delay(1000); - LandscapeColumns.Value = 4; - } - ).Add( - "AutoSpacingGrid Test7. Landscape Test. SpacingType is Center and ColumnSpacing is 4.", - () => { - GridType.Value = AiForms.Renderers.GridType.AutoSpacingGrid; - SpacingType.Value = AiForms.Renderers.SpacingType.Center; - ColumnSpacing.Value = 4; - } - ).Add( - "AutoSpacingGrid Test8. Has Colum width been changed 60 to 90 to 120 to 150 with keeping Center?", - async () => { - ColumnWidth.Value = 90; - await Task.Delay(1000); - ColumnWidth.Value = 120; - await Task.Delay(1000); - ColumnWidth.Value = 150; - } - ).Add( - "AutoSpacingGrid Test9. Has SpacingType been changed to Between?", - () => { - SpacingType.Value = AiForms.Renderers.SpacingType.Between; - } - ).Add( - "AutoSpacingGrid Test10. Has Colum width been changed 150 to 120 to 90 to 60 with keeping Between?", - async () => { - ColumnWidth.Value = 120; - await Task.Delay(1000); - ColumnWidth.Value = 90; - await Task.Delay(1000); - ColumnWidth.Value = 60; - } - ); + public virtual void OnNavigatingTo(NavigationParameters parameters) + { + TestSections = parameters.GetValue>("tests"); + + _testEnumerator = TestSections.SelectMany(x => x).Where(y => y.Check.Value).SelectMany(z => z).GetEnumerator(); + + TestSections.ForEach(x => x.SetViewModel(this)); + + RaisePropertyChanged(nameof(TestSections)); } public PhotoItem GetAdditionalItem() @@ -303,100 +99,6 @@ public PhotoItem GetAdditionalItem() }; } - public virtual void IndividualTest() - { - - - TestList.Add("Test Start").Add( - "Manipulation Test1. Has Title10 been scrolled to Top to Bottom To Center?", - async () => { - ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Start, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.End, false); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Center, false); - } - ).Add( - "Manipulation Test2. Has Title10 been scrolled to Top to Bottom To Center with animation?", - async () => { - - ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Start, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.End, true); - await Task.Delay(2000); - ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Center, true); - } - ).Add( - "Manipulation Test3. Has new cell been inserted before Title1?", - async () => { - - ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); - await Task.Delay(2000); - ItemsSource.Insert(0, GetAdditionalItem()); - } - ).Add( - "Manipulation Test4. Click + again. Has new cell been inserted after Title20?", - async () => { - - ScrollController.ScrollTo(ItemsSource.Last(), ScrollToPosition.End, true); - await Task.Delay(2000); - ItemsSource.Add(GetAdditionalItem()); - } - ).Add( - "Manipulation Test5. Click + again. Has new cell been inserted between Title8 and Title9?", - async () => { - - ScrollController.ScrollTo(ItemsSource[8], ScrollToPosition.Center, true); - await Task.Delay(2000); - ItemsSource.Insert(9, GetAdditionalItem()); - } - ).Add( - "Manipulation Test4. Click -. Has the first cell been deleted?", - async () => { - - ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); - await Task.Delay(2000); - ItemsSource.RemoveAt(0); - } - ).Add( - "Manipulation Test6. Click - again. Has the last cell been deleted?", - async () => { - - ScrollController.ScrollTo(ItemsSource.Last(), ScrollToPosition.End, true); - await Task.Delay(2000); - ItemsSource.RemoveAt(ItemsSource.Count - 1); - } - ).Add( - "Manipulation Test7. Click - again. Has the cell between Title8 and Title9 been deleted?", - async () => { - - ScrollController.ScrollTo(ItemsSource[8], ScrollToPosition.Center, true); - await Task.Delay(2000); - ItemsSource.RemoveAt(8); - } - ).Add( - "Manipulation Test8. Click R. Has the first cell been changed to AddItem?", - async () => { - - ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); - await Task.Delay(2000); - ItemsSource[0] = GetAdditionalItem(); - } - ).Add( - "Manipulation Test9. Click M. Has the first cell been moved to after Title5?", - async () => { - - ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); - await Task.Delay(2000); - ItemsSource.Move(0, 4); - } - ); - } - void InitializeProperties() { @@ -430,84 +132,5 @@ void InitializeProperties() IsRefreshing.Value = false; }); } - - public virtual void InitializeCommand() - { - var addItem = new PhotoItem - { - PhotoUrl = $"https://kamusoft.jp/openimage/nativecell/1.jpg", - Title = $"AddItem", - Category = "AAA" - }; - - var addPtn = 0; - AddCommand.Subscribe(_ => - { - switch (addPtn) - { - case 0: - //ItemsSource.Insert(0, addItem); - GridType.Value = AiForms.Renderers.GridType.AutoSpacingGrid; - SpacingType.Value = AiForms.Renderers.SpacingType.Between; - break; - case 1: - //ItemsSource.Add(addItem); - SpacingType.Value = AiForms.Renderers.SpacingType.Center; - break; - case 2: - //ItemsSource.Insert(9, addItem); - GridType.Value = AiForms.Renderers.GridType.UniformGrid; - break; - - } - - addPtn++; - if (addPtn > 2) - { - addPtn = 0; - } - }); - - var delPtn = 0; - DelCommand.Subscribe(_ => - { - switch (delPtn) - { - case 0: - ItemsSource.RemoveAt(0); - break; - case 1: - ItemsSource.RemoveAt(ItemsSource.Count - 1); - break; - case 2: - ItemsSource.RemoveAt(8); - break; - } - delPtn++; - if (delPtn > 2) - { - delPtn = 0; - } - }); - - RepCommand.Subscribe(_ => - { - ItemsSource[0] = addItem; - }); - - MoveCommand.Subscribe(_ => - { - ItemsSource.Move(0, 4); - }); - } - - - - public virtual void OnNavigatingTo(NavigationParameters parameters) - { - InitializeCommand(); - IndividualTest(); - CommontTest(); - } } } diff --git a/Sample/Sample/ViewModels/DemoPageViewModel.cs b/Sample/Sample/ViewModels/DemoPageViewModel.cs index 98ae1ff..4473112 100644 --- a/Sample/Sample/ViewModels/DemoPageViewModel.cs +++ b/Sample/Sample/ViewModels/DemoPageViewModel.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading.Tasks; -using AiForms.Extras.Abstractions; using Reactive.Bindings; using Prism.Services; using Sample.Views; using Xamarin.Forms; using AiForms.Renderers; +using AiForms.Dialogs.Abstractions; namespace Sample.ViewModels { diff --git a/Sample/Sample/ViewModels/GridGroupTestIndexViewModel.cs b/Sample/Sample/ViewModels/GridGroupTestIndexViewModel.cs new file mode 100644 index 0000000..e329827 --- /dev/null +++ b/Sample/Sample/ViewModels/GridGroupTestIndexViewModel.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Prism.Navigation; +using Reactive.Bindings; +using Sample.ViewModels.Tests; +using Xamarin.Forms; + +namespace Sample.ViewModels +{ + public class GridGroupTestIndexViewModel + { + public ReactiveCommand RunCommand { get; } = new ReactiveCommand(); + public ReactiveCommand AllCheckCommand { get; } = new ReactiveCommand(); + public ReactiveCommand NoneCheckCommand { get; } = new ReactiveCommand(); + public ReactiveCommand SaveCommand { get; } = new ReactiveCommand(); + + public List TestSections { get; } = new List(); + + public GridGroupTestIndexViewModel(INavigationService navigationService) + { + var Section = new TestSection { SectionTitle = "Fundamental" }; + Section.Add(new PullToRefreshTest()); + Section.Add(new RowSpacingAndHeightTest()); + Section.Add(new ColorTest()); + + TestSections.Add(Section); + + Section = new TestSection { SectionTitle = "GridType" }; + Section.Add(new UniformGridTest()); + Section.Add(new AutoSpacingTest()); + + TestSections.Add(Section); + + Section = new TestSection { SectionTitle = "Individual" }; + Section.Add(new GridGroupManipulationTest()); + + TestSections.Add(Section); + + var groups = TestSections.SelectMany(x => x).ToList(); + + + void CheckChange(bool turned) + { + foreach (var grp in groups) + { + grp.Check.Value = turned; + } + } + + AllCheckCommand.Subscribe(_ => CheckChange(true)); + NoneCheckCommand.Subscribe(_ => CheckChange(false)); + + SaveCommand.Subscribe(_ => + { + for (var i = 0; i < groups.Count; i++) + { + Application.Current.Properties[$"grid_group_check{i}"] = groups[i].Check.Value; + } + Application.Current.SavePropertiesAsync(); + }); + + for (var i = 0; i < groups.Count; i++) + { + if (Application.Current.Properties.TryGetValue($"grid_group_check{i}", out var check)) + { + groups[i].Check.Value = (bool)check; + } + } + + RunCommand.Subscribe(async _ => + { + var param = new NavigationParameters(); + param.Add("tests", TestSections); + await navigationService.NavigateAsync("CollectionViewGroupTest", param); + }); + } + } +} diff --git a/Sample/Sample/ViewModels/GridTestIndexViewModel.cs b/Sample/Sample/ViewModels/GridTestIndexViewModel.cs new file mode 100644 index 0000000..90d8c95 --- /dev/null +++ b/Sample/Sample/ViewModels/GridTestIndexViewModel.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using Sample.ViewModels.Tests; +using System.Linq; +using Reactive.Bindings; +using Xamarin.Forms; +using Prism.Navigation; + +namespace Sample.ViewModels +{ + public class GridTestIndexViewModel + { + public ReactiveCommand RunCommand { get; } = new ReactiveCommand(); + public ReactiveCommand AllCheckCommand { get; } = new ReactiveCommand(); + public ReactiveCommand NoneCheckCommand { get; } = new ReactiveCommand(); + public ReactiveCommand SaveCommand { get; } = new ReactiveCommand(); + + public List TestSections { get; } = new List(); + public GridTestIndexViewModel(INavigationService navigationService) + { + var Section = new TestSection { SectionTitle = "Fundamental" }; + Section.Add(new PullToRefreshTest()); + Section.Add(new RowSpacingAndHeightTest()); + Section.Add(new ColorTest()); + + TestSections.Add(Section); + + Section = new TestSection { SectionTitle = "GridType" }; + Section.Add(new UniformGridTest()); + Section.Add(new AutoSpacingTest()); + + TestSections.Add(Section); + + Section = new TestSection { SectionTitle = "Individual" }; + Section.Add(new GridManipulationTest()); + + TestSections.Add(Section); + + var groups = TestSections.SelectMany(x => x).ToList(); + + + void CheckChange(bool turned) + { + foreach (var grp in groups) + { + grp.Check.Value = turned; + } + } + + AllCheckCommand.Subscribe(_ => CheckChange(true)); + NoneCheckCommand.Subscribe(_ => CheckChange(false)); + + SaveCommand.Subscribe(_ => + { + for (var i = 0; i < groups.Count; i++) + { + Application.Current.Properties[$"check{i}"] = groups[i].Check.Value; + } + Application.Current.SavePropertiesAsync(); + }); + + for (var i = 0; i < groups.Count; i++) + { + if (Application.Current.Properties.TryGetValue($"check{i}", out var check)) + { + groups[i].Check.Value = (bool)check; + } + } + + RunCommand.Subscribe(async _ => + { + var param = new NavigationParameters(); + param.Add("tests", TestSections); + await navigationService.NavigateAsync("CollectionViewTest", param); + }); + } + } +} diff --git a/Sample/Sample/ViewModels/TestFormViewModel.cs b/Sample/Sample/ViewModels/TestFormViewModel.cs index 026595d..5692fce 100644 --- a/Sample/Sample/ViewModels/TestFormViewModel.cs +++ b/Sample/Sample/ViewModels/TestFormViewModel.cs @@ -4,6 +4,12 @@ using Unity.Attributes; using Prism.Services; using System.Linq; +using Xamarin.Forms; +using System.Reflection; +using System.Threading.Tasks; +using Sample.Views; +using AiForms.Dialogs; + namespace Sample.ViewModels { public class TestFormViewModel @@ -71,5 +77,78 @@ public class TestItem public bool Result { get; set; } public Action Action { get; set; } public Action CancelAction { get; set; } + + public bool IsFirstItem { get; set; } + public bool IsLastItem { get; set; } + public LayoutAlignment VAlign { get; set; } = LayoutAlignment.Center; + public TestGroup Parent { get; set; } + + public async void Run() + { + if(IsFirstItem) + { + Toast.Instance.Show(new {Message=Parent.GroupTitle,VAlign=LayoutAlignment.Start}); + Parent?.Initialize(); + await Task.Delay(500); + } + Toast.Instance.Show(this); + Parent.SetUp(); + await Task.Delay(500); + Action?.Invoke(); + + if(IsLastItem) + { + Parent?.Destroy(); + } + } + } + + public class TestAttribute:Attribute{ + public string Message { get; set; } + } + + public class TestGroup:List + { + public CollectionViewTestViewModel VM { get; set; } + public string GroupTitle { get; set; } + public ReactivePropertySlim Check { get; } = new ReactivePropertySlim(); + + + public TestGroup(string groupTitle) + { + GroupTitle = groupTitle; + var methods = this.GetType().GetMethods().Where(x => x.GetCustomAttribute() != null); + + foreach (var method in methods) + { + var methodAction = (Action)method.CreateDelegate(typeof(Action), this); + var testAttr = method.GetCustomAttribute(); + + Add(new TestItem { Parent = this,Action = methodAction, Message = testAttr.Message }); + } + + this[0].IsFirstItem = true; + this[methods.Count() - 1].IsLastItem = true; + } + + public virtual void Initialize(){} + + public virtual void Destroy(){} + + public virtual void SetUp(){} + + } + + public class TestSection:List + { + public string SectionTitle { get; set; } + + public void SetViewModel(CollectionViewTestViewModel vm) + { + foreach(var group in this) + { + group.VM = vm; + } + } } } diff --git a/Sample/Sample/ViewModels/Tests/AutoSpacingTest.cs b/Sample/Sample/ViewModels/Tests/AutoSpacingTest.cs new file mode 100644 index 0000000..c9f3991 --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/AutoSpacingTest.cs @@ -0,0 +1,104 @@ +using System; +using System.Threading.Tasks; + +namespace Sample.ViewModels.Tests +{ + public class AutoSpacingTest:TestGroup + { + public AutoSpacingTest():base("AutoSpacing") + { + } + + public override void Initialize() + { + base.Initialize(); + VM.GridType.Value = AiForms.Renderers.GridType.AutoSpacingGrid; + VM.ColumnWidth.Value = 150; + VM.SpacingType.Value = AiForms.Renderers.SpacingType.Between; + VM.ColumnSpacing.Value = 4; + } + + public override void Destroy() + { + base.Destroy(); + Initialize(); + } + + [Test(Message = "Has Colum width been changed 150 to 120 to 90 to 60 with keeping Between?")] + public async void ColumnNumberDecrement() + { + VM.ColumnWidth.Value = 120; + await Task.Delay(1000); + VM.ColumnWidth.Value = 90; + await Task.Delay(1000); + VM.ColumnWidth.Value = 60; + } + + [Test(Message = "Has SpacingType been changed to Center?")] + public void ChangeTypeCenter() + { + VM.SpacingType.Value = AiForms.Renderers.SpacingType.Center; + } + + [Test(Message = "Has Colum width been changed 60 to 90 to 120 to 150 with keeping Center?")] + public async void ColumnNumberIncrement() + { + VM.ColumnWidth.Value = 90; + await Task.Delay(1000); + VM.ColumnWidth.Value = 120; + await Task.Delay(1000); + VM.ColumnWidth.Value = 150; + } + + [Test(Message = "Has ColumnSpacing been changed 0?")] + public void ChangeSpacing0() + { + VM.ColumnSpacing.Value = 0; + } + + [Test(Message = "Has Colum width been changed 150 to 120 to 90 to 60 with keeping Center?")] + public async void ColumnNumberDecrement2() + { + VM.ColumnWidth.Value = 120; + await Task.Delay(1000); + VM.ColumnWidth.Value = 90; + await Task.Delay(1000); + VM.ColumnWidth.Value = 60; + } + + [Test(Message = "Change Landscape.")] + public void ChangeLandscape() + { + VM.ColumnSpacing.Value = 4; + } + + [Test(Message = "Has Colum width been changed 60 to 90 to 120 to 150 with keeping Center?")] + public async void ColumnNumberIncrement2() + { + VM.ColumnWidth.Value = 90; + await Task.Delay(1000); + VM.ColumnWidth.Value = 120; + await Task.Delay(1000); + VM.ColumnWidth.Value = 150; + } + + [Test(Message = "Has SpacingType been changed to Between?")] + public void ChnageBetweeen() + { + VM.SpacingType.Value = AiForms.Renderers.SpacingType.Between; + } + + [Test(Message = "Has Colum width been changed 150 to 120 to 90 to 60 with keeping Between?")] + public async void ColumnNumberDecrement3() + { + VM.ColumnWidth.Value = 120; + await Task.Delay(1000); + VM.ColumnWidth.Value = 90; + await Task.Delay(1000); + VM.ColumnWidth.Value = 60; + } + + [Test(Message = "Change Portrait")] + public void ChangePortrait(){} + } +} diff --git a/Sample/Sample/ViewModels/Tests/ColorTest.cs b/Sample/Sample/ViewModels/Tests/ColorTest.cs new file mode 100644 index 0000000..951d500 --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/ColorTest.cs @@ -0,0 +1,38 @@ +using System; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace Sample.ViewModels.Tests +{ + public class ColorTest:TestGroup + { + public ColorTest():base("Color") + { + } + + public override void SetUp() + { + base.SetUp(); + VM.Background.Value = Color.White; + VM.FeedbackColor.Value = Color.Yellow; + } + + [Test(Message = "Has Background turned from Yellow to White to Green to transparent?")] + public async void BackgroundColor() + { + VM.Background.Value = Color.Yellow; + await Task.Delay(1000); + VM.Background.Value = Color.White; + await Task.Delay(1000); + VM.Background.Value = Color.Green; + await Task.Delay(1000); + VM.Background.Value = Color.Transparent; + } + + [Test(Message = "Tap some cells. Has FeedBack color turned Red?")] + public void FeedbackColor() + { + VM.FeedbackColor.Value = Color.Red; + } + } +} diff --git a/Sample/Sample/ViewModels/Tests/GridGroupManipulationTest.cs b/Sample/Sample/ViewModels/Tests/GridGroupManipulationTest.cs new file mode 100644 index 0000000..6f5efe8 --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/GridGroupManipulationTest.cs @@ -0,0 +1,171 @@ +using System; +using System.Threading.Tasks; +using AiForms.Renderers; +using System.Collections.ObjectModel; +using Xamarin.Forms; +using System.Collections.Generic; + +namespace Sample.ViewModels.Tests +{ + public class GridGroupManipulationTest:TestGroup + { + + IScrollController ScrollController => VM.ScrollController; + PhotoGroup ItemsSource => VM.ItemsSource; + ObservableCollection ItemsGroupSource => VM.ItemsGroupSource; + PhotoGroup _additionalGroup; + + public GridGroupManipulationTest():base("GridGroupManipulation") + { + } + + public override void Initialize() + { + base.Initialize(); + var list = new List(); + for (var i = 5; i < 15; i++) + { + list.Add(new PhotoItem + { + PhotoUrl = $"https://kamusoft.jp/openimage/nativecell/{i + 1}.jpg", + Title = $"Title {i + 1}", + Category = "DDD", + }); + } + _additionalGroup = new PhotoGroup(list) { Head = "SectionD" }; + + } + + [Test(Message = "Has SectionB been scrolled to Top to Bottom To Center?")] + public async void ScrollTest() + { + ScrollController.ScrollToStart(); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Start, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.End, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Center, false); + } + + [Test(Message = "Has SectionB been scrolled to Top to Bottom To Center with animation?")] + public async void ScrollTest2() + { + ScrollController.ScrollToStart(true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Start, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.End, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[1][0], ItemsGroupSource[1], ScrollToPosition.Center, true); + } + + [Test(Message = "Has SectionC - Title14 been scrolled to Top to Bottom To Center?")] + public async void ScrollTest3() + { + ScrollController.ScrollToStart(false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Start, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.End, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Center, false); + } + + [Test(Message = "Has SectionC - Title14 been scrolled to Top to Bottom To Center with animation?")] + public async void ScrollTest4() + { + ScrollController.ScrollToStart(true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Start, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.End, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsGroupSource[2][3], ItemsGroupSource[2], ScrollToPosition.Center, true); + } + + [Test(Message = "Has new cell been inserted before Title1?")] + public async void InsertTest() + { + ScrollController.ScrollToStart(true); + await Task.Delay(2000); + ItemsGroupSource[0].Insert(0, VM.GetAdditionalItem()); + } + + [Test(Message = "Has new cell been inserted after Title20?")] + public async void InsertTest2() + { + ScrollController.ScrollTo(ItemsGroupSource[0][20], ItemsGroupSource[0], ScrollToPosition.End, true); + await Task.Delay(2000); + ItemsGroupSource[0].Add(VM.GetAdditionalItem()); + } + + [Test(Message = "Has new cell been inserted between Title8 and Title9?")] + public async void InsertTest3() + { + ScrollController.ScrollTo(ItemsGroupSource[0][8], ItemsGroupSource[0], ScrollToPosition.Center, true); + await Task.Delay(2000); + ItemsGroupSource[0].Insert(9, VM.GetAdditionalItem()); + } + + [Test(Message = "Has the first cell been deleted?")] + public async void DeleteTest() + { + ScrollController.ScrollToStart(true); + await Task.Delay(2000); + ItemsGroupSource[0].RemoveAt(0); + } + + [Test(Message = "Has the last cell in SectionA been deleted?")] + public async void DeleteTest2() + { + ScrollController.ScrollTo(ItemsGroupSource[0][21], ItemsGroupSource[0], ScrollToPosition.End, true); + await Task.Delay(2000); + ItemsGroupSource[0].RemoveAt(ItemsGroupSource[0].Count - 1); + } + + [Test(Message = "Has the cell between Title8 and Title9 in SectionA been deleted?")] + public async void DeleteTest3() + { + ScrollController.ScrollTo(ItemsGroupSource[0][8], ItemsGroupSource[0], ScrollToPosition.Center, true); + await Task.Delay(2000); + ItemsGroupSource[0].RemoveAt(8); + } + + [Test(Message = "Has the first cell been changed to AddItem?")] + public async void ReplaceTest() + { + ScrollController.ScrollToStart(true); + await Task.Delay(2000); + ItemsGroupSource[0][0] = VM.GetAdditionalItem(); + } + + [Test(Message = "Has the first cell been moved to after Title5?")] + public async void MoveTest() + { + ScrollController.ScrollToStart(true); + await Task.Delay(2000); + ItemsGroupSource[0].Move(0, 4); + } + + [Test(Message = "Has new section been inserted at last?")] + public async void SectionInsertTest() + { + await Task.Delay(2000); + ItemsGroupSource.Add(_additionalGroup); + await Task.Delay(2000); + ScrollController.ScrollToEnd(true); + } + + [Test(Message = "Has the last section been deleted?")] + public async void SectionDeleteTest() + { + await Task.Delay(2000); + ItemsGroupSource.Remove(_additionalGroup); + await Task.Delay(2000); + ScrollController.ScrollToEnd(true); + } + + + } +} diff --git a/Sample/Sample/ViewModels/Tests/GridManipulationTest.cs b/Sample/Sample/ViewModels/Tests/GridManipulationTest.cs new file mode 100644 index 0000000..bc4ccb5 --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/GridManipulationTest.cs @@ -0,0 +1,106 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using AiForms.Renderers; +using Xamarin.Forms; + +namespace Sample.ViewModels.Tests +{ + public class GridManipulationTest:TestGroup + { + IScrollController ScrollController => VM.ScrollController; + PhotoGroup ItemsSource => VM.ItemsSource; + + public GridManipulationTest():base("GridManipulation") + { + } + + [Test(Message = "Has Title10 been scrolled to Top to Bottom To Center?")] + public async void ScrollTest() + { + ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Start, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.End, false); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Center, false); + } + + [Test(Message = "Has Title10 been scrolled to Top to Bottom To Center with animation?")] + public async void ScrollAnimeTest() + { + ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Start, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.End, true); + await Task.Delay(2000); + ScrollController.ScrollTo(ItemsSource[9], ScrollToPosition.Center, true); + } + + [Test(Message = "Has new cell been inserted before Title1?")] + public async void InsertTest() + { + ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); + await Task.Delay(2000); + ItemsSource.Insert(0, VM.GetAdditionalItem()); + } + + [Test(Message = "Has new cell been inserted after Title20?")] + public async void InsertTest2() + { + ScrollController.ScrollTo(ItemsSource.Last(), ScrollToPosition.End, true); + await Task.Delay(2000); + ItemsSource.Add(VM.GetAdditionalItem()); + } + + [Test(Message = "Has new cell been inserted between Title8 and Title9?")] + public async void InsertTest3() + { + ScrollController.ScrollTo(ItemsSource[8], ScrollToPosition.Center, true); + await Task.Delay(2000); + ItemsSource.Insert(9, VM.GetAdditionalItem()); + } + + [Test(Message = "Has the first cell been deleted?")] + public async void DeleteTest() + { + ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); + await Task.Delay(2000); + ItemsSource.RemoveAt(0); + } + + [Test(Message = "Has the last cell been deleted?")] + public async void DeleteTest2() + { + ScrollController.ScrollTo(ItemsSource.Last(), ScrollToPosition.End, true); + await Task.Delay(2000); + ItemsSource.RemoveAt(ItemsSource.Count - 1); + } + + [Test(Message = "Has the cell between Title8 and Title9 been deleted?")] + public async void DeleteTest3() + { + ScrollController.ScrollTo(ItemsSource[8], ScrollToPosition.Center, true); + await Task.Delay(2000); + ItemsSource.RemoveAt(8); + } + + [Test(Message = "Has the first cell been changed to AddItem?")] + public async void ReplaceTest() + { + ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); + await Task.Delay(2000); + ItemsSource[0] = VM.GetAdditionalItem(); + } + + [Test(Message = "Has the first cell been moved to after Title5?")] + public async void MoveTest() + { + ScrollController.ScrollTo(ItemsSource.First(), ScrollToPosition.Start, true); + await Task.Delay(2000); + ItemsSource.Move(0, 4); + } + } +} diff --git a/Sample/Sample/ViewModels/Tests/PullToRefreshTest.cs b/Sample/Sample/ViewModels/Tests/PullToRefreshTest.cs new file mode 100644 index 0000000..7fdf179 --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/PullToRefreshTest.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace Sample.ViewModels.Tests +{ + public class PullToRefreshTest:TestGroup + { + public PullToRefreshTest():base("PullToRefresh"){} + + public override void SetUp() + { + base.SetUp(); + VM.EnabledPullToRefresh.Value = true; + VM.RefreshIconColor.Value = Color.DimGray; + } + + [Test(Message = "PullToRefresh can't be work.")] + public void Disabled() + { + VM.EnabledPullToRefresh.Value = false; + } + + [Test(Message = "Can PullToRefresh be work?")] + public void Enabled() + { + VM.EnabledPullToRefresh.Value = true; + } + + [Test(Message = "Has Refresh icon turned red?")] + public void TurnIconColor() + { + VM.RefreshIconColor.Value = Color.Red; + } + } +} diff --git a/Sample/Sample/ViewModels/Tests/RowSpacingAndHeightTest.cs b/Sample/Sample/ViewModels/Tests/RowSpacingAndHeightTest.cs new file mode 100644 index 0000000..8d6c3da --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/RowSpacingAndHeightTest.cs @@ -0,0 +1,72 @@ +using System; +namespace Sample.ViewModels.Tests +{ + public class RowSpacingAndHeightTest:TestGroup + { + public RowSpacingAndHeightTest():base("RowSpacingAndHeight") + { + } + + public override void SetUp() + { + base.SetUp(); + VM.RowSpacing.Value = 4.0; + VM.GroupFirstSpacing.Value = 0; + VM.GroupLastSpacing.Value = 0; + VM.ColumnHeight.Value = 1.0; + VM.IsGroupHeaderSticky.Value = true; + VM.AdditionalHeight.Value = 0; + VM.HeaderHeight.Value = 36; + } + + [Test(Message = "Has RowSpacing become much larger?")] + public void RowSpacing() + { + VM.RowSpacing.Value = 25; + } + + [Test(Message = "Has Group First Spacing been 30px in Grouped?")] + public void FirstSpacing() + { + VM.GroupFirstSpacing.Value = 30; + } + + [Test(Message = "Has Group Last Spacing been 30px in Grouped?")] + public void LastSpacing() + { + VM.GroupLastSpacing.Value = 30; + } + + [Test(Message = "Has ColumnHeight been changed to absolute value(250px)?")] + public void ColumnHeightAbsolute() + { + VM.ColumnHeight.Value = 250; + } + + [Test(Message = "Has ColumnHeight been changed to relative value(0.5)?")] + public void ColumnHeightProportional() + { + VM.ColumnHeight.Value = 0.5; + } + + [Test(Message = "Has ColumnHeight been changed to 1.0 + 50px by AdditionalHeight?")] + public void AdditionalHeight() + { + VM.AdditionalHeight.Value = 50; + } + + [Test(Message = "Has GroupHeaderHeight been twice as large as the privious?")] + public void GroupHeaderHeight() + { + VM.HeaderHeight.Value *= 2; + } + + + [Test(Message = "Has HeaderCell position been released from sticky? (iOS)")] + public void Sticky() + { + VM.IsGroupHeaderSticky.Value = false; + } + + } +} diff --git a/Sample/Sample/ViewModels/Tests/UniformGridTest.cs b/Sample/Sample/ViewModels/Tests/UniformGridTest.cs new file mode 100644 index 0000000..1326772 --- /dev/null +++ b/Sample/Sample/ViewModels/Tests/UniformGridTest.cs @@ -0,0 +1,102 @@ +using System; +using System.Threading.Tasks; + +namespace Sample.ViewModels.Tests +{ + public class UniformGridTest : TestGroup + { + public UniformGridTest() : base("UniformGrid") + { + } + + public override void Initialize() + { + base.Initialize(); + VM.GridType.Value = AiForms.Renderers.GridType.UniformGrid; + VM.PortraitColumns.Value = 2; + VM.LandscapeColumns.Value = 4; + VM.BothSidesMargin.Value = 10; + VM.ColumnSpacing.Value = 4; + } + + public override void Destroy() + { + base.Destroy(); + Initialize(); + } + + public override void SetUp() + { + base.SetUp(); + } + + [Test(Message = "Has Colums number been changed 2 to 3 to 4 to 5 to 6 on Portrait?")] + public async void ColumnNumberIncrement() + { + VM.PortraitColumns.Value = 3; + await Task.Delay(1000); + VM.PortraitColumns.Value = 4; + await Task.Delay(1000); + VM.PortraitColumns.Value = 5; + await Task.Delay(1000); + VM.PortraitColumns.Value = 6; + } + + [Test(Message = "Has ColumnSpacing / BothSidesMargin been changed 0?")] + public void SpacingAndMargin() + { + VM.ColumnSpacing.Value = 0; + VM.BothSidesMargin.Value = 0; + } + + [Test(Message = "Has Colums number been changed 6 to 5 to 4 to 3 to 2 on Portrait?")] + public async void ColumnNumberDecrement() + { + VM.PortraitColumns.Value = 5; + await Task.Delay(1000); + VM.PortraitColumns.Value = 4; + await Task.Delay(1000); + VM.PortraitColumns.Value = 3; + await Task.Delay(1000); + VM.PortraitColumns.Value = 2; + } + + [Test(Message = "Change Landscape. Is Columns number 4?")] + public void ChangeLandscape() { } + + [Test(Message = "Has Colums number been changed 5 to 6 to 7 to 8 on Landscape?")] + public async void LandscapeColumnNumber() + { + VM.LandscapeColumns.Value = 5; + await Task.Delay(1000); + VM.LandscapeColumns.Value = 6; + await Task.Delay(1000); + VM.LandscapeColumns.Value = 7; + await Task.Delay(1000); + VM.LandscapeColumns.Value = 8; + await Task.Delay(1000); + } + + [Test(Message = "Have ColumnSpacing and BothSidesMargin been changed 4 and 10?")] + public void SpacingAndMargin2() + { + VM.ColumnSpacing.Value = 4; + VM.BothSidesMargin.Value = 10; + } + + [Test(Message = "Has Colums number been changed 8 to 7 to 6 to 5 to 4 on Landscape?")] + public async void LandscapeColumnNumber2() + { + VM.LandscapeColumns.Value = 7; + await Task.Delay(1000); + VM.LandscapeColumns.Value = 6; + await Task.Delay(1000); + VM.LandscapeColumns.Value = 5; + await Task.Delay(1000); + VM.LandscapeColumns.Value = 4; + } + + [Test(Message = "Change Portrait")] + public void ChangePortrait() { } + } +} diff --git a/Sample/Sample/Views/CollectionVIewTest.xaml b/Sample/Sample/Views/CollectionVIewTest.xaml index 9247afd..9f036d5 100644 --- a/Sample/Sample/Views/CollectionVIewTest.xaml +++ b/Sample/Sample/Views/CollectionVIewTest.xaml @@ -8,77 +8,67 @@ x:Class="Sample.Views.CollectionViewTest"> - + + + - - - - RecycleElement - - - - - - - - - - - - + + + RecycleElement + - - - - - - - - - - + + + + + + + + + + diff --git a/Sample/Sample/Views/CollectionViewGroupTest.xaml b/Sample/Sample/Views/CollectionViewGroupTest.xaml index 73ee59c..ed2ec7c 100644 --- a/Sample/Sample/Views/CollectionViewGroupTest.xaml +++ b/Sample/Sample/Views/CollectionViewGroupTest.xaml @@ -7,87 +7,74 @@ xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" x:Class="Sample.Views.CollectionViewGroupTest"> - - - - - - + + + - - - - RecycleElement - - - - - - - - - - - - - - - - - + + + + RecycleElement + + + + + + + + + + + + + + + + + - - - - - - - - - - diff --git a/Sample/Sample/Views/GridGroupTestIndex.xaml b/Sample/Sample/Views/GridGroupTestIndex.xaml new file mode 100644 index 0000000..f12fc87 --- /dev/null +++ b/Sample/Sample/Views/GridGroupTestIndex.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sample/Sample/Views/GridGroupTestIndex.xaml.cs b/Sample/Sample/Views/GridGroupTestIndex.xaml.cs new file mode 100644 index 0000000..044498a --- /dev/null +++ b/Sample/Sample/Views/GridGroupTestIndex.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Sample.Views +{ + public partial class GridGroupTestIndex : ContentPage + { + public GridGroupTestIndex() + { + InitializeComponent(); + } + } +} diff --git a/Sample/Sample/Views/GridTestIndex.xaml b/Sample/Sample/Views/GridTestIndex.xaml new file mode 100644 index 0000000..48ea251 --- /dev/null +++ b/Sample/Sample/Views/GridTestIndex.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sample/Sample/Views/GridTestIndex.xaml.cs b/Sample/Sample/Views/GridTestIndex.xaml.cs new file mode 100644 index 0000000..3772218 --- /dev/null +++ b/Sample/Sample/Views/GridTestIndex.xaml.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +using Xamarin.Forms; + +namespace Sample.Views +{ + public partial class GridTestIndex : ContentPage + { + public GridTestIndex() + { + InitializeComponent(); + } + } +} diff --git a/Sample/Sample/Views/MainPage.xaml b/Sample/Sample/Views/MainPage.xaml index 7c65d16..30eeed1 100644 --- a/Sample/Sample/Views/MainPage.xaml +++ b/Sample/Sample/Views/MainPage.xaml @@ -7,10 +7,12 @@