Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Added IndicatorsView #7465

Merged
merged 54 commits into from
Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b61e0e5
Added IndicatorsView
AndreiMisiukevich Sep 10, 2019
90a6d7a
removed static ctor
AndreiMisiukevich Sep 18, 2019
cf3a293
refused plural in naming
AndreiMisiukevich Sep 18, 2019
6651cc5
opened ItemsSource property
AndreiMisiukevich Sep 18, 2019
ad7d82b
followed code convention
AndreiMisiukevich Sep 18, 2019
43e62b5
renamed IndicatorView (removed plural)
AndreiMisiukevich Sep 18, 2019
5ce8531
made Color.Default as initial value
AndreiMisiukevich Sep 18, 2019
cda5965
updated IndicatorSize initial value
AndreiMisiukevich Sep 18, 2019
54ee807
Added IndicatorViewExtensions
AndreiMisiukevich Sep 18, 2019
c2c1480
naming changes
AndreiMisiukevich Sep 18, 2019
14e9ab4
fix build
AndreiMisiukevich Sep 18, 2019
c1b6aa6
small cleanup
AndreiMisiukevich Sep 19, 2019
d1b2088
refactored control to templatedView
AndreiMisiukevich Sep 19, 2019
dea5243
added UIPageControl renderer for iOS
AndreiMisiukevich Sep 20, 2019
74c026a
moved extensions class to separate file
AndreiMisiukevich Sep 30, 2019
bfb92c7
removed useless private methods
AndreiMisiukevich Sep 30, 2019
0832cd8
local vars name refactoring
AndreiMisiukevich Sep 30, 2019
726713a
tapGesture naming update
AndreiMisiukevich Sep 30, 2019
8607253
avoided linq
AndreiMisiukevich Sep 30, 2019
75dbe1f
code styling
AndreiMisiukevich Sep 30, 2019
a4d2b74
fixed default indicator colors for iOS
AndreiMisiukevich Sep 30, 2019
5b6b991
added experimental flag
AndreiMisiukevich Sep 30, 2019
c7d8617
[Core]Update api naming for IndicatorView
rmarinho Oct 15, 2019
f3bd9b1
Update IndicatorView.cs
rmarinho Oct 16, 2019
a0f9f1a
[Core] Add forms visual
rmarinho Oct 21, 2019
f42dae1
Revert "[Core] Add forms visual"
rmarinho Oct 21, 2019
90c558f
Revert "Revert "[Core] Add forms visual""
rmarinho Oct 21, 2019
224c8c8
[Gallery]Revert changes to gallery
rmarinho Oct 21, 2019
0618228
[Android] Export default renderer for FormsVisual
rmarinho Oct 21, 2019
38baf85
[iOS] Handle FormsVisual for IndicatorView
rmarinho Oct 21, 2019
597af0e
[iOS] Update Position from native renderer
rmarinho Oct 21, 2019
c172e53
[iOS] IndicatorVIewRendederer updates and dispose
rmarinho Oct 21, 2019
dbe7a8f
[Controls] Fix merge
rmarinho Oct 22, 2019
6319696
Added IndicatorView Core Gallery sample
jsuarezruiz Nov 15, 2019
cfd6e7e
Add IndicatorSample
rmarinho Nov 15, 2019
b2accaf
Update Xamarin.Forms.Controls.csproj
rmarinho Nov 18, 2019
c91d064
[Core] Fix FormsVisual check
rmarinho Nov 21, 2019
df37985
[iOS] Fix FormsVisual check
rmarinho Nov 21, 2019
1deecee
[Controls] Fix Indicator Gallery sample
rmarinho Nov 21, 2019
2f84c04
[Core] Cleanup IndicatorView
rmarinho Nov 21, 2019
93eff8a
[Core]Fix toogle between template and shapes on FormsVisual
rmarinho Nov 22, 2019
08f2cc7
[Controls] Fix indicators samples
rmarinho Nov 22, 2019
7858550
[Controls] Fix IndicatorTemplate
rmarinho Nov 22, 2019
318ba53
[Core] Add ItemsSourceBy xaml option
rmarinho Nov 22, 2019
16c0bc3
[iOS,Android,Core] Add IndicatorStacklayout
rmarinho Nov 22, 2019
4cc6728
[Android] Remove extra renderer for FormsVisual
rmarinho Nov 22, 2019
4e8af18
[Controls] Remove Visual from Indicator sample
rmarinho Nov 22, 2019
91cf385
[Core, iOS, Android] Fix bug on IndcatorView
rmarinho Nov 22, 2019
ca4a614
- remove forms visual
PureWeen Nov 22, 2019
15afeb0
- remove extra shared
PureWeen Nov 22, 2019
fa33271
- remove forms visual
PureWeen Nov 22, 2019
b517247
- remove disposable
PureWeen Nov 23, 2019
369aa4a
- remove renderer from tizen
PureWeen Nov 23, 2019
1367226
Merge branch '4.4.0' into indicatorsView
PureWeen Nov 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Stubs/Xamarin.Forms.Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ internal class _FrameRenderer { }
internal class _CheckBoxRenderer { }
#endif

#if !TIZEN4_0
[RenderWith(typeof(IndicatorViewRenderer))]
#endif
internal class _IndicatorViewRenderer { }

#if __IOS__
// current previewer doesn't work with appcompat so this renderer is here for the previewer only
// once previewer switches to appcompat then we can remove this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,4 @@
</CreateItem>
<Copy SourceFiles="@(MapsKey)" DestinationFiles="Properties\MapsKey.cs" Condition="!Exists('Properties\MapsKey.cs')" />
</Target>
</Project>
</Project>
1 change: 1 addition & 0 deletions Xamarin.Forms.Controls/CoreGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ public override string ToString()
new GalleryPageFactory(() => new MemoryLeakGallery(), "Memory Leak"),
new GalleryPageFactory(() => new Issues.A11yTabIndex(), "Accessibility TabIndex"),
new GalleryPageFactory(() => new FontImageSourceGallery(), "Font ImageSource"),
new GalleryPageFactory(() => new IndicatorsSample(), "Indicator Gallery"),
new GalleryPageFactory(() => new CarouselViewGallery(), "CarouselView Gallery"),
new GalleryPageFactory(() => new CarouselViewCoreGalleryPage(), "CarouselView Core Gallery"),
new GalleryPageFactory(() => new CollectionViewGallery(), "CollectionView Gallery"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public CarouselItemsGallery()
{
var viewModel = new CarouselItemsGalleryViewModel();

Title = $"CarouselView (Items)";
Title = $"CarouselView (Indicators)";

var layout = new Grid
var grid = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
Expand Down Expand Up @@ -42,7 +42,22 @@ public CarouselItemsGallery()
EmptyView = "This is the empty view"
};

layout.Children.Add(carouselView, 0, 0);
var absolute = new AbsoluteLayout();
absolute.Children.Add(carouselView, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);

var indicators = new IndicatorView
{
Margin = new Thickness(15, 20),
IndicatorColor = Color.Gray,
SelectedIndicatorColor = Color.Black,
IndicatorsShape = IndicatorShape.Square
};

IndicatorView.SetItemsSourceBy(indicators, carouselView);

absolute.Children.Add(indicators, new Rectangle(.5, 1, -1, -1), AbsoluteLayoutFlags.PositionProportional);

grid.Children.Add(absolute, 0, 0);

var stacklayoutButtons = new StackLayout
{
Expand Down Expand Up @@ -92,9 +107,9 @@ public CarouselItemsGallery()
stacklayoutButtons.Children.Add(removeItemButton);
stacklayoutButtons.Children.Add(clearItemsButton);

layout.Children.Add(stacklayoutButtons, 0, 1);
grid.Children.Add(stacklayoutButtons, 0, 1);

Content = layout;
Content = grid;
BindingContext = viewModel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ public CarouselViewGallery()
new CarouselCodeGallery(ItemsLayoutOrientation.Vertical), Navigation),
GalleryBuilder.NavButton("CarouselView (XAML, Horizontal)", () =>
new CarouselXamlGallery(), Navigation),
GalleryBuilder.NavButton("CarouselView (Items)", () =>
GalleryBuilder.NavButton("CarouselView (Indicators Forms)", () =>
new CarouselItemsGallery(), Navigation),
GalleryBuilder.NavButton("CarouselView (Indicators Default (Native))", () =>
new CarouselItemsGallery(), Navigation),
GalleryBuilder.NavButton("CarouselView Snap", () =>
new CarouselSnapGallery(), Navigation),
GalleryBuilder.NavButton("ObservableCollection and CarouselView", () =>
new CollectionCarouselViewGallery(), Navigation),
GalleryBuilder.NavButton("CarouselView EmptyView", () =>
new EmptyCarouselGallery(), Navigation)
new EmptyCarouselGallery(), Navigation),
GalleryBuilder.NavButton("IndicatorView", () =>
new IndicatorCodeGallery(), Navigation)
}
}
};
Expand All @@ -54,7 +58,7 @@ void ButtonClicked(object sender, System.EventArgs e)
button.TextColor = Color.Black;
button.IsEnabled = false;

Device.SetFlags(new[] { ExperimentalFlags.CarouselViewExperimental });
Device.SetFlags(new[] { ExperimentalFlags.CarouselViewExperimental, ExperimentalFlags.IndicatorViewExperimental });
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
using System.Collections.Generic;
using Xamarin.Forms.Internals;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

namespace Xamarin.Forms.Controls.GalleryPages.CollectionViewGalleries.CarouselViewGalleries
{
[Preserve(AllMembers = true)]
public class IndicatorCodeGallery : ContentPage
{
public IndicatorCodeGallery()
{
Title = "IndicatorView Gallery";

On<iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never);

var nItems = 10;

var layout = new Grid
{
RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Star },
new RowDefinition { Height = GridLength.Auto }
}
};

var itemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
{
SnapPointsType = SnapPointsType.MandatorySingle,
SnapPointsAlignment = SnapPointsAlignment.Center
};

var itemTemplate = ExampleTemplates.CarouselTemplate();

var carouselView = new CarouselView
{
ItemsLayout = itemsLayout,
ItemTemplate = itemTemplate,
BackgroundColor = Color.LightGray,
AutomationId = "TheCarouselView"
};

layout.Children.Add(carouselView);

var generator = new ItemsSourceGenerator(carouselView, nItems, ItemsSourceType.ObservableCollection, false);

layout.Children.Add(generator);

generator.GenerateItems();

var indicatorView = new IndicatorView
{
HorizontalOptions = LayoutOptions.Center,
Margin = new Thickness(12, 6, 12, 24),
IndicatorColor = Color.Gray,
SelectedIndicatorColor = Color.Black,
IndicatorsShape = IndicatorShape.Square,
AutomationId = "TheIndicatorView"
};

IndicatorView.SetItemsSourceBy(indicatorView, carouselView);

layout.Children.Add(indicatorView);

var stckMaxVisible = new StackLayout { Orientation = StackOrientation.Horizontal };
stckMaxVisible.Children.Add(new Label { VerticalOptions = LayoutOptions.Center, Text = "MaximumVisible" });
var maxVisibleSlider = new Slider
{
Maximum = nItems,
Minimum = 0,
Value = nItems,
WidthRequest = 150,
BackgroundColor = Color.Pink
};
stckMaxVisible.Children.Add(maxVisibleSlider);

maxVisibleSlider.ValueChanged += (s, e) =>
{
var maximumVisible = (int)maxVisibleSlider.Value;
indicatorView.MaximumVisible = maximumVisible;
};

layout.Children.Add(stckMaxVisible);

var stckColors = new StackLayout { Orientation = StackOrientation.Horizontal };
stckColors.Children.Add(new Label { VerticalOptions = LayoutOptions.Center, Text = "IndicatorColor" });

var colors = new List<string>
{
"Black",
"Blue",
"Red"
};

var colorsPicker = new Picker
{
ItemsSource = colors,
WidthRequest = 150
};
colorsPicker.SelectedIndex = 0;

colorsPicker.SelectedIndexChanged += (s, e) =>
{
var selectedIndex = colorsPicker.SelectedIndex;

switch (selectedIndex)
{
case 0:
indicatorView.IndicatorColor = Color.Black;
break;
case 1:
indicatorView.IndicatorColor = Color.Blue;
break;
case 2:
indicatorView.IndicatorColor = Color.Red;
break;
}
};

stckColors.Children.Add(colorsPicker);

layout.Children.Add(stckColors);

var stckTemplate = new StackLayout { Orientation = StackOrientation.Horizontal };
stckTemplate.Children.Add(new Label { VerticalOptions = LayoutOptions.Center, Text = "IndicatorTemplate" });

var templates = new List<string>
{
"Circle",
"Square",
"Template"
};

var templatePicker = new Picker
{
ItemsSource = templates,
WidthRequest = 150,
TextColor = Color.Black
};

templatePicker.SelectedIndexChanged += (s, e) =>
{
var selectedIndex = templatePicker.SelectedIndex;

switch (selectedIndex)
{
case 0:
indicatorView.IndicatorTemplate = null;
indicatorView.IndicatorsShape = IndicatorShape.Circle;
break;
case 1:
indicatorView.IndicatorTemplate = null;
indicatorView.IndicatorsShape = IndicatorShape.Square;
break;
case 2:
indicatorView.IndicatorTemplate = ExampleTemplates.IndicatorTemplate();
break;
}
};

templatePicker.SelectedIndex = 0;

stckTemplate.Children.Add(templatePicker);

layout.Children.Add(stckTemplate);

Grid.SetRow(generator, 0);
Grid.SetRow(stckMaxVisible, 1);
Grid.SetRow(stckColors, 2);
Grid.SetRow(stckTemplate, 3);
Grid.SetRow(carouselView, 4);
Grid.SetRow(indicatorView, 5);

Content = layout;

generator.CollectionChanged += (sender, e) =>
{
maxVisibleSlider.Maximum = generator.Count;
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ public static DataTemplate CarouselTemplate()
});
}

public static DataTemplate IndicatorTemplate()
{
return new DataTemplate(() =>
{
var image = new Image
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Aspect = Aspect.AspectFill,
Source = new FontImageSource
{
FontFamily = DefaultFontFamily(),
Glyph = "\uf30c",
},
HeightRequest = 10,
WidthRequest = 10
};

return image;
});
}

public static DataTemplate ScrollToIndexTemplate()
{
return new DataTemplate(() =>
Expand Down Expand Up @@ -469,6 +491,26 @@ static void More_Clicked(object sender, EventArgs e)
throw new NotImplementedException();
}

static string DefaultFontFamily()
{
var fontFamily = "";
switch (Device.RuntimePlatform)
{
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
default:
fontFamily = "fonts/ionicons.ttf#";
break;
}

return fontFamily;
}

class IndexRequestConverter : IValueConverter
{
readonly int _cutoff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class ItemsSourceGenerator : ContentView

public int Count => _count;
public ItemsSourceGenerator(ItemsView cv, int initialItems = 1000,
ItemsSourceType itemsSourceType = ItemsSourceType.List)
ItemsSourceType itemsSourceType = ItemsSourceType.List, bool sideItems = true)
{
_count = initialItems;
_cv = cv;
Expand All @@ -40,14 +40,20 @@ public ItemsSourceGenerator(ItemsView cv, int initialItems = 1000,

var button = new Button { Text = "Update", AutomationId = "btnUpdate" };
var label = new Label { Text = "Items:", VerticalTextAlignment = TextAlignment.Center };
var labelSideItems = new Label { Text = "Side items:", VerticalTextAlignment = TextAlignment.Center };
_entry = new Entry { Keyboard = Keyboard.Numeric, Text = initialItems.ToString(), WidthRequest = 100, AutomationId = "entryUpdate" };
_entrySideItems = new Entry { Keyboard = Keyboard.Numeric, Text = carousel?.NumberOfSideItems.ToString(), WidthRequest = 100, AutomationId = "entrySideItemsUpdate" };

layout.Children.Add(label);
layout.Children.Add(_entry);
layout.Children.Add(labelSideItems);
layout.Children.Add(_entrySideItems);

if (sideItems)
{
var labelSideItems = new Label { Text = "Side items:", VerticalTextAlignment = TextAlignment.Center };
_entrySideItems = new Entry { Keyboard = Keyboard.Numeric, Text = carousel?.NumberOfSideItems.ToString(), WidthRequest = 100, AutomationId = "entrySideItemsUpdate" };

layout.Children.Add(labelSideItems);
layout.Children.Add(_entrySideItems);
}

layout.Children.Add(button);

button.Clicked += GenerateItems;
Expand Down Expand Up @@ -169,7 +175,7 @@ void GenerateItems(object sender, EventArgs e)
if (carousel == null)
return;

if (int.TryParse(_entrySideItems.Text, out int count))
if (int.TryParse(_entrySideItems?.Text, out int count))
carousel.NumberOfSideItems = count;
}
}
Expand Down
Loading