summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkingces95 <kingces95@users.noreply.github.com>2016-04-18 23:57:22 -0700
committerJason Smith <jason.smith@xamarin.com>2016-04-18 23:57:22 -0700
commitd51b17aece6bb5db839090616bc61fc6aac76b40 (patch)
treeccf8f4abdddbc1b2cdc0aa7dea4c1b8d7a0d71e3
parent279e4b01a329f59798e7a688e8501814c37e1385 (diff)
downloadxamarin-forms-d51b17aece6bb5db839090616bc61fc6aac76b40.tar.gz
xamarin-forms-d51b17aece6bb5db839090616bc61fc6aac76b40.tar.bz2
xamarin-forms-d51b17aece6bb5db839090616bc61fc6aac76b40.zip
Whitespace fixes (#110)
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselViewGallery.cs24
-rw-r--r--Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs166
-rw-r--r--Xamarin.Forms.Core/CarouselView.cs46
-rw-r--r--Xamarin.Forms.Core/IItemViewController.cs5
-rw-r--r--Xamarin.Forms.Core/ItemsViewSimple.cs44
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs124
-rw-r--r--Xamarin.Forms.Platform.WinRT/CarouselViewRenderer.cs7
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs26
8 files changed, 271 insertions, 171 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselViewGallery.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselViewGallery.cs
index 6288caa8..7c53b399 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselViewGallery.cs
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselViewGallery.cs
@@ -12,8 +12,8 @@ using NUnit.Framework;
namespace Xamarin.Forms.Controls
{
- [Preserve (AllMembers = true)]
- [Issue (IssueTracker.Github, 900000, "CarouselView General Tests")]
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Github, 900000, "CarouselView General Tests")]
public class CarouselViewGalleryTests
{
#if UITEST
@@ -24,7 +24,10 @@ namespace Xamarin.Forms.Controls
}
public interface IGalleryPage : IUIProxy
{
- string Name { get; }
+ string Name
+ {
+ get;
+ }
}
public class Gallery
@@ -98,7 +101,8 @@ namespace Xamarin.Forms.Controls
Queue<string> _expectedEvents;
int _eventId;
- public CarouselViewGallery() {
+ public CarouselViewGallery()
+ {
_itemIds = Enumerable.Range(0, InitialItems).ToList();
_currentPosition = InitialItemId;
_currentItem = _itemIds[_currentPosition];
@@ -184,8 +188,8 @@ namespace Xamarin.Forms.Controls
expectedPosition = 0;
// handle swipe past last
- else if (expectedPosition == Count && _currentPosition == Count -1)
- expectedPosition = Count -1;
+ else if (expectedPosition == Count && _currentPosition == Count - 1)
+ expectedPosition = Count - 1;
// anticipate events
ExpectMovementEvents(expectedPosition);
@@ -250,7 +254,8 @@ namespace Xamarin.Forms.Controls
{
var gallery = Gallery.Launch();
- try {
+ try
+ {
var carousel = gallery.NaviateToGallery<CarouselViewGallery>();
// start at something other than 0
@@ -280,11 +285,12 @@ namespace Xamarin.Forms.Controls
gallery.Screenshot("End");
}
- catch (Exception e) {
+ catch (Exception e)
+ {
gallery.Screenshot("End");
throw e;
}
}
#endif
- }
+ }
}
diff --git a/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs
index c2e0ef7f..e1e82507 100644
--- a/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs
+++ b/Xamarin.Forms.Controls/GalleryPages/CarouselViewGallery.cs
@@ -13,7 +13,7 @@ using NUnit.Framework;
namespace Xamarin.Forms.Controls
{
- [Preserve (AllMembers = true)]
+ [Preserve(AllMembers = true)]
public sealed class CarouselViewGallaryPage : ContentPage // or TestMasterDetailPage, etc ...
{
public abstract class Item
@@ -28,37 +28,48 @@ namespace Xamarin.Forms.Controls
}
public int Id => id;
- public string TypeName => GetType ().Name;
+ public string TypeName => GetType().Name;
+ }
+ public sealed class Foo : Item
+ {
+ }
+ public sealed class Bar : Item
+ {
+ }
+ public sealed class Baz : Item
+ {
+ }
+ public sealed class Poo : Item
+ {
+ }
+ public sealed class Moo : Item
+ {
}
- public sealed class Foo : Item { }
- public sealed class Bar : Item { }
- public sealed class Baz : Item { }
- public sealed class Poo : Item { }
- public sealed class Moo : Item { }
- [Preserve (AllMembers = true)]
+ [Preserve(AllMembers = true)]
public sealed class ItemView : ContentView
{
- public static readonly BindableProperty TextColorProperty = BindableProperty.Create (
+ public static readonly BindableProperty TextColorProperty = BindableProperty.Create(
propertyName: nameof(TextColor),
- returnType: typeof (Color),
- declaringType: typeof (ItemView),
+ returnType: typeof(Color),
+ declaringType: typeof(ItemView),
defaultValue: Color.White,
defaultBindingMode: BindingMode.TwoWay
);
- public static readonly BindableProperty ContextProperty = BindableProperty.Create (
+ public static readonly BindableProperty ContextProperty = BindableProperty.Create(
propertyName: nameof(Context),
- returnType: typeof (CarouselView),
- declaringType: typeof (ItemView),
+ returnType: typeof(CarouselView),
+ declaringType: typeof(ItemView),
defaultBindingMode: BindingMode.TwoWay
);
- public ItemView ()
+ public ItemView()
{
- var change = CreateButton("Change", "Change", (items, index) => items[index] = new Moo ());
+ var change = CreateButton("Change", "Change", (items, index) => items[index] = new Moo());
- var removeBar = new StackLayout {
+ var removeBar = new StackLayout
+ {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children = {
@@ -68,7 +79,8 @@ namespace Xamarin.Forms.Controls
}
};
- var addBar = new StackLayout {
+ var addBar = new StackLayout
+ {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children = {
@@ -82,17 +94,19 @@ namespace Xamarin.Forms.Controls
}
};
- var typeNameLabel = new Label () { StyleId = "typename" };
- typeNameLabel.SetBinding (Label.TextProperty, nameof(Item.TypeName));
+ var typeNameLabel = new Label() { StyleId = "typename" };
+ typeNameLabel.SetBinding(Label.TextProperty, nameof(Item.TypeName));
- var idLabel = new Label () {
+ var idLabel = new Label()
+ {
AutomationId = "ItemId",
StyleId = "id",
TextColor = Color.White
};
- idLabel.SetBinding (Label.TextProperty, nameof(Item.Id));
+ idLabel.SetBinding(Label.TextProperty, nameof(Item.Id));
- Content = new StackLayout {
+ Content = new StackLayout
+ {
Children = {
typeNameLabel,
idLabel,
@@ -102,7 +116,8 @@ namespace Xamarin.Forms.Controls
}
};
- PropertyChanged += (s, e) => {
+ PropertyChanged += (s, e) =>
+ {
if (e.PropertyName == "TextColor")
typeNameLabel.TextColor = TextColor;
};
@@ -110,45 +125,58 @@ namespace Xamarin.Forms.Controls
Button CreateButton(string text, string automationId, Action<IList<Item>, int> clicked)
{
- var button = new Button ();
+ var button = new Button();
button.AutomationId = automationId;
button.Text = text;
- button.Clicked += (s, e) => {
+ button.Clicked += (s, e) =>
+ {
var items = (IList<Item>)Context.ItemsSource;
- var index = items.IndexOf (BindingContext);
- clicked (items, index);
+ var index = items.IndexOf(BindingContext);
+ clicked(items, index);
};
return button;
}
public CarouselView Context
{
- get { return (CarouselView)GetValue (ContextProperty); }
- set { SetValue (ContextProperty, value); }
+ get
+ {
+ return (CarouselView)GetValue(ContextProperty);
+ }
+ set
+ {
+ SetValue(ContextProperty, value);
+ }
}
public Color TextColor
{
- get { return (Color)GetValue(TextColorProperty); }
- set { SetValue(TextColorProperty, value); }
+ get
+ {
+ return (Color)GetValue(TextColorProperty);
+ }
+ set
+ {
+ SetValue(TextColorProperty, value);
+ }
}
}
public sealed class MyDataTemplateSelector : DataTemplateSelector
{
- Dictionary<Type, Color> m_colorByType = new Dictionary<Type, Color> ();
- Dictionary<Type, DataTemplate> m_dataTemplateByType = new Dictionary<Type, DataTemplate> ();
+ Dictionary<Type, Color> m_colorByType = new Dictionary<Type, Color>();
+ Dictionary<Type, DataTemplate> m_dataTemplateByType = new Dictionary<Type, DataTemplate>();
public MyDataTemplateSelector()
{
- m_colorByType[typeof (Foo)] = Color.Green;
- m_colorByType[typeof (Bar)] = Color.Red;
+ m_colorByType[typeof(Foo)] = Color.Green;
+ m_colorByType[typeof(Bar)] = Color.Red;
}
- protected override DataTemplate OnSelectTemplate (object item, BindableObject container)
+ protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
- return OnSelectTemplate (item.GetType (), container);
+ return OnSelectTemplate(item.GetType(), container);
}
- DataTemplate OnSelectTemplate (Type itemType, BindableObject container)
+ DataTemplate OnSelectTemplate(Type itemType, BindableObject container)
{
DataTemplate dataTemplate;
if (!m_dataTemplateByType.TryGetValue(itemType, out dataTemplate))
@@ -158,26 +186,30 @@ namespace Xamarin.Forms.Controls
DataTemplate CreateTemplate(Type itemType, BindableObject container)
{
- var dataTemplate = new DataTemplate (typeof (ItemView));
+ var dataTemplate = new DataTemplate(typeof(ItemView));
Color color;
- if (!m_colorByType.TryGetValue (itemType, out color)) {
+ if (!m_colorByType.TryGetValue(itemType, out color))
+ {
color = Color.Pink;
- dataTemplate.SetValue (BackgroundColorProperty, Color.Black);
- } else {
- dataTemplate.SetValue (BackgroundColorProperty, Color.Blue);
+ dataTemplate.SetValue(BackgroundColorProperty, Color.Black);
+ }
+ else
+ {
+ dataTemplate.SetValue(BackgroundColorProperty, Color.Blue);
}
- dataTemplate.SetValue (ItemView.TextColorProperty, color);
- dataTemplate.SetValue (ItemView.ContextProperty, container);
+ dataTemplate.SetValue(ItemView.TextColorProperty, color);
+ dataTemplate.SetValue(ItemView.ContextProperty, container);
return dataTemplate;
}
}
static Button CreateButton(string text, string automationId, Action onClicked = null)
{
- var button = new Button {
- Text = text,
+ var button = new Button
+ {
+ Text = text,
AutomationId = automationId
};
@@ -190,7 +222,8 @@ namespace Xamarin.Forms.Controls
static Label CreateCopy(string text, string automationId = "") => CreateLabel(text, Color.White, automationId);
static Label CreateLabel(string text, Color color, string automationId)
{
- return new Label() {
+ return new Label()
+ {
TextColor = color,
Text = text,
AutomationId = automationId
@@ -221,9 +254,9 @@ namespace Xamarin.Forms.Controls
_position.Text = $"{_carouselView.Position}";
}
- public CarouselViewGallaryPage ()
+ public CarouselViewGallaryPage()
{
- _selector = new MyDataTemplateSelector ();
+ _selector = new MyDataTemplateSelector();
_items = new ObservableCollection<Item>() {
new Baz(),
new Poo(),
@@ -231,7 +264,8 @@ namespace Xamarin.Forms.Controls
new Bar(),
};
- _carouselView = new CarouselView {
+ _carouselView = new CarouselView
+ {
BackgroundColor = Color.Purple,
ItemsSource = _items,
ItemTemplate = _selector,
@@ -245,26 +279,29 @@ namespace Xamarin.Forms.Controls
_selectedPosition = CreateValue("?", "SelectedPosition");
_eventLog = CreateValue(string.Empty, "EventLog");
- _carouselView.ItemSelected += (s, o) => {
+ _carouselView.ItemSelected += (s, o) =>
+ {
var selectedItem = (Item)o.SelectedItem;
var selectedItemId = selectedItem.Id;
- if (selectedItem != _carouselView.Item)
- throw new Exception("CarouselView.Item != ItemSelected");
+ if (selectedItem != _carouselView.Item)
+ throw new Exception("CarouselView.Item != ItemSelected");
_selectedItem.Text = $"{selectedItemId}";
OnEvent("i");
};
- _carouselView.PositionSelected += (s, o) => {
+ _carouselView.PositionSelected += (s, o) =>
+ {
var selectedPosition = (int)o.SelectedPosition;
- if (_items[selectedPosition] != _carouselView.Item)
- throw new Exception("CarouselView.Item != Items[selectedPosition]");
- _selectedPosition.Text = $"{selectedPosition}";
+ if (_items[selectedPosition] != _carouselView.Item)
+ throw new Exception("CarouselView.Item != Items[selectedPosition]");
+ _selectedPosition.Text = $"{selectedPosition}";
OnEvent("p");
};
BackgroundColor = Color.Blue;
- var moveBar = new StackLayout {
+ var moveBar = new StackLayout
+ {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.FillAndExpand,
Children = {
@@ -284,7 +321,8 @@ namespace Xamarin.Forms.Controls
};
- var statusBar = new StackLayout {
+ var statusBar = new StackLayout
+ {
Orientation = StackOrientation.Horizontal,
Children = {
CreateCopy("Pos:"), _position,
@@ -293,12 +331,14 @@ namespace Xamarin.Forms.Controls
}
};
- var logBar = new StackLayout {
+ var logBar = new StackLayout
+ {
Orientation = StackOrientation.Horizontal,
Children = { _eventLog }
};
- Content = new StackLayout {
+ Content = new StackLayout
+ {
Children = {
_carouselView,
moveBar,
diff --git a/Xamarin.Forms.Core/CarouselView.cs b/Xamarin.Forms.Core/CarouselView.cs
index 68c387b6..c74463d3 100644
--- a/Xamarin.Forms.Core/CarouselView.cs
+++ b/Xamarin.Forms.Core/CarouselView.cs
@@ -6,21 +6,21 @@ namespace Xamarin.Forms
[RenderWith(typeof(_CarouselViewRenderer))]
public class CarouselView : ItemsView, ICarouselViewController
{
- public static readonly BindableProperty PositionProperty =
+ public static readonly BindableProperty PositionProperty =
BindableProperty.Create(
- propertyName: nameof(Position),
- returnType: typeof(int),
- declaringType: typeof(CarouselView),
- defaultValue: 0,
+ propertyName: nameof(Position),
+ returnType: typeof(int),
+ declaringType: typeof(CarouselView),
+ defaultValue: 0,
defaultBindingMode: BindingMode.TwoWay
);
- public static readonly BindableProperty ItemProperty =
+ public static readonly BindableProperty ItemProperty =
BindableProperty.Create(
- propertyName: nameof(Item),
- returnType: typeof(object),
- declaringType: typeof(CarouselView),
- defaultValue: null,
+ propertyName: nameof(Item),
+ returnType: typeof(object),
+ declaringType: typeof(CarouselView),
+ defaultValue: null,
defaultBindingMode: BindingMode.TwoWay
);
@@ -48,13 +48,25 @@ namespace Xamarin.Forms
public int Position
{
- get { return (int)GetValue(PositionProperty); }
- set { SetValue(PositionProperty, value); }
+ get
+ {
+ return (int)GetValue(PositionProperty);
+ }
+ set
+ {
+ SetValue(PositionProperty, value);
+ }
}
public object Item
{
- get { return GetValue(ItemProperty); }
- internal set { SetValue(ItemProperty, value); }
+ get
+ {
+ return GetValue(ItemProperty);
+ }
+ internal set
+ {
+ SetValue(ItemProperty, value);
+ }
}
public event EventHandler<SelectedItemChangedEventArgs> ItemSelected;
@@ -80,8 +92,8 @@ namespace Xamarin.Forms
return;
_lastItem = item;
- Item = item;
- ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs(item));
+ Item = item;
+ ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs(item));
}
void ICarouselViewController.SendSelectedPositionChanged(int position)
{
@@ -89,7 +101,7 @@ namespace Xamarin.Forms
return;
_lastPosition = position;
- Item = ((IItemViewController)this).GetItem(position);
+ Item = ((IItemViewController)this).GetItem(position);
PositionSelected?.Invoke(this, new SelectedPositionChangedEventArgs(position));
}
}
diff --git a/Xamarin.Forms.Core/IItemViewController.cs b/Xamarin.Forms.Core/IItemViewController.cs
index 0876f602..ca4c51ee 100644
--- a/Xamarin.Forms.Core/IItemViewController.cs
+++ b/Xamarin.Forms.Core/IItemViewController.cs
@@ -6,6 +6,9 @@
View CreateView(object itemType);
object GetItem(int index);
object GetItemType(object item);
- int Count { get; }
+ int Count
+ {
+ get;
+ }
}
} \ No newline at end of file
diff --git a/Xamarin.Forms.Core/ItemsViewSimple.cs b/Xamarin.Forms.Core/ItemsViewSimple.cs
index 59858d22..8ad82b7f 100644
--- a/Xamarin.Forms.Core/ItemsViewSimple.cs
+++ b/Xamarin.Forms.Core/ItemsViewSimple.cs
@@ -9,18 +9,18 @@ namespace Xamarin.Forms
{
public abstract class ItemsView : View, IItemViewController
{
- public static readonly BindableProperty ItemsSourceProperty =
+ public static readonly BindableProperty ItemsSourceProperty =
BindableProperty.Create(
propertyName: "ItemsSource",
- returnType: typeof(IEnumerable),
- declaringType: typeof(ItemsView),
+ returnType: typeof(IEnumerable),
+ declaringType: typeof(ItemsView),
defaultValue: Enumerable.Empty<object>()
);
- public static readonly BindableProperty ItemTemplateProperty =
+ public static readonly BindableProperty ItemTemplateProperty =
BindableProperty.Create(
- propertyName: "ItemTemplate",
- returnType: typeof(DataTemplate),
+ propertyName: "ItemTemplate",
+ returnType: typeof(DataTemplate),
declaringType: typeof(ItemsView)
);
@@ -32,14 +32,26 @@ namespace Xamarin.Forms
public IEnumerable ItemsSource
{
- get { return (IEnumerable)GetValue(ItemsSourceProperty); }
- set { SetValue(ItemsSourceProperty, value); }
+ get
+ {
+ return (IEnumerable)GetValue(ItemsSourceProperty);
+ }
+ set
+ {
+ SetValue(ItemsSourceProperty, value);
+ }
}
public DataTemplate ItemTemplate
{
- get { return (DataTemplate)GetValue(ItemTemplateProperty); }
- set { SetValue(ItemTemplateProperty, value); }
+ get
+ {
+ return (DataTemplate)GetValue(ItemTemplateProperty);
+ }
+ set
+ {
+ SetValue(ItemTemplateProperty, value);
+ }
}
int IItemViewController.Count => _itemSource.Count;
@@ -80,7 +92,7 @@ namespace Xamarin.Forms
var itemsSource = ItemsSource;
if (itemsSource == null)
itemsSource = Enumerable.Empty<object>();
-
+
// abstract enumerable, IList, IList<T>, and IReadOnlyList<T>
_itemSource = new ItemSource(itemsSource);
@@ -233,7 +245,10 @@ namespace Xamarin.Forms
return true;
}
- public object Current { get; private set; }
+ public object Current
+ {
+ get; private set;
+ }
public void Reset()
{
@@ -264,7 +279,10 @@ namespace Xamarin.Forms
Enumerable = list.Cast<object>().ToArray();
}
- internal IEnumerable Enumerable { get; }
+ internal IEnumerable Enumerable
+ {
+ get;
+ }
internal int Count
{
diff --git a/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs
index 55d9b0df..7b0da7aa 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/CarouselViewRenderer.cs
@@ -38,14 +38,14 @@ namespace Xamarin.Forms.Platform.Android
internal static IntVector Clamp(this IntVector position, IntRectangle bound)
{
return new IntVector(
- x: position.X.Clamp(bound.Left, bound.Right),
+ x: position.X.Clamp(bound.Left, bound.Right),
y: position.Y.Clamp(bound.Top, bound.Bottom)
);
}
internal static IntVector LeadingCorner(this IntRectangle rectangle, IntVector delta)
{
return new IntVector(
- x: delta.X < 0 ? rectangle.Left : rectangle.Right,
+ x: delta.X < 0 ? rectangle.Left : rectangle.Right,
y: delta.Y < 0 ? rectangle.Top : rectangle.Bottom
);
}
@@ -63,16 +63,16 @@ namespace Xamarin.Forms.Platform.Android
return new Rectangle(
x: context.FromPixels(rectangle.Left),
y: context.FromPixels(rectangle.Top),
- width: context.FromPixels(rectangle.Width),
+ width: context.FromPixels(rectangle.Width),
height: context.FromPixels(rectangle.Height)
);
}
internal static Rect ToAndroidRectangle(this IntRectangle rectangle)
{
return new Rect(
- left: rectangle.Left,
- right: rectangle.Right,
- top: rectangle.Top,
+ left: rectangle.Left,
+ right: rectangle.Right,
+ top: rectangle.Top,
bottom: rectangle.Bottom
);
}
@@ -121,39 +121,39 @@ namespace Xamarin.Forms.Platform.Android
return !(lhs == rhs);
}
public static IntRectangle operator -(IntRectangle source, IntVector vector) => source + -vector;
- public static IntRectangle operator +(IntRectangle source, IntVector vector) =>
+ public static IntRectangle operator +(IntRectangle source, IntVector vector) =>
new IntRectangle(source.Location + vector, source.Size);
public static IntVector operator -(IntVector vector, IntVector other) => vector + -other;
- public static IntVector operator +(IntVector vector, IntVector other) =>
+ public static IntVector operator +(IntVector vector, IntVector other) =>
new IntVector(
- x: vector.X + other.X,
+ x: vector.X + other.X,
y: vector.Y + other.Y
);
public static IntPoint operator -(IntPoint point, IntVector delta) => point + -delta;
- public static IntPoint operator +(IntPoint point, IntVector delta) =>
+ public static IntPoint operator +(IntPoint point, IntVector delta) =>
new IntPoint(
- x: point.X + delta.X,
+ x: point.X + delta.X,
y: point.Y + delta.Y
);
public static IntVector operator -(IntVector vector) => vector * -1;
- public static IntVector operator *(IntVector vector, int scaler) =>
+ public static IntVector operator *(IntVector vector, int scaler) =>
new IntVector(
- x: vector.X * scaler,
+ x: vector.X * scaler,
y: vector.Y * scaler
);
- public static IntVector operator /(IntVector vector, int scaler) =>
+ public static IntVector operator /(IntVector vector, int scaler) =>
new IntVector(
- x: vector.X / scaler,
+ x: vector.X / scaler,
y: vector.Y / scaler
);
- public static IntVector operator *(IntVector vector, double scaler) =>
+ public static IntVector operator *(IntVector vector, double scaler) =>
new IntVector(
x: (int)(vector.X * scaler),
- y: (int)(vector.Y * scaler)
+ y: (int)(vector.Y * scaler)
);
public static IntVector operator /(IntVector vector, double scaler) => vector * (1 / scaler);
@@ -267,16 +267,16 @@ namespace Xamarin.Forms.Platform.Android
internal override bool CanScrollHorizontally => true;
internal override bool CanScrollVertically => false;
- internal override IntRectangle GetBounds(int originPosition, State state) =>
+ internal override IntRectangle GetBounds(int originPosition, State state) =>
new IntRectangle(
- LayoutItem(originPosition, 0).Location,
+ LayoutItem(originPosition, 0).Location,
new IntSize(_itemSize.Width * state.ItemCount, _itemSize.Height)
);
internal override Tuple<int, int> GetPositions(
- int positionOrigin,
- int itemCount,
- IntRectangle viewport,
+ int positionOrigin,
+ int itemCount,
+ IntRectangle viewport,
bool includeBuffer)
{
// returns one item off-screen in either direction.
@@ -442,8 +442,8 @@ namespace Xamarin.Forms.Platform.Android
// layoutManager
recyclerView.SetLayoutManager(
layout: _physicalLayout = new PhysicalLayoutManager(
- context: Context,
- virtualLayout: new VirtualLayoutManager(),
+ context: Context,
+ virtualLayout: new VirtualLayoutManager(),
positionOrigin: Element.Position
)
);
@@ -452,14 +452,14 @@ namespace Xamarin.Forms.Platform.Android
var dragging = false;
recyclerView.AddOnScrollListener(
new OnScrollListener(
- onDragStart: () => dragging = true,
- onDragEnd: () =>
+ onDragStart: () => dragging = true,
+ onDragEnd: () =>
{
dragging = false;
var velocity = _physicalLayout.Velocity;
- var target = velocity.X > 0 ?
- _physicalLayout.VisiblePositions().Max() :
+ var target = velocity.X > 0 ?
+ _physicalLayout.VisiblePositions().Max() :
_physicalLayout.VisiblePositions().Min();
_physicalLayout.ScrollToPosition(target);
}
@@ -472,7 +472,7 @@ namespace Xamarin.Forms.Platform.Android
_physicalLayout.OnEndScroll += position => scrolling = false;
// appearing
- _physicalLayout.OnAppearing += appearingPosition =>
+ _physicalLayout.OnAppearing += appearingPosition =>
{
Controller.SendPositionAppearing(appearingPosition);
};
@@ -507,7 +507,7 @@ namespace Xamarin.Forms.Platform.Android
{
case NotifyCollectionChangedAction.Add:
Adapter.NotifyItemRangeInserted(
- positionStart: e.NewStartingIndex,
+ positionStart: e.NewStartingIndex,
itemCount: e.NewItems.Count
);
break;
@@ -515,7 +515,7 @@ namespace Xamarin.Forms.Platform.Android
case NotifyCollectionChangedAction.Move:
for (var i = 0; i < e.NewItems.Count; i++)
Adapter.NotifyItemMoved(
- fromPosition: e.OldStartingIndex + i,
+ fromPosition: e.OldStartingIndex + i,
toPosition: e.NewStartingIndex + i
);
break;
@@ -525,14 +525,14 @@ namespace Xamarin.Forms.Platform.Android
throw new InvalidOperationException("CarouselView must retain a least one item.");
Adapter.NotifyItemRangeRemoved(
- positionStart: e.OldStartingIndex,
+ positionStart: e.OldStartingIndex,
itemCount: e.OldItems.Count
);
break;
case NotifyCollectionChangedAction.Replace:
Adapter.NotifyItemRangeChanged(
- positionStart: e.OldStartingIndex,
+ positionStart: e.OldStartingIndex,
itemCount: e.OldItems.Count
);
break;
@@ -633,7 +633,7 @@ namespace Xamarin.Forms.Platform.Android
#endregion
internal DecoratedView(
- PhysicalLayoutManager layout,
+ PhysicalLayoutManager layout,
AndroidView view)
{
_layout = layout;
@@ -663,10 +663,10 @@ namespace Xamarin.Forms.Platform.Android
// causes the private LAYOUT_REQUIRED flag to be set so we can be sure the Layout call will properly chain through to all children
Measure(position.Width, position.Height);
- _layout.LayoutDecorated(_view,
- left: position.Left,
- top: position.Top,
- right: position.Right,
+ _layout.LayoutDecorated(_view,
+ left: position.Left,
+ top: position.Top,
+ right: position.Right,
bottom: position.Bottom
);
}
@@ -682,15 +682,21 @@ namespace Xamarin.Forms.Platform.Android
internal abstract class VirtualLayoutManager
{
internal abstract Tuple<int, int> GetPositions(
- int positionOrigin,
- int itemCount,
- IntRectangle viewport,
+ int positionOrigin,
+ int itemCount,
+ IntRectangle viewport,
bool isPreLayout
);
internal abstract IntRectangle LayoutItem(int positionOrigin, int position);
- internal abstract bool CanScrollHorizontally { get; }
- internal abstract bool CanScrollVertically { get; }
+ internal abstract bool CanScrollHorizontally
+ {
+ get;
+ }
+ internal abstract bool CanScrollVertically
+ {
+ get;
+ }
internal abstract void Layout(int positionOrigin, IntSize viewportSize, ref IntVector offset);
internal abstract IntRectangle GetBounds(int positionOrigin, State state);
@@ -719,9 +725,9 @@ namespace Xamarin.Forms.Platform.Android
#endregion
internal SeekAndSnapScroller(
- Context context,
- Func<int, IntVector> vectorToPosition,
- SnapPreference snapPreference = SnapPreference.None)
+ Context context,
+ Func<int, IntVector> vectorToPosition,
+ SnapPreference snapPreference = SnapPreference.None)
: base(context)
{
_vectorToPosition = vectorToPosition;
@@ -782,8 +788,9 @@ namespace Xamarin.Forms.Platform.Android
_samples = Enumerable.Repeat(IntVector.Origin, s_samplesCount).ToList();
_deferredLayout = new Queue<Action<Recycler, State>>();
_scroller = new SeekAndSnapScroller(
- context: context,
- vectorToPosition: adapterPosition => {
+ context: context,
+ vectorToPosition: adapterPosition =>
+ {
var end = virtualLayout.LayoutItem(_positionOrigin, adapterPosition).Center();
var begin = Viewport.Center();
return end - begin;
@@ -807,7 +814,7 @@ namespace Xamarin.Forms.Platform.Android
_adapterChangeType = default(AdapterChangeType);
delta = Viewport.BoundTranslation(
- delta: delta,
+ delta: delta,
bound: _virtualLayout.GetBounds(_positionOrigin, state)
);
@@ -882,7 +889,8 @@ namespace Xamarin.Forms.Platform.Android
{
_adapterChangeType = AdapterChangeType.Added;
- _deferredLayout.Enqueue((recycler, state) => {
+ _deferredLayout.Enqueue((recycler, state) =>
+ {
var viewByAdaptorPositionCopy = _viewByAdaptorPosition.ToArray();
_viewByAdaptorPosition.Clear();
@@ -912,7 +920,8 @@ namespace Xamarin.Forms.Platform.Android
var positionEnd = positionStart + itemCount;
- _deferredLayout.Enqueue((recycler, state) => {
+ _deferredLayout.Enqueue((recycler, state) =>
+ {
if (state.ItemCount == 0)
throw new InvalidOperationException("Cannot delete all items.");
@@ -975,7 +984,8 @@ namespace Xamarin.Forms.Platform.Android
_adapterChangeType = AdapterChangeType.Updated;
// rebind rendered updated elements
- _deferredLayout.Enqueue((recycler, state) => {
+ _deferredLayout.Enqueue((recycler, state) =>
+ {
for (var i = 0; i < itemCount; i++)
{
var position = positionStart + i;
@@ -1145,7 +1155,7 @@ namespace Xamarin.Forms.Platform.Android
readonly IVisualElementRenderer _visualElementRenderer;
#endregion
- public CarouselViewHolder(View view, IVisualElementRenderer renderer)
+ public CarouselViewHolder(View view, IVisualElementRenderer renderer)
: base(renderer.ViewGroup)
{
_visualElementRenderer = renderer;
@@ -1175,13 +1185,15 @@ namespace Xamarin.Forms.Platform.Android
#region Private Members
ItemsView Element
{
- get {
+ get
+ {
return (ItemsView)_renderer.Element;
}
}
IItemViewController Controller
{
- get {
+ get
+ {
return Element;
}
}
@@ -1190,7 +1202,7 @@ namespace Xamarin.Forms.Platform.Android
public override int ItemCount
{
get
- {
+ {
return Controller.Count;
}
}
diff --git a/Xamarin.Forms.Platform.WinRT/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/CarouselViewRenderer.cs
index e4ff754c..f29909df 100644
--- a/Xamarin.Forms.Platform.WinRT/CarouselViewRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/CarouselViewRenderer.cs
@@ -27,7 +27,10 @@ namespace Xamarin.Forms.Platform.WinRT
ICarouselViewController Controller
{
- get { return Element; }
+ get
+ {
+ return Element;
+ }
}
protected override void OnElementChanged(ElementChangedEventArgs<CarouselView> e)
@@ -45,7 +48,7 @@ namespace Xamarin.Forms.Platform.WinRT
{
if (_flipView == null)
{
- _flipView = new FlipView
+ _flipView = new FlipView
{
IsSynchronizedWithCurrentItem = false,
ItemTemplate = (WDataTemplate)WApp.Current.Resources["ItemTemplate"]
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs
index 5bc2b8de..39cda393 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs
@@ -60,7 +60,10 @@ namespace Xamarin.Forms.Platform.iOS
ICarouselViewController Controller
{
- get { return Element; }
+ get
+ {
+ return Element;
+ }
}
void Initialize()
{
@@ -233,11 +236,13 @@ namespace Xamarin.Forms.Platform.iOS
internal sealed class CarouselViewController : UICollectionViewController
{
- new sealed class Layout : UICollectionViewFlowLayout {
+ new sealed class Layout : UICollectionViewFlowLayout
+ {
static readonly nfloat ZeroMinimumInteritemSpacing = 0;
static readonly nfloat ZeroMinimumLineSpacing = 0;
- public Layout(UICollectionViewScrollDirection scrollDirection) {
+ public Layout(UICollectionViewScrollDirection scrollDirection)
+ {
ScrollDirection = scrollDirection;
MinimumInteritemSpacing = ZeroMinimumInteritemSpacing;
MinimumLineSpacing = ZeroMinimumLineSpacing;
@@ -307,7 +312,7 @@ namespace Xamarin.Forms.Platform.iOS
int _initialPosition;
internal CarouselViewController(
- CarouselViewRenderer renderer,
+ CarouselViewRenderer renderer,
int initialPosition)
: base(new Layout(UICollectionViewScrollDirection.Horizontal))
{
@@ -324,7 +329,7 @@ namespace Xamarin.Forms.Platform.iOS
[Export("collectionView:layout:sizeForItemAtIndexPath:")]
SizeF GetSizeForItem(
UICollectionView collectionView,
- UICollectionViewLayout layout,
+ UICollectionViewLayout layout,
NSIndexPath indexPath)
{
return collectionView.Frame.Size;
@@ -335,7 +340,8 @@ namespace Xamarin.Forms.Platform.iOS
public override void WillDisplayCell(UICollectionView collectionView, UICollectionViewCell cell, NSIndexPath indexPath)
{
- if (_initialPosition != 0) {
+ if (_initialPosition != 0)
+ {
ScrollToPosition(_initialPosition, false);
_initialPosition = 0;
return;
@@ -401,16 +407,16 @@ namespace Xamarin.Forms.Platform.iOS
internal void MoveItem(int oldPosition, int newPosition)
{
base.MoveItem(
- CollectionView,
- NSIndexPath.FromRowSection(oldPosition, 0),
+ CollectionView,
+ NSIndexPath.FromRowSection(oldPosition, 0),
NSIndexPath.FromRowSection(newPosition, 0)
);
}
internal void ScrollToPosition(int position, bool animated = true)
{
CollectionView.ScrollToItem(
- indexPath: NSIndexPath.FromRowSection(position, 0),
- scrollPosition: UICollectionViewScrollPosition.CenteredHorizontally,
+ indexPath: NSIndexPath.FromRowSection(position, 0),
+ scrollPosition: UICollectionViewScrollPosition.CenteredHorizontally,
animated: animated
);
}