<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (c) 2023 Samson Achiaga
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<layout 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"
    tools:context=".ui.AddNoteFragment">

    <data>

        <import type="com.certified.audionote.utils.UtilKt" />

        <import type="com.certified.audionote.utils.ReminderAvailableState" />

        <import type="com.certified.audionote.utils.ReminderCompletionState" />

        <variable
            name="viewModel"
            type="com.certified.audionote.ui.NotesViewModel" />

        <variable
            name="reminderAvailableState"
            type="ReminderAvailableState" />

        <variable
            name="reminderCompletionState"
            type="ReminderCompletionState" />

        <variable
            name="note"
            type="com.certified.audionote.model.Note" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/parent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@{note.color}">

        <androidx.appcompat.widget.AppCompatImageButton
            android:id="@+id/btn_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginStart="@dimen/_8sdp"
            android:layout_marginTop="@dimen/_16sdp"
            android:background="@null"
            android:contentDescription="@string/back_button"
            android:padding="@dimen/_4sdp"
            android:tint="@color/black_day_white_night"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/ic_arrow_back_black_24dp"
            tools:ignore="TouchTargetSizeCheck" />

        <com.google.android.material.textview.MaterialTextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/_32sdp"
            android:fontFamily="@font/open_sans_bold"
            android:text="@string/new_note"
            android:textColor="@color/black_day_white_night"
            android:textSize="@dimen/_18ssp"
            app:layout_constraintBottom_toBottomOf="@+id/btn_back"
            app:layout_constraintStart_toEndOf="@+id/btn_back"
            app:layout_constraintTop_toTopOf="@+id/btn_back" />

        <ScrollView
            android:id="@+id/scrollView2"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="@dimen/_16sdp"
            android:layout_marginEnd="@dimen/_16sdp"
            android:paddingTop="@dimen/_16sdp"
            app:layout_constraintBottom_toTopOf="@+id/card_add_reminder"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/btn_back">

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

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/et_note_title"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:fontFamily="@font/open_sans_semi_bold"
                    android:gravity="start|top"
                    android:hint="@string/note_title_required"
                    android:inputType="textMultiLine"
                    android:maxLength="50"
                    android:text="@{note.title}"
                    android:textSize="@dimen/_16ssp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:ignore="TouchTargetSizeCheck,TextContrastCheck" />

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/et_note_description"
                    android:layout_width="0dp"
                    android:layout_height="0dp"
                    android:layout_marginTop="@dimen/_10sdp"
                    android:background="@null"
                    android:ems="10"
                    android:fontFamily="@font/open_sans_regular"
                    android:gravity="start|top"
                    android:hint="@string/description"
                    android:inputType="textMultiLine"
                    android:text="@{note.description}"
                    android:textSize="@dimen/_12ssp"
                    app:layout_constraintBottom_toTopOf="@+id/guideline2"
                    app:layout_constraintEnd_toEndOf="@+id/et_note_title"
                    app:layout_constraintHorizontal_bias="1.0"
                    app:layout_constraintStart_toStartOf="@+id/et_note_title"
                    app:layout_constraintTop_toBottomOf="@+id/et_note_title"
                    tools:ignore="TextContrastCheck" />

                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/guideline2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    app:layout_constraintGuide_percent=".4" />

                <com.google.android.material.textview.MaterialTextView
                    android:id="@+id/tv_timer"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/_16sdp"
                    android:fontFamily="@font/open_sans_regular"
                    android:textColor="@color/black_day_white_night"
                    android:textSize="@dimen/_24ssp"
                    app:layout_constraintBottom_toTopOf="@+id/btn_record"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/et_note_description"
                    app:timeText="@{note.audioLength}"
                    tools:text="00:00" />

                <androidx.appcompat.widget.AppCompatImageButton
                    android:id="@+id/btn_record"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/_16sdp"
                    android:layout_marginBottom="@dimen/_8sdp"
                    android:background="@null"
                    android:contentDescription="@string/record_button"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tv_timer"
                    app:srcCompat="@drawable/ic_mic_not_recording" />

            </androidx.constraintlayout.widget.ConstraintLayout>
        </ScrollView>

        <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
            android:id="@+id/fab_save_note"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/_16sdp"
            android:layout_marginBottom="@dimen/_8sdp"
            android:backgroundTint="@color/fab_background_tint"
            android:text="@string/save"
            android:textAllCaps="false"
            android:textSize="@dimen/_14ssp"
            app:icon="@drawable/ic_done_black_24dp"
            app:iconSize="@dimen/_27sdp"
            app:layout_constraintBottom_toBottomOf="@+id/scrollView2"
            app:layout_constraintEnd_toEndOf="parent" />

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/card_add_reminder"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:elevation="@dimen/_4sdp"
            app:cardBackgroundColor="@null"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/parent_add_reminder"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@{note.color}"
                android:backgroundTint="#27FFFFFF"
                android:backgroundTintMode="screen"
                android:paddingStart="@dimen/_8sdp"
                android:paddingTop="@dimen/_4sdp"
                android:paddingEnd="@dimen/_8sdp"
                android:paddingBottom="@dimen/_4sdp">

                <androidx.appcompat.widget.AppCompatImageButton
                    android:id="@+id/appCompatImageView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:padding="@dimen/_4sdp"
                    android:src="@drawable/ic_alarm_on_black_24dp"
                    android:tint="@color/black_day_white_night"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <com.google.android.material.textview.MaterialTextView
                    android:id="@+id/tv_reminder_date"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/_16sdp"
                    android:fontFamily="@font/open_sans_regular"
                    android:padding="@dimen/_4sdp"
                    android:text="@{UtilKt.formatReminderDate(note.reminder)}"
                    android:textColor="@color/black_day_white_night"
                    android:textSize="@dimen/_14ssp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintStart_toEndOf="@+id/appCompatImageView3"
                    app:layout_constraintTop_toTopOf="parent"
                    app:strikeThrough="@{viewModel.reminderCompletionState == ReminderCompletionState.COMPLETED}"
                    app:visible="@{viewModel.reminderAvailableState == ReminderAvailableState.HAS_REMINDER}" />

                <com.google.android.material.textview.MaterialTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="@dimen/_16sdp"
                    android:fontFamily="@font/open_sans_regular"
                    android:text="@string/click_to_add_a_reminder_to_this_note"
                    android:textSize="@dimen/_12ssp"
                    app:layout_constraintBottom_toBottomOf="@+id/appCompatImageView3"
                    app:layout_constraintStart_toEndOf="@+id/appCompatImageView3"
                    app:layout_constraintTop_toTopOf="@+id/appCompatImageView3"
                    app:visible="@{viewModel.reminderAvailableState == ReminderAvailableState.NO_REMINDER}" />

            </androidx.constraintlayout.widget.ConstraintLayout>

        </com.google.android.material.card.MaterialCardView>

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>