maui-linux/Xamarin.Forms.Platform.iOS/CollectionView/HorizontalTemplatedCell.cs

34 строки
868 B
C#
Исходник Обычный вид История

[Enhancement] Add CollectionView progress behind feature flag (#4265) * The barest beginnings of starting a spike for LV2 * Very basic RecyclerView * Very, very basic UICollectionView * Start setting up galleries * De-duplicate some gallery code * Android horizontal layout * Very basic horizontal/vertical text lists for iOS * Vertical list views working in iOS, stashing while trying to figure out what the deal is with horizontal views and frames with heights of 1 * Working on rotation issues in iOS * Fix name of renderer in UWP; make horizontal scrolling work for horizontal lists on UWP * Set up gallery to generate different sizes of lists for testing * Respond to items source updates on UWP * Add gallery for GridLayout; Add GridLayout; begin GridLayout implementation UWP * Basic UWP gridness * Add demo page for grid layouts with text; Handle grid layout spans on UWP; handle grid layout span changes on UWP; * Implement span updates on Android grid layouts; * Ironed out most of the iOS text cell layout issues * iOS vertical/horizontal text lists now working reliably; * In progress on UWP DataTemplate stuff * Dumping the data template into the itemsource * Vertical list basically working with DataTemplate; horizontal list having image size issues * Clean up names and move classes to their own files * Adding some notes for FormsContentControl * Rolling back platform test on UWP * Fix Tizen build * Fix typo and roll back old test code * Remove old testing comments * Make basic data templates work on Android * Update measure to work horizontally * Remove old testing code * Terser rectangles * Use nameof() * Rename FormsContentControl to ItemContentControl * Use CreateRenderer instead of GetOrCreateRenderer * Clean up TemplateCodeCollectionViewGallery * Add grid galleries for templates * Nicer example templates * Create gallery to test removing items from collections * Smooth single item removal on Android * Smooth item insertion on Android * Observable collection item adds working on UWP * UWP Remove * Split files * Add gallery for snap points; start implementation of snap points on Android; * Move snap handling to separate class; implement Start snapping (horizontally) * Debugging vertical overlap issues on Android * Temporarily add IsClippedToBounds to generators to force clipping on Android * Start and End SnapHelpers are working horizontally and vertically * Consolidate some snap code on Android * Mandatory Single Snapping working for Center/Start horizontally * Throwing together scrollto gallery * Super basic "ScrollTo" implementation for Android, plus test page * Expand ScrollTo test harness; * Move ScrollToRequestEventArgs to its own file * Mostly working Carousel renderer; needs some cleanup and its own gallery pages * Carousel gallery * Naming cleanup * Make parameter name consistent * Finally some basic data template functionality for lists * Checkpoint; sort of working * Working out estimate size hacks * Working out cell optimizations * Checkpoint before some serious refactoring * Collapsing closer to a solution; text lists and grids working; template lists and grids working; uniform size hint mostly implemented; * Remove awkward Update method * No longer hard-coding list item heights estimates * Consolidate more code * Get rid of event on ItemsViewLayout * Remove public NeedsEstimate stuff * Get rid of IConstrainedCell * Watch for Span changes on iOS * Indexed ScrollTo on iOS * Implement removal/insertion of items on iOS * Handle Move, Reset, Replace on Android * Add screens to test ScrollTo Item; implement ScrollTo Item for iOS * ScrollTo Item working on Android, but only works for MakeVisible * Implement Android ScrollTo Animated ScrollToPosition * Ugly but functional non-animated scroll with ScrollToPosition * Move Scroll logic into helper class for clarity and maintenance * Fix Start snapping with grids (hard-coded span of 1) * Fix next/previous row/col snapping bug for EndSnapHelper * Remove some debug statements * Clean up example code * Fix missing delegate setting on CollectionView * Add filtering example * Watching the adapter and handling empty view from the renderer * Add debugging for all the FindViewHolder methods * Suuuuper basic but functional EmptyView * Allow EmptyView to be turned on and off * Building tests for all the EmptyView scenarios * Set Platform on EmptyView (for now) * Templated EmptyView on Android * Clean up merge errors * Require flag to use CollectionView on Android * Require flag to use CollectionView on UWP * Restore Label functionality commented out during testing * Adding a note for myself * Add flags for iOS; flags for Android CarouselView; * Remove Calabash out-commenting * Undo changes to DotSettings; remove outdated TODOs * Fix formatting * Remove debugging code; remove outdated todos; remove unnecessary comments * Undo randon VS changes * Include CollectionView in experimental renderer testing * Use correct property in nameof() call * Rename ScrollToRequestEventArgs Animate -> IsAnimated * Rename Constrain -> ConstrainTo for consistency * Add Core flags feature; add flag verification for CollectionView features * Make sure no one is subclassing native CollectionView stuff without flag * Set CollectionView flags for unit tests * Make flags depend on Application.Current * Fix iOS 9.3 exception when laying out CollectionView * Use Device.Flags * Move CV flag check to CollectionView; use Device.Flags on native platforms; * Move classes into their own files * Make CollectionView flag check method non-browseable * Remove old TODO * Remove Element.Platform sets * stubbed toolbox entries and snippets for Carousel and Collection * updated CV snippet to include layout * Remove Linq using statement * Remove unused using statement * Turn off CollectionView in Control Gallery * Move PropertyChangedEventArgsExtensions to internal on each platform * Clean up debugging code * Fix broken test setup * Remove ToString overrides * Fix broken test screen Fix broken test screen * Fix rebase errors * Update submodule * Fix rebase error
2018-11-13 15:49:08 +03:00
using System;
using CoreGraphics;
using Foundation;
using UIKit;
namespace Xamarin.Forms.Platform.iOS
{
internal sealed class HorizontalTemplatedCell : TemplatedCell
[Enhancement] Add CollectionView progress behind feature flag (#4265) * The barest beginnings of starting a spike for LV2 * Very basic RecyclerView * Very, very basic UICollectionView * Start setting up galleries * De-duplicate some gallery code * Android horizontal layout * Very basic horizontal/vertical text lists for iOS * Vertical list views working in iOS, stashing while trying to figure out what the deal is with horizontal views and frames with heights of 1 * Working on rotation issues in iOS * Fix name of renderer in UWP; make horizontal scrolling work for horizontal lists on UWP * Set up gallery to generate different sizes of lists for testing * Respond to items source updates on UWP * Add gallery for GridLayout; Add GridLayout; begin GridLayout implementation UWP * Basic UWP gridness * Add demo page for grid layouts with text; Handle grid layout spans on UWP; handle grid layout span changes on UWP; * Implement span updates on Android grid layouts; * Ironed out most of the iOS text cell layout issues * iOS vertical/horizontal text lists now working reliably; * In progress on UWP DataTemplate stuff * Dumping the data template into the itemsource * Vertical list basically working with DataTemplate; horizontal list having image size issues * Clean up names and move classes to their own files * Adding some notes for FormsContentControl * Rolling back platform test on UWP * Fix Tizen build * Fix typo and roll back old test code * Remove old testing comments * Make basic data templates work on Android * Update measure to work horizontally * Remove old testing code * Terser rectangles * Use nameof() * Rename FormsContentControl to ItemContentControl * Use CreateRenderer instead of GetOrCreateRenderer * Clean up TemplateCodeCollectionViewGallery * Add grid galleries for templates * Nicer example templates * Create gallery to test removing items from collections * Smooth single item removal on Android * Smooth item insertion on Android * Observable collection item adds working on UWP * UWP Remove * Split files * Add gallery for snap points; start implementation of snap points on Android; * Move snap handling to separate class; implement Start snapping (horizontally) * Debugging vertical overlap issues on Android * Temporarily add IsClippedToBounds to generators to force clipping on Android * Start and End SnapHelpers are working horizontally and vertically * Consolidate some snap code on Android * Mandatory Single Snapping working for Center/Start horizontally * Throwing together scrollto gallery * Super basic "ScrollTo" implementation for Android, plus test page * Expand ScrollTo test harness; * Move ScrollToRequestEventArgs to its own file * Mostly working Carousel renderer; needs some cleanup and its own gallery pages * Carousel gallery * Naming cleanup * Make parameter name consistent * Finally some basic data template functionality for lists * Checkpoint; sort of working * Working out estimate size hacks * Working out cell optimizations * Checkpoint before some serious refactoring * Collapsing closer to a solution; text lists and grids working; template lists and grids working; uniform size hint mostly implemented; * Remove awkward Update method * No longer hard-coding list item heights estimates * Consolidate more code * Get rid of event on ItemsViewLayout * Remove public NeedsEstimate stuff * Get rid of IConstrainedCell * Watch for Span changes on iOS * Indexed ScrollTo on iOS * Implement removal/insertion of items on iOS * Handle Move, Reset, Replace on Android * Add screens to test ScrollTo Item; implement ScrollTo Item for iOS * ScrollTo Item working on Android, but only works for MakeVisible * Implement Android ScrollTo Animated ScrollToPosition * Ugly but functional non-animated scroll with ScrollToPosition * Move Scroll logic into helper class for clarity and maintenance * Fix Start snapping with grids (hard-coded span of 1) * Fix next/previous row/col snapping bug for EndSnapHelper * Remove some debug statements * Clean up example code * Fix missing delegate setting on CollectionView * Add filtering example * Watching the adapter and handling empty view from the renderer * Add debugging for all the FindViewHolder methods * Suuuuper basic but functional EmptyView * Allow EmptyView to be turned on and off * Building tests for all the EmptyView scenarios * Set Platform on EmptyView (for now) * Templated EmptyView on Android * Clean up merge errors * Require flag to use CollectionView on Android * Require flag to use CollectionView on UWP * Restore Label functionality commented out during testing * Adding a note for myself * Add flags for iOS; flags for Android CarouselView; * Remove Calabash out-commenting * Undo changes to DotSettings; remove outdated TODOs * Fix formatting * Remove debugging code; remove outdated todos; remove unnecessary comments * Undo randon VS changes * Include CollectionView in experimental renderer testing * Use correct property in nameof() call * Rename ScrollToRequestEventArgs Animate -> IsAnimated * Rename Constrain -> ConstrainTo for consistency * Add Core flags feature; add flag verification for CollectionView features * Make sure no one is subclassing native CollectionView stuff without flag * Set CollectionView flags for unit tests * Make flags depend on Application.Current * Fix iOS 9.3 exception when laying out CollectionView * Use Device.Flags * Move CV flag check to CollectionView; use Device.Flags on native platforms; * Move classes into their own files * Make CollectionView flag check method non-browseable * Remove old TODO * Remove Element.Platform sets * stubbed toolbox entries and snippets for Carousel and Collection * updated CV snippet to include layout * Remove Linq using statement * Remove unused using statement * Turn off CollectionView in Control Gallery * Move PropertyChangedEventArgsExtensions to internal on each platform * Clean up debugging code * Fix broken test setup * Remove ToString overrides * Fix broken test screen Fix broken test screen * Fix rebase errors * Update submodule * Fix rebase error
2018-11-13 15:49:08 +03:00
{
public static NSString ReuseId = new NSString("Xamarin.Forms.Platform.iOS.HorizontalTemplatedCell");
[Enhancement] Add CollectionView progress behind feature flag (#4265) * The barest beginnings of starting a spike for LV2 * Very basic RecyclerView * Very, very basic UICollectionView * Start setting up galleries * De-duplicate some gallery code * Android horizontal layout * Very basic horizontal/vertical text lists for iOS * Vertical list views working in iOS, stashing while trying to figure out what the deal is with horizontal views and frames with heights of 1 * Working on rotation issues in iOS * Fix name of renderer in UWP; make horizontal scrolling work for horizontal lists on UWP * Set up gallery to generate different sizes of lists for testing * Respond to items source updates on UWP * Add gallery for GridLayout; Add GridLayout; begin GridLayout implementation UWP * Basic UWP gridness * Add demo page for grid layouts with text; Handle grid layout spans on UWP; handle grid layout span changes on UWP; * Implement span updates on Android grid layouts; * Ironed out most of the iOS text cell layout issues * iOS vertical/horizontal text lists now working reliably; * In progress on UWP DataTemplate stuff * Dumping the data template into the itemsource * Vertical list basically working with DataTemplate; horizontal list having image size issues * Clean up names and move classes to their own files * Adding some notes for FormsContentControl * Rolling back platform test on UWP * Fix Tizen build * Fix typo and roll back old test code * Remove old testing comments * Make basic data templates work on Android * Update measure to work horizontally * Remove old testing code * Terser rectangles * Use nameof() * Rename FormsContentControl to ItemContentControl * Use CreateRenderer instead of GetOrCreateRenderer * Clean up TemplateCodeCollectionViewGallery * Add grid galleries for templates * Nicer example templates * Create gallery to test removing items from collections * Smooth single item removal on Android * Smooth item insertion on Android * Observable collection item adds working on UWP * UWP Remove * Split files * Add gallery for snap points; start implementation of snap points on Android; * Move snap handling to separate class; implement Start snapping (horizontally) * Debugging vertical overlap issues on Android * Temporarily add IsClippedToBounds to generators to force clipping on Android * Start and End SnapHelpers are working horizontally and vertically * Consolidate some snap code on Android * Mandatory Single Snapping working for Center/Start horizontally * Throwing together scrollto gallery * Super basic "ScrollTo" implementation for Android, plus test page * Expand ScrollTo test harness; * Move ScrollToRequestEventArgs to its own file * Mostly working Carousel renderer; needs some cleanup and its own gallery pages * Carousel gallery * Naming cleanup * Make parameter name consistent * Finally some basic data template functionality for lists * Checkpoint; sort of working * Working out estimate size hacks * Working out cell optimizations * Checkpoint before some serious refactoring * Collapsing closer to a solution; text lists and grids working; template lists and grids working; uniform size hint mostly implemented; * Remove awkward Update method * No longer hard-coding list item heights estimates * Consolidate more code * Get rid of event on ItemsViewLayout * Remove public NeedsEstimate stuff * Get rid of IConstrainedCell * Watch for Span changes on iOS * Indexed ScrollTo on iOS * Implement removal/insertion of items on iOS * Handle Move, Reset, Replace on Android * Add screens to test ScrollTo Item; implement ScrollTo Item for iOS * ScrollTo Item working on Android, but only works for MakeVisible * Implement Android ScrollTo Animated ScrollToPosition * Ugly but functional non-animated scroll with ScrollToPosition * Move Scroll logic into helper class for clarity and maintenance * Fix Start snapping with grids (hard-coded span of 1) * Fix next/previous row/col snapping bug for EndSnapHelper * Remove some debug statements * Clean up example code * Fix missing delegate setting on CollectionView * Add filtering example * Watching the adapter and handling empty view from the renderer * Add debugging for all the FindViewHolder methods * Suuuuper basic but functional EmptyView * Allow EmptyView to be turned on and off * Building tests for all the EmptyView scenarios * Set Platform on EmptyView (for now) * Templated EmptyView on Android * Clean up merge errors * Require flag to use CollectionView on Android * Require flag to use CollectionView on UWP * Restore Label functionality commented out during testing * Adding a note for myself * Add flags for iOS; flags for Android CarouselView; * Remove Calabash out-commenting * Undo changes to DotSettings; remove outdated TODOs * Fix formatting * Remove debugging code; remove outdated todos; remove unnecessary comments * Undo randon VS changes * Include CollectionView in experimental renderer testing * Use correct property in nameof() call * Rename ScrollToRequestEventArgs Animate -> IsAnimated * Rename Constrain -> ConstrainTo for consistency * Add Core flags feature; add flag verification for CollectionView features * Make sure no one is subclassing native CollectionView stuff without flag * Set CollectionView flags for unit tests * Make flags depend on Application.Current * Fix iOS 9.3 exception when laying out CollectionView * Use Device.Flags * Move CV flag check to CollectionView; use Device.Flags on native platforms; * Move classes into their own files * Make CollectionView flag check method non-browseable * Remove old TODO * Remove Element.Platform sets * stubbed toolbox entries and snippets for Carousel and Collection * updated CV snippet to include layout * Remove Linq using statement * Remove unused using statement * Turn off CollectionView in Control Gallery * Move PropertyChangedEventArgsExtensions to internal on each platform * Clean up debugging code * Fix broken test setup * Remove ToString overrides * Fix broken test screen Fix broken test screen * Fix rebase errors * Update submodule * Fix rebase error
2018-11-13 15:49:08 +03:00
[Export("initWithFrame:")]
public HorizontalTemplatedCell(CGRect frame) : base(frame)
[Enhancement] Add CollectionView progress behind feature flag (#4265) * The barest beginnings of starting a spike for LV2 * Very basic RecyclerView * Very, very basic UICollectionView * Start setting up galleries * De-duplicate some gallery code * Android horizontal layout * Very basic horizontal/vertical text lists for iOS * Vertical list views working in iOS, stashing while trying to figure out what the deal is with horizontal views and frames with heights of 1 * Working on rotation issues in iOS * Fix name of renderer in UWP; make horizontal scrolling work for horizontal lists on UWP * Set up gallery to generate different sizes of lists for testing * Respond to items source updates on UWP * Add gallery for GridLayout; Add GridLayout; begin GridLayout implementation UWP * Basic UWP gridness * Add demo page for grid layouts with text; Handle grid layout spans on UWP; handle grid layout span changes on UWP; * Implement span updates on Android grid layouts; * Ironed out most of the iOS text cell layout issues * iOS vertical/horizontal text lists now working reliably; * In progress on UWP DataTemplate stuff * Dumping the data template into the itemsource * Vertical list basically working with DataTemplate; horizontal list having image size issues * Clean up names and move classes to their own files * Adding some notes for FormsContentControl * Rolling back platform test on UWP * Fix Tizen build * Fix typo and roll back old test code * Remove old testing comments * Make basic data templates work on Android * Update measure to work horizontally * Remove old testing code * Terser rectangles * Use nameof() * Rename FormsContentControl to ItemContentControl * Use CreateRenderer instead of GetOrCreateRenderer * Clean up TemplateCodeCollectionViewGallery * Add grid galleries for templates * Nicer example templates * Create gallery to test removing items from collections * Smooth single item removal on Android * Smooth item insertion on Android * Observable collection item adds working on UWP * UWP Remove * Split files * Add gallery for snap points; start implementation of snap points on Android; * Move snap handling to separate class; implement Start snapping (horizontally) * Debugging vertical overlap issues on Android * Temporarily add IsClippedToBounds to generators to force clipping on Android * Start and End SnapHelpers are working horizontally and vertically * Consolidate some snap code on Android * Mandatory Single Snapping working for Center/Start horizontally * Throwing together scrollto gallery * Super basic "ScrollTo" implementation for Android, plus test page * Expand ScrollTo test harness; * Move ScrollToRequestEventArgs to its own file * Mostly working Carousel renderer; needs some cleanup and its own gallery pages * Carousel gallery * Naming cleanup * Make parameter name consistent * Finally some basic data template functionality for lists * Checkpoint; sort of working * Working out estimate size hacks * Working out cell optimizations * Checkpoint before some serious refactoring * Collapsing closer to a solution; text lists and grids working; template lists and grids working; uniform size hint mostly implemented; * Remove awkward Update method * No longer hard-coding list item heights estimates * Consolidate more code * Get rid of event on ItemsViewLayout * Remove public NeedsEstimate stuff * Get rid of IConstrainedCell * Watch for Span changes on iOS * Indexed ScrollTo on iOS * Implement removal/insertion of items on iOS * Handle Move, Reset, Replace on Android * Add screens to test ScrollTo Item; implement ScrollTo Item for iOS * ScrollTo Item working on Android, but only works for MakeVisible * Implement Android ScrollTo Animated ScrollToPosition * Ugly but functional non-animated scroll with ScrollToPosition * Move Scroll logic into helper class for clarity and maintenance * Fix Start snapping with grids (hard-coded span of 1) * Fix next/previous row/col snapping bug for EndSnapHelper * Remove some debug statements * Clean up example code * Fix missing delegate setting on CollectionView * Add filtering example * Watching the adapter and handling empty view from the renderer * Add debugging for all the FindViewHolder methods * Suuuuper basic but functional EmptyView * Allow EmptyView to be turned on and off * Building tests for all the EmptyView scenarios * Set Platform on EmptyView (for now) * Templated EmptyView on Android * Clean up merge errors * Require flag to use CollectionView on Android * Require flag to use CollectionView on UWP * Restore Label functionality commented out during testing * Adding a note for myself * Add flags for iOS; flags for Android CarouselView; * Remove Calabash out-commenting * Undo changes to DotSettings; remove outdated TODOs * Fix formatting * Remove debugging code; remove outdated todos; remove unnecessary comments * Undo randon VS changes * Include CollectionView in experimental renderer testing * Use correct property in nameof() call * Rename ScrollToRequestEventArgs Animate -> IsAnimated * Rename Constrain -> ConstrainTo for consistency * Add Core flags feature; add flag verification for CollectionView features * Make sure no one is subclassing native CollectionView stuff without flag * Set CollectionView flags for unit tests * Make flags depend on Application.Current * Fix iOS 9.3 exception when laying out CollectionView * Use Device.Flags * Move CV flag check to CollectionView; use Device.Flags on native platforms; * Move classes into their own files * Make CollectionView flag check method non-browseable * Remove old TODO * Remove Element.Platform sets * stubbed toolbox entries and snippets for Carousel and Collection * updated CV snippet to include layout * Remove Linq using statement * Remove unused using statement * Turn off CollectionView in Control Gallery * Move PropertyChangedEventArgsExtensions to internal on each platform * Clean up debugging code * Fix broken test setup * Remove ToString overrides * Fix broken test screen Fix broken test screen * Fix rebase errors * Update submodule * Fix rebase error
2018-11-13 15:49:08 +03:00
{
}
public override CGSize Measure()
{
var measure = VisualElementRenderer.Element.Measure(double.PositiveInfinity,
ConstrainedDimension, MeasureFlags.IncludeMargins);
var width = VisualElementRenderer.Element.Width > 0
? VisualElementRenderer.Element.Width : measure.Request.Width;
return new CGSize(width, ConstrainedDimension);
}
public override void ConstrainTo(CGSize constraint)
{
ConstrainedDimension = constraint.Height;
Layout(constraint);
}
}
}