<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:controls="clr-namespace:GalaxyBudsClient.Interface.Controls"
             xmlns:ext="clr-namespace:GalaxyBudsClient.Interface.MarkupExtensions"
             xmlns:pages="clr-namespace:GalaxyBudsClient.Interface.ViewModels.Pages"
             xmlns:collections="clr-namespace:System.Collections;assembly=System.Runtime"
             xmlns:specifications="clr-namespace:GalaxyBudsClient.Model.Specifications"
             xmlns:ic="clr-namespace:FluentIcons.Avalonia.Fluent;assembly=FluentIcons.Avalonia.Fluent"
             xmlns:i18N="clr-namespace:GalaxyBudsClient.Generated.I18N"
             xmlns:constants="clr-namespace:GalaxyBudsClient.Model.Constants"
             mc:Ignorable="d" d:DesignWidth="800"
             x:Class="GalaxyBudsClient.Interface.Pages.TouchpadPage"
             x:DataType="pages:TouchpadPageViewModel"
             x:CompileBindings="True">

    <Design.DataContext>
        <pages:TouchpadPageViewModel />
    </Design.DataContext>

    <ScrollViewer>
        <StackPanel Spacing="8" Margin="{StaticResource AppPageMargin}">
            <Interaction.Behaviors>
                <ext:RequiresConnectedDeviceBehavior />
            </Interaction.Behaviors>
            
            <controls:SettingsGroup>
                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadLock}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGesturesDescription}}"
                    Symbol="LockClosed"
                    IsChecked="{Binding IsTouchpadLocked}" />
            </controls:SettingsGroup>

            <controls:SettingsGroup>
                <controls:SettingsGroup.IsEnabled>
                    <MultiBinding Converter="{x:Static BoolConverters.And}">
                        <Binding Path="!IsTouchpadLocked" />
                        <Binding Path="IsHoldGestureEnabled" />
                    </MultiBinding>
                </controls:SettingsGroup.IsEnabled>

                <controls:SettingsComboBoxItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadLeftAction}}"
                    Description="{Binding LeftActionDescription}"
                    Symbol="ArrowStepInLeft"
                    DisplayMemberBinding="{Binding ., Converter={StaticResource EnumDescriptionConverter}, DataType=constants:TouchOptions}"
                    ItemsSource="{Binding LeftActions}"
                    SelectedValue="{Binding LeftAction}"
                    IsToolButtonVisible="True"
                    IsToolButtonEnabled="{Binding IsLeftCustomActionEditable}"
                    ToolButtonClick="OnEditLeftCustomActionClicked">
                    
                    <controls:SettingsComboBoxItem.ToolButtonContent>
                        <ic:SymbolIcon Symbol="Edit" />
                    </controls:SettingsComboBoxItem.ToolButtonContent>

                </controls:SettingsComboBoxItem>

                <controls:SettingsComboBoxItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadRightAction}}"
                    Description="{Binding RightActionDescription}"
                    Symbol="ArrowStepInRight"
                    DisplayMemberBinding="{Binding ., Converter={StaticResource EnumDescriptionConverter}, DataType=constants:TouchOptions}"
                    ItemsSource="{Binding RightActions}"
                    SelectedValue="{Binding RightAction}"
                    IsToolButtonVisible="True"
                    IsToolButtonEnabled="{Binding IsRightCustomActionEditable}"
                    ToolButtonClick="OnEditRightCustomActionClicked">
                    
                    <controls:SettingsComboBoxItem.ToolButtonContent>
                        <ic:SymbolIcon Symbol="Edit" />
                    </controls:SettingsComboBoxItem.ToolButtonContent>

                </controls:SettingsComboBoxItem>

                <controls:SettingsComboBoxItem
                    Content="{Binding LeftControlCycleModeLabel}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadNoiseControlModeDesc}}"
                    Symbol="ArrowRepeatAll"
                    IsEnabled="{Binding IsNoiseControlCycleModeEditable}"
                    ItemsSource="{Binding ., Source={ext:NoiseControlCycleModesBindingSource}}"
                    SelectedValue="{Binding NoiseControlCycleMode}">
                    <Interaction.Behaviors>
                        <ext:LocalizationAwareComboBoxBehavior /> 
                        <ext:RequiresFeatureBehavior Feature="NoiseControl" />
                    </Interaction.Behaviors>
                </controls:SettingsComboBoxItem>
                
                <controls:SettingsComboBoxItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadNoiseControlModeR}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadNoiseControlModeDesc}}"
                    Symbol="ArrowRepeatAll"
                    IsEnabled="{Binding IsNoiseControlCycleModeRightEditable}"
                    ItemsSource="{Binding ., Source={ext:NoiseControlCycleModesBindingSource}}"
                    SelectedValue="{Binding NoiseControlCycleModeRight}">
                    <Interaction.Behaviors>
                        <ext:LocalizationAwareComboBoxBehavior /> 
                        <ext:RequiresFeatureBehavior Feature="NoiseControlModeDualSide" />
                    </Interaction.Behaviors>
                </controls:SettingsComboBoxItem>

            </controls:SettingsGroup>

            <controls:SettingsGroup IsEnabled="{Binding !IsTouchpadLocked}">
                <Interaction.Behaviors>
                    <ext:RequiresAnyFeatureBehavior>
                        <ext:RequiresAnyFeatureBehavior.Features>
                            <collections:ArrayList>
                                <specifications:Features>DoubleTapVolume</specifications:Features>
                                <specifications:Features>AdvancedTouchLock</specifications:Features>
                            </collections:ArrayList>
                        </ext:RequiresAnyFeatureBehavior.Features>
                    </ext:RequiresAnyFeatureBehavior>
                </Interaction.Behaviors>

                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadGestureSingle}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGestureSingleDesc}}"
                    Symbol="VideoPlayPause"
                    IsChecked="{Binding IsSingleTapGestureEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="AdvancedTouchLock" />
                    </Interaction.Behaviors>
                </controls:SettingsSwitchItem>

                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadGestureDouble}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGestureDoubleDesc}}"
                    Symbol="Next"
                    IsChecked="{Binding IsDoubleTapGestureEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="AdvancedTouchLock" />
                    </Interaction.Behaviors>
                </controls:SettingsSwitchItem>

                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadGestureTriple}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGestureTripleDesc}}"
                    Symbol="Previous"
                    IsChecked="{Binding IsTripleTapGestureEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="AdvancedTouchLock" />
                    </Interaction.Behaviors>

                </controls:SettingsSwitchItem>
                
                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadGestureHold}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGestureHoldDesc}}"
                    Symbol="TapSingle"
                    IsChecked="{Binding IsHoldGestureEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="AdvancedTouchLock" />
                    </Interaction.Behaviors>
                </controls:SettingsSwitchItem>

                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadGestureDoubleForCall}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGestureDoubleForCallDesc}}"
                    Symbol="CallInbound"
                    IsChecked="{Binding IsDoubleTapGestureForCallsEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="AdvancedTouchLockForCalls" />
                    </Interaction.Behaviors>
                </controls:SettingsSwitchItem>
                
                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadGestureHoldForCall}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadGestureHoldForCallDesc}}"
                    Symbol="CallProhibited"
                    IsChecked="{Binding IsHoldGestureForCallsEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="AdvancedTouchLockForCalls" />
                    </Interaction.Behaviors>
                </controls:SettingsSwitchItem>

                <controls:SettingsSwitchItem
                    Content="{ext:Translate {x:Static i18N:Keys.TouchpadDoubleTapVolume}}"
                    Description="{ext:Translate {x:Static i18N:Keys.TouchpadDoubleTapVolumeDescription}}"
                    Symbol="TapDouble"
                    IsChecked="{Binding IsDoubleTapVolumeEnabled}">
                    <Interaction.Behaviors>
                        <ext:RequiresFeatureBehavior Feature="DoubleTapVolume" />
                    </Interaction.Behaviors>
                </controls:SettingsSwitchItem>
            </controls:SettingsGroup>

        </StackPanel>
    </ScrollViewer>

</UserControl>