<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:focusable="true">

    <com.github.chrisbanes.photoview.PhotoView
        android:id="@+id/photoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <!--    This should be inside CoordinatorLayout for two reasons:

            1. TouchImageView really wants some constraints ans has no size otherwise
            2. We don't want sheet to overlap with appbar but the only way to do it with autosizing
            is to gibe parent some margin. -->
    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="70dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:id="@+id/captionSheet"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/description_bg_expanded"
            android:orientation="vertical"
            app:behavior_peekHeight="90dp"
            app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

            <View
                android:layout_width="24dp"
                android:layout_height="3dp"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
                android:background="@drawable/ic_drag_indicator_horiz_24dp"
                android:importantForAccessibility="no" />

            <androidx.core.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/mediaDescription"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hyphenationFrequency="full"
                    android:lineSpacingMultiplier="1.1"
                    android:paddingLeft="8dp"
                    android:paddingRight="8dp"
                    android:paddingBottom="8dp"
                    android:textColor="?android:textColorPrimary"
                    android:textIsSelectable="true"
                    android:textSize="?attr/status_text_medium"
                    tools:text="Some media description which might get quite long so that it won't easily fit in one line" />
            </androidx.core.widget.NestedScrollView>
        </LinearLayout>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>