<?xml version="1.0" encoding="UTF-8" ?>
<StackLayout
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Bit.App.Lists.ItemLayouts.CustomFields.BooleanCustomFieldItemLayout"
    xmlns:u="clr-namespace:Bit.App.Utilities"
    xmlns:controls="clr-namespace:Bit.App.Controls"
    xmlns:cfvm="clr-namespace:Bit.App.Lists.ItemViewModels.CustomFields"
    xmlns:core="clr-namespace:Bit.Core;assembly=BitwardenCore"
    x:DataType="cfvm:BooleanCustomFieldItemViewModel"
    Spacing="0" Padding="0">
    <StackLayout.Resources>
        <ResourceDictionary>
            <u:InverseBoolConverter x:Key="inverseBool" />
            <u:IconGlyphConverter x:Key="iconGlyphConverter" />
            <u:BooleanToBoxRowInputPaddingConverter x:Key="booleanToBoxRowInputPaddingConverter" />
        </ResourceDictionary>
    </StackLayout.Resources>
    <Grid
        StyleClass="box-row"
        Padding="{Binding IsEditing, Converter={StaticResource booleanToBoxRowInputPaddingConverter}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Label
            Text="{Binding Field.Name, Mode=OneWay}"
            StyleClass="box-label"
            Grid.Row="0"
            Grid.Column="0"
            IsVisible="{Binding IsEditing, Mode=OneWay, Converter={StaticResource inverseBool}}" />
        <Label
            Text="{Binding Field.Name, Mode=OneWay}"
            IsVisible="{Binding IsEditing}"
            StyleClass="box-value"
            VerticalOptions="FillAndExpand"
            VerticalTextAlignment="Center"
            Grid.Row="0"
            Grid.Column="0"
            Grid.RowSpan="2" />
        <controls:IconLabel
            Text="{Binding BooleanValue, Mode=OneWay, Converter={StaticResource iconGlyphConverter}, ConverterParameter={x:Static u:BooleanGlyphType.Checkbox}}"
            StyleClass="box-value"
            Grid.Row="1"
            Grid.Column="0"
            Margin="0, 5, 0, 0"
            IsVisible="{Binding IsEditing, Mode=OneWay, Converter={StaticResource inverseBool}}"  />
        <Switch
            IsToggled="{Binding BooleanValue}"
            IsVisible="{Binding IsEditing}"
            Grid.Row="0"
            Grid.Column="1"
            Grid.RowSpan="2" />
        <controls:IconButton 
            StyleClass="box-row-button, box-row-button-platform"
            Text="{Binding Source={x:Static core:BitwardenIcons.Cog}}"
            Command="{Binding FieldOptionsCommand}"
            IsVisible="{Binding IsEditing}"
            Grid.Row="0"
            Grid.Column="2"
            Grid.RowSpan="2"
            AutomationProperties.IsInAccessibleTree="True"
            AutomationProperties.Name="{u:I18n Options}" />
    </Grid>
    <BoxView StyleClass="box-row-separator" />
</StackLayout>
