Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public override string ToString()
new GalleryPageFactory(() => new ScrollViewControlPage(), "ScrollView Feature Matrix"),
new GalleryPageFactory(() => new GraphicsViewControlPage(), "GraphicsView Feature Matrix"),
new GalleryPageFactory(() => new EditorControlPage(), "Editor Feature Matrix"),
new GalleryPageFactory(() => new IndicatorViewControlPage(), "IndicatorView Feature Matrix"),
};

public CorePageView(Page rootPage)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.IndicatorViewControlMainPage"
xmlns:local="clr-namespace:Maui.Controls.Sample"
x:DataType="local:IndicatorViewViewModel"
Title="IndicatorView Control">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Options"
Clicked="NavigateToOptionsPage_Clicked"
AutomationId="Options"/>
</ContentPage.ToolbarItems>

<Grid Padding="10"
RowDefinitions="*, Auto, Auto, Auto"
ColumnDefinitions="*, *"
RowSpacing="5"
ColumnSpacing="10">

<!-- CarouselView -->
<local:CarouselView2 Grid.Row="0"
Grid.ColumnSpan="2"
ItemsSource="{Binding CarouselItems}"
Position="{Binding Position, Mode=TwoWay}"
Loop="False"
HorizontalScrollBarVisibility="Never"
IndicatorView="{x:Reference customIndicator}">
<local:CarouselView2.ItemTemplate>
<DataTemplate x:DataType="local:IndicatorViewCarouselItem">
<Border BackgroundColor="{Binding Color}"
HeightRequest="250"
WidthRequest="250"
Stroke="DarkGray"
StrokeThickness="2"
HorizontalOptions="Center"
VerticalOptions="Center">
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0"
Text="{Binding Title}"
FontSize="Large"
TextColor="Black"
HorizontalTextAlignment="Center"
VerticalOptions="Center"/>
<Label Grid.Row="1"
Text="{Binding Description}"
FontSize="Small"
TextColor="DarkGray"
HorizontalTextAlignment="Center"
VerticalOptions="Center"/>
</Grid>
</Border>
</DataTemplate>
</local:CarouselView2.ItemTemplate>
</local:CarouselView2>

<!-- IndicatorView -->
<IndicatorView Grid.Row="1"
Grid.ColumnSpan="2"
x:Name="customIndicator"
Margin="0,0,0,20"
HorizontalOptions="Center"
ItemsSource="{Binding CarouselItems}"
Count="{Binding Count}"
Position="{Binding Position, Mode=TwoWay}"
HideSingle="{Binding HideSingle}"
IndicatorColor="{Binding IndicatorColor}"
SelectedIndicatorColor="{Binding SelectedIndicatorColor}"
IndicatorSize="{Binding IndicatorSize}"
IndicatorsShape="{Binding IndicatorsShape}"
MaximumVisible="{Binding MaximumVisible}"
IndicatorTemplate="{Binding IndicatorTemplate}"
FlowDirection="{Binding FlowDirection}"
IsEnabled="{Binding IsEnabled}"
IsVisible="{Binding IsVisible}"
Shadow="{Binding Shadow}"
AutomationId="IndicatorViewControl"/>

<Label Grid.Row="2"
Grid.Column="0"
Text="{Binding Position, StringFormat='Position: {0}'}"
FontSize="14"
HorizontalOptions="Center"
AutomationId="PositionLabel"/>
<Label Grid.Row="2"
Grid.Column="1"
Text="{Binding Count, StringFormat='Count: {0}'}"
FontSize="14"
HorizontalOptions="Center"
AutomationId="CountLabel"/>

<Button Grid.Row="3"
Grid.Column="0"
Text="Add Item"
Clicked="OnAddItemClicked"
AutomationId="AddItemButton"/>
<Button Grid.Row="3"
Grid.Column="1"
Text="Remove Item"
Clicked="OnRemoveItemClicked"
AutomationId="RemoveItemButton"/>

</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample;

public class IndicatorViewControlPage : NavigationPage
{
private IndicatorViewViewModel _viewModel;
public IndicatorViewControlPage()
{
_viewModel = new IndicatorViewViewModel();
PushAsync(new IndicatorViewControlMainPage(_viewModel));
}
}

public partial class IndicatorViewControlMainPage : ContentPage
{
private IndicatorViewViewModel _viewModel;
private readonly Color[] _fixedColors = new Color[]
{
Colors.Red,
Colors.Green,
Colors.Blue,
Colors.Orange,
Colors.Purple,
Colors.Teal,
Colors.Brown
};

public IndicatorViewControlMainPage(IndicatorViewViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;
}

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
_viewModel = new IndicatorViewViewModel();
BindingContext = _viewModel;
_viewModel.Position = 0;
_viewModel.CurrentItem = _viewModel.CarouselItems.FirstOrDefault();
await Navigation.PushAsync(new IndicatorViewOptionsPage(_viewModel));
}

private void OnAddItemClicked(object sender, EventArgs e)
{
var index = _viewModel.CarouselItems.Count;
var color = _fixedColors[index % _fixedColors.Length];

_viewModel.CarouselItems.Add(new IndicatorViewCarouselItem
{
Title = $"Item {index + 1}",
Description = $"Description for item {index + 1}",
Color = color
});

_viewModel.Count = _viewModel.CarouselItems.Count;
}

private void OnRemoveItemClicked(object sender, EventArgs e)
{
if (_viewModel.CarouselItems.Count > 0)
{
_viewModel.CarouselItems.RemoveAt(_viewModel.CarouselItems.Count - 1);
_viewModel.Count = _viewModel.CarouselItems.Count;

if (_viewModel.Position >= _viewModel.CarouselItems.Count)
_viewModel.Position = Math.Max(0, _viewModel.CarouselItems.Count - 1);
}
}
}
Loading