<?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"
    tools:context=".postCreation.PostSubmissionFragment"
    android:id="@+id/postSubmissionFragment" >

    <com.google.android.material.appbar.MaterialToolbar
        android:id="@+id/top_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:theme="?attr/actionBarTheme"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/post_preview"
        android:layout_margin="20dp"
        android:layout_width="88dp"
        android:layout_height="88dp"
        android:contentDescription="@string/post_preview"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/top_bar"/>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/upload_error"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="2dp"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/top_bar"
        tools:visibility="visible">

        <TextView
            android:id="@+id/upload_error_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="?attr/colorError"
            android:text="@string/media_upload_failed"
            android:textColor="?attr/colorOnError"
            android:textSize="20sp"
            app:drawableStartCompat="@drawable/cloud_off_24"
            app:drawableTint="?attr/colorOnError"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/upload_error_text_explanation"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="?attr/colorError"
            android:textColor="?attr/colorOnError"
            android:textSize="20sp"
            android:visibility="gone"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/upload_error_text_view"
            tools:text="Error code returned by server: 413"
            tools:visibility="visible" />

        <Button
            android:id="@+id/retry_upload_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/retry"
            app:layout_constraintEnd_toEndOf="@id/upload_error_text_view"
            app:layout_constraintHorizontal_bias="0.498"
            app:layout_constraintStart_toStartOf="@id/upload_error_text_view"
            app:layout_constraintTop_toBottomOf="@+id/upload_error_text_explanation" />
    </androidx.constraintlayout.widget.ConstraintLayout>


    <TextView
        android:id="@+id/upload_completed_textview"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_marginEnd="8dp"
        android:text="@string/media_upload_completed"
        android:textColor="@android:color/holo_green_light"
        android:textSize="16sp"
        android:visibility="invisible"
        app:drawableStartCompat="@drawable/cloud_done_24"
        app:drawableTint="@android:color/holo_green_light"
        app:layout_constraintBottom_toTopOf="@+id/buttonConstraints"
        app:layout_constraintEnd_toEndOf="parent"
        tools:visibility="visible" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/buttonConstraints"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <Button
            android:id="@+id/post_creation_send_button"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:enabled="true"
            android:text="@string/post"
            android:visibility="visible"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <ProgressBar
            android:id="@+id/posting_progress_bar"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

    <ProgressBar
        android:id="@+id/uploadProgressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:visibility="invisible"
        app:layout_constraintBottom_toBottomOf="@+id/upload_completed_textview"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/postTextInputLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/description"
        android:paddingStart="15dp"
        android:paddingTop="8dp"
        android:paddingEnd="15dp"
        app:counterEnabled="true"
        app:errorEnabled="true"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/post_preview">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/new_post_description_input_field"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ems="10"
            android:inputType="textMultiLine" />

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


    <com.google.android.material.materialswitch.MaterialSwitch
        android:id="@+id/nsfwSwitch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        app:layout_constraintBottom_toBottomOf="@+id/post_preview"
        app:layout_constraintStart_toEndOf="@+id/post_preview"
        app:layout_constraintTop_toTopOf="@+id/post_preview" />

    <TextView
        android:id="@+id/privateTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/contains_nsfw"
        android:textStyle="bold"
        android:padding="8dp"
        app:layout_constraintBottom_toBottomOf="@+id/nsfwSwitch"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toEndOf="@+id/nsfwSwitch"
        app:layout_constraintTop_toTopOf="@+id/nsfwSwitch" />

</androidx.constraintlayout.widget.ConstraintLayout>