<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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="wrap_content"
    android:fillViewport="true">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="@dimen/spacer_2x">

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/labelsWrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/label_labels"
            app:layout_constraintBottom_toTopOf="@id/labelsGroup"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:startIconDrawable="@drawable/ic_label_24dp">

            <it.niedermann.nextcloud.deck.ui.view.ToggleAutoCompleteTextView
                android:id="@+id/labels"
                style="@style/Widget.Material3.AutoCompleteTextView.OutlinedBox.Dense"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:completionThreshold="1"
                android:inputType="text" />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.chip.ChipGroup
            android:id="@+id/labelsGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="true"
            app:layout_constraintBottom_toTopOf="@id/peopleWrapper"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/labelsWrapper" />

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/peopleWrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/spacer_2x"
            android:hint="@string/hint_assign_people"
            app:layout_constraintBottom_toTopOf="@id/assignees"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/labelsGroup"
            app:startIconDrawable="@drawable/ic_person_24dp">

            <it.niedermann.nextcloud.deck.ui.view.ToggleAutoCompleteTextView
                android:id="@+id/people"
                style="@style/Widget.Material3.AutoCompleteTextView.OutlinedBox.Dense"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:completionThreshold="1"
                android:inputType="text" />
        </com.google.android.material.textfield.TextInputLayout>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/assignees"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/spacer_1x"
            android:layout_marginBottom="@dimen/spacer_1hx"
            app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
            app:layout_constraintBottom_toTopOf="@id/cardDueDateView"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/peopleWrapper"
            tools:listitem="@tools:sample/avatars" />

        <it.niedermann.nextcloud.deck.ui.card.details.CardDueDateView
            android:id="@+id/cardDueDateView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/spacer_2x"
            app:layout_constraintBottom_toTopOf="@id/descriptionWrapper"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/assignees" />


        <RelativeLayout
            android:id="@+id/descriptionWrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/spacer_1x"
            app:layout_constraintBottom_toTopOf="@id/projectsTitle"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/cardDueDateView">

            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/descriptionEditorWrapper"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/spacer_1x"
                android:hint="@string/label_description">

                <it.niedermann.android.markdown.MarkdownEditorImpl
                    android:id="@+id/descriptionEditor"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/spacer_2x"
                    android:textColor="?attr/colorOnSurface"
                    android:textSize="@dimen/font_size_description" />

            </com.google.android.material.textfield.TextInputLayout>

            <it.niedermann.android.markdown.MarkdownViewerImpl
                android:id="@+id/descriptionViewer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="12dp"
                android:padding="@dimen/spacer_2x"
                android:textColor="?attr/colorOnSurface"
                android:textIsSelectable="true"
                android:textSize="@dimen/font_size_description"
                android:translationY="1dp"
                android:visibility="visible" />

            <ImageButton
                android:id="@+id/descriptionToggle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_alignParentEnd="true"
                android:layout_gravity="bottom"
                android:layout_marginEnd="6dp"
                android:background="?android:windowBackground"
                android:contentDescription="@string/edit_description"
                android:paddingStart="@dimen/spacer_1hx"
                android:paddingTop="@dimen/spacer_1x"
                android:paddingEnd="@dimen/spacer_1hx"
                android:paddingBottom="@dimen/spacer_1hx"
                android:translationY="-7dp"
                android:visibility="invisible"
                app:srcCompat="@drawable/ic_eye_24"
                tools:visibility="visible" />
        </RelativeLayout>

        <TextView
            android:id="@+id/projectsTitle"
            style="?attr/textAppearanceOverline"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingStart="@dimen/spacer_4x"
            android:paddingEnd="@null"
            android:text="@string/projects_title"
            app:layout_constraintBottom_toTopOf="@id/projects"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/descriptionWrapper" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/projects"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/projectsTitle"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/projectsTitle"
            tools:listitem="@layout/item_project" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
