<?xml version="1.0" encoding="utf-8" ?>
<local:ChatServicePageControlBase
    x:Class="RodelAgent.UI.Controls.Chat.GroupsSection"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ext="using:RodelAgent.UI.Extensions"
    xmlns:ic="using:FluentIcons.WinUI"
    xmlns:items="using:RodelAgent.UI.ViewModels.Items"
    xmlns:itemscontrol="using:RodelAgent.UI.Controls.Items"
    xmlns:local="using:RodelAgent.UI.Controls.Chat"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Spacing="8">
        <Grid Margin="12,0" Padding="0,4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock
                VerticalAlignment="Center"
                Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                Style="{StaticResource CaptionTextBlockStyle}"
                Text="{ext:Locale Name=Groups}" />
        </Grid>
        <Grid>
            <ItemsRepeater ItemsSource="{x:Bind ViewModel.GroupPresets}">
                <ItemsRepeater.ItemTemplate>
                    <DataTemplate x:DataType="items:GroupPresetItemViewModel">
                        <itemscontrol:ChatGroupPresetItemControl
                            Click="OnPresetItemClick"
                            DataContext="{x:Bind}"
                            ViewModel="{x:Bind}">
                            <itemscontrol:ChatGroupPresetItemControl.ContextFlyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem Click="OnEditItemClick" Text="{ext:Locale Name=ModifyGroup}">
                                        <MenuFlyoutItem.Icon>
                                            <ic:SymbolIcon Symbol="Edit" />
                                        </MenuFlyoutItem.Icon>
                                    </MenuFlyoutItem>
                                    <MenuFlyoutItem Click="OnPresetItemDeleteClick" Text="{ext:Locale Name=Delete}">
                                        <MenuFlyoutItem.Icon>
                                            <ic:SymbolIcon Foreground="{ThemeResource SystemFillColorCriticalBrush}" Symbol="Delete" />
                                        </MenuFlyoutItem.Icon>
                                    </MenuFlyoutItem>
                                </MenuFlyout>
                            </itemscontrol:ChatGroupPresetItemControl.ContextFlyout>
                        </itemscontrol:ChatGroupPresetItemControl>
                    </DataTemplate>
                </ItemsRepeater.ItemTemplate>
                <ItemsRepeater.Layout>
                    <StackLayout Spacing="4" />
                </ItemsRepeater.Layout>
            </ItemsRepeater>
        </Grid>
    </StackPanel>
</local:ChatServicePageControlBase>
