<?xml version="1.0" encoding="UTF-8"?>
<controls:ExtendedGrid xmlns="http://xamarin.com/schemas/2014/forms"
                       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                       x:Class="Bit.App.Controls.AuthenticatorViewCell"
                       xmlns:controls="clr-namespace:Bit.App.Controls"
                       xmlns:pages="clr-namespace:Bit.App.Pages"
                       xmlns:u="clr-namespace:Bit.App.Utilities"
                       xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
                       xmlns:core="clr-namespace:Bit.Core;assembly=BitwardenCore"
                       StyleClass="list-row, list-row-platform"
                       HorizontalOptions="FillAndExpand"
                       x:DataType="pages:GroupingsPageTOTPListItem"
                       ColumnDefinitions="40,*,40,Auto,40"
                       RowSpacing="0"
                       Padding="0,10,0,0"
                       RowDefinitions="*,*">

    <Grid.Resources>
        <u:IconGlyphConverter x:Key="iconGlyphConverter" />
        <u:InverseBoolConverter x:Key="inverseBool" />
    </Grid.Resources>

    <controls:IconLabel
        Grid.Column="0"
        HorizontalOptions="Center"
        VerticalOptions="Center"
        StyleClass="list-icon, list-icon-platform"
        Grid.RowSpan="2"
        IsVisible="{Binding ShowIconImage, Converter={StaticResource inverseBool}}"
        Text="{Binding Cipher, Converter={StaticResource iconGlyphConverter}}"
        AutomationProperties.IsInAccessibleTree="False" />

    <ff:CachedImage
        Grid.Column="0"
        BitmapOptimizations="True"
        ErrorPlaceholder="login.png"
        LoadingPlaceholder="login.png"
        HorizontalOptions="Center"
        VerticalOptions="Center"
        WidthRequest="22"
        HeightRequest="22"
        Grid.RowSpan="2"
        IsVisible="{Binding ShowIconImage}"
        Source="{Binding IconImageSource, Mode=OneTime}"
        AutomationProperties.IsInAccessibleTree="False" />

    <Label
        LineBreakMode="TailTruncation"
        Grid.Column="1"
        Grid.Row="0"
        VerticalTextAlignment="Center"
        VerticalOptions="Fill"
        StyleClass="list-title, list-title-platform"
        Text="{Binding Cipher.Name}" />

    <Label
        LineBreakMode="TailTruncation"
        Grid.Column="1"
        Grid.Row="1"
        VerticalTextAlignment="Center"
        VerticalOptions="Fill"
        StyleClass="list-subtitle, list-subtitle-platform"
        Text="{Binding Cipher.SubTitle}" />

    <controls:CircularProgressbarView
        Progress="{Binding Progress}"
        Grid.Row="0"
        Grid.Column="2"
        Grid.RowSpan="2"
        HorizontalOptions="Fill"
        VerticalOptions="CenterAndExpand" />

    <Label
        Text="{Binding TotpSec, Mode=OneWay}"
        Style="{DynamicResource textTotp}"
        Grid.Row="0"
        Grid.Column="2"
        Grid.RowSpan="2"
        StyleClass="text-sm"
        HorizontalTextAlignment="Center"
        HorizontalOptions="Fill"
        VerticalTextAlignment="Center"
        VerticalOptions="Fill" />
    
    <StackLayout
        Grid.Row="0"
        Grid.Column="3"
        Margin="3,0,2,0"
        Spacing="5"
        Grid.RowSpan="2"
        Orientation="Horizontal"
        HorizontalOptions="Fill"
        VerticalOptions="Fill">

        <controls:MonoLabel
            Text="{Binding TotpCodeFormattedStart, Mode=OneWay}"
            Style="{DynamicResource textTotp}"
            StyleClass="text-lg"
            HorizontalTextAlignment="Center"
            VerticalTextAlignment="Center"
            HorizontalOptions="Center"
            VerticalOptions="FillAndExpand" />
        
        <controls:MonoLabel
            Text="{Binding TotpCodeFormattedEnd, Mode=OneWay}"
            Style="{DynamicResource textTotp}"
            StyleClass="text-lg"
            HorizontalTextAlignment="Center"
            VerticalTextAlignment="Center"
            HorizontalOptions="Center"
            VerticalOptions="FillAndExpand" />
    </StackLayout>

    <controls:IconButton
        StyleClass="box-row-button, box-row-button-platform"
        Text="{Binding Source={x:Static core:BitwardenIcons.Clone}}"
        Command="{Binding CopyCommand}"
        CommandParameter="LoginTotp"
        Grid.Row="0"
        Grid.Column="4"
        Grid.RowSpan="2"
        Padding="0,0,1,0"
        HorizontalOptions="Center"
        VerticalOptions="Center"
        AutomationProperties.IsInAccessibleTree="True"
        AutomationProperties.Name="{u:I18n CopyTotp}" />
</controls:ExtendedGrid>