Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/chips group #35

Merged
merged 14 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,30 @@
<material:MaterialLabel
Text="You can modify the chip as you require, this is useful when you need to add it to specific spaces or follow the required layout throughout your app." />

<material:MaterialLabel Style="{StaticResource SectionTitle}" Text="Chips Group (single-selection)" />
<Frame Style="{StaticResource SurfaceContainer}" Padding="16,32">
<material:MaterialChipsGroup
LabelText="Chips"
SupportingText="You must select one"
IsMultipleSelection="False"
HorizontalSpacing="4"
SelectedItem="{Binding SelectedChip}"
ItemsSource="{Binding Chips}"/>
</Frame>
<material:MaterialLabel Text="You can easily group chips together to give the user a list of single-select options, even offering a way to display animated validation text." />

<material:MaterialLabel Style="{StaticResource SectionTitle}" Text="Chips Group (multi-selection)" />
<Frame Style="{StaticResource SurfaceContainer}" Padding="16,32">
<material:MaterialChipsGroup
LabelText="Chips"
IsMultipleSelection="True"
ChipsFlexLayoutPercentageBasis="0.5"
Align="Center"
SelectedItems="{Binding SelectedChips}"
ItemsSource="{Binding Chips}"/>
</Frame>
<material:MaterialLabel Text="You can also provide a group to select multiple options. The chips group allows for chips alignment, spacing, percentage size, and more." />

</VerticalStackLayout>
</ScrollView>
</local:BaseContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@
</ScrollView>
</Grid>


</local:BaseContentPage>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.ObjectModel;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;

Expand All @@ -12,23 +13,33 @@ public partial class ChipsViewModel : BaseViewModel

[ObservableProperty]
private bool _isEnabledState;

[ObservableProperty]
private bool _chipsFilterA;

[ObservableProperty]
private bool _chipsFilterB;

[ObservableProperty]
private bool _chipsFilterC;

[ObservableProperty]
private bool _chipsFilterD;

[ObservableProperty]
private ObservableCollection<string> _chips;

[ObservableProperty]
private List<string> _selectedChips = new();

[ObservableProperty]
private string _selectedChip;

#endregion

public ChipsViewModel()
{
Chips = new ObservableCollection<string> { "Chip A", "Chip B", "Chip C", "Chip D", "Chip E" };
Subtitle = "Chips help people enter information, make selections, filter content, or trigger actions";
}

Expand All @@ -37,7 +48,7 @@ private async void TappedChips()
{
await DisplayAlert(Title, "Chips tapped!", "OK");
}

[ICommand]
private async void TappedChipsFilter(string chip)
{
Expand All @@ -60,7 +71,7 @@ private async void TappedChipsFilter(string chip)
await DisplayAlert(Title, $"Chips D {((ChipsFilterD) ? "selected" : "not selected")}", "OK");
break;
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace HorusStudio.Maui.MaterialDesignControls.Sample.ViewModels
{
public partial class MainViewModel : BaseViewModel
public partial class MainViewModel : BaseViewModel
{
#region Attributes & Properties

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using HorusStudio.Maui.MaterialDesignControls.Behaviors;
using HorusStudio.Maui.MaterialDesignControls.Enums;
using System.Windows.Input;


Expand Down
Loading