<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="12dp"
    android:layout_marginEnd="12dp"
    android:layout_marginBottom="12dp"
    android:orientation="vertical"
    app:cardBackgroundColor="?attr/attachmentCardBackground"
    app:cardCornerRadius="2dp"
    app:cardElevation="1dp">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/attachment_preview"
            android:layout_width="match_parent"
            android:layout_height="150dp"
            android:background="?android:attr/windowBackground"
            android:contentDescription="@null"
            android:visibility="gone"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:visibility="visible" />

        <ImageView
            android:id="@+id/attachment_type"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:contentDescription="@null"
            app:srcCompat="@drawable/ic_attachment_generic"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/attachment_preview"
            app:tint="?attr/colorAccent" />

        <TextView
            android:id="@+id/attachment_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="8dp"
            android:ellipsize="start"
            android:singleLine="true"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="14sp"
            app:layout_constraintBottom_toTopOf="@+id/attachment_size"
            app:layout_constraintEnd_toStartOf="@id/barrier_button"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toEndOf="@+id/attachment_type"
            app:layout_constraintTop_toBottomOf="@+id/attachment_preview"
            app:layout_constraintVertical_chainStyle="packed"
            tools:text="filename.ext" />

        <TextView
            android:id="@+id/attachment_size"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:singleLine="true"
            android:textColor="?android:attr/textColorSecondary"
            android:textSize="12sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/barrier_button"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="@+id/attachment_name"
            app:layout_constraintTop_toBottomOf="@+id/attachment_name"
            app:layout_constraintVertical_bias="0.0"
            tools:text="99 KB" />

        <androidx.constraintlayout.widget.Barrier
            android:id="@+id/barrier_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="left" />

        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleSmall"
            android:layout_width="32dp"
            android:layout_height="32dp"
            android:layout_marginStart="8dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/attachment_delete"
            app:layout_constraintStart_toEndOf="@id/barrier_button"
            app:layout_constraintTop_toBottomOf="@+id/attachment_preview" />

        <ImageButton
            android:id="@+id/attachment_delete"
            android:layout_width="42dp"
            android:layout_height="42dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            android:background="?attr/selectableItemBackgroundBorderless"
            android:contentDescription="@string/remove_attachment_action"
            app:srcCompat="?attr/iconActionCancel"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/attachment_preview" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.cardview.widget.CardView>
