From 870f9c98ffccce86d80c6ff7a05de7238fc1b0e8 Mon Sep 17 00:00:00 2001 From: kingces95 Date: Thu, 7 Apr 2016 14:55:19 -0700 Subject: [A, iOS] CarouselView Bug Fixes (#49) * CarouselView programatic scrolling fixes; swipe back fixes * Make iOS CarouselView events consistant with Android * bump swipe distance; add Screenshot on Exception * Formatting. No logical change. * Comment out [Test] on UITest and fix TestCloud failures later. --- .../Renderers/CarouselViewRenderer.cs | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'Xamarin.Forms.Platform.Android') diff --git a/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs index b44ef3e6..12a1157a 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs @@ -267,7 +267,7 @@ namespace Xamarin.Forms.Platform.Android internal override bool CanScrollHorizontally => true; internal override bool CanScrollVertically => false; - internal override IntRectangle GetBounds(int originPosition, RecyclerView.State state) => + internal override IntRectangle GetBounds(int originPosition, State state) => new IntRectangle( LayoutItem(originPosition, 0).Location, new IntSize(_itemSize.Width * state.ItemCount, _itemSize.Height) @@ -583,7 +583,7 @@ namespace Xamarin.Forms.Platform.Android } // initialize properties - VisualElementController.SetValueFromRenderer(CarouselView.PositionProperty, 0); + _position = Element.Position; // initialize events Element.CollectionChanged += OnCollectionChanged; @@ -778,10 +778,7 @@ namespace Xamarin.Forms.Platform.Android AdapterChangeType _adapterChangeType; #endregion - public PhysicalLayoutManager( - Context context, - VirtualLayoutManager virtualLayout, - int positionOrigin) + internal PhysicalLayoutManager(Context context, VirtualLayoutManager virtualLayout, int positionOrigin) { _positionOrigin = positionOrigin; _context = context; @@ -793,7 +790,7 @@ namespace Xamarin.Forms.Platform.Android _scroller = new SeekAndSnapScroller( context: context, vectorToPosition: adapterPosition => { - var end = virtualLayout.LayoutItem(positionOrigin, adapterPosition).Center(); + var end = virtualLayout.LayoutItem(_positionOrigin, adapterPosition).Center(); var begin = Viewport.Center(); return end - begin; } @@ -853,24 +850,24 @@ namespace Xamarin.Forms.Platform.Android base.Dispose(disposing); } - public event Action OnAppearing; - public event Action OnBeginScroll; - public event Action OnDisappearing; - public event Action OnEndScroll; + internal event Action OnAppearing; + internal event Action OnBeginScroll; + internal event Action OnDisappearing; + internal event Action OnEndScroll; - public IntVector Velocity => _samples.Aggregate((o, a) => o + a) / _samples.Count; - public void Layout(int width, int height) + internal IntVector Velocity => _samples.Aggregate((o, a) => o + a) / _samples.Count; + internal void Layout(int width, int height) { // e.g. when rotated the width and height are updated the virtual layout will // need to resize and provide a new viewport offset given the current one. _virtualLayout.Layout(_positionOrigin, new IntSize(width, height), ref _locationOffset); } - public IntRectangle Viewport => Rectangle + _locationOffset; - public IEnumerable VisiblePositions() + internal IntRectangle Viewport => Rectangle + _locationOffset; + internal IEnumerable VisiblePositions() { return _visibleAdapterPosition; } - public IEnumerable Views() + internal IEnumerable Views() { return _viewByAdaptorPosition.Values; } -- cgit v1.2.3