<?xml version="1.0" encoding="utf-8"?>

<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">

    <data>

        <import type="it.integry.integrywmsnative.core.utility.UtilityNumber" />
        <import type="android.view.View" />

        <variable
            name="view"
            type="it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditView" />

        <variable
            name="viewModel"
            type="it.integry.integrywmsnative.view.bottom_sheet__mtb_colr_edit.BottomSheetMtbColrEditViewModel" />
    </data>

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


        <androidx.cardview.widget.CardView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:cardCornerRadius="16dp"
            app:cardElevation="4dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">


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

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/title_layout"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="8dp"
                        android:orientation="vertical"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintEnd_toStartOf="@id/qta_layout">

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/bottom_sheet_actions_title"
                            style="@style/AppTheme.NewMaterial.Text.Medium"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:ellipsize="end"
                            android:maxLines="2"
                            android:paddingStart="0dp"
                            android:paddingEnd="8dp"
                            android:text="@{viewModel.mtbColr.descrizione}"
                            android:textColor="#444"
                            android:textStyle="bold"
                            tools:text="Descrizione articolo" />

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/bottom_sheet_actions_subtitle"
                            style="@style/AppTheme.NewMaterial.Text.Small"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@{viewModel.mtbColr.codMart}"
                            tools:text="ABF52IL" />

                    </LinearLayout>

                    <androidx.appcompat.widget.LinearLayoutCompat
                        android:id="@+id/qta_layout"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent">


                        <androidx.appcompat.widget.LinearLayoutCompat
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal">

                            <TextView
                                style="@style/AppTheme.NewMaterial.Text.Small"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="end"
                                android:text="@{UtilityNumber.decimalToString(viewModel.mtbColr.qtaCol)}"
                                android:textStyle="bold"
                                tools:text="250" />

                            <TextView
                                style="@style/AppTheme.NewMaterial.Text.Small"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="4dp"
                                android:gravity="end"
                                android:text="@{viewModel.mtbColr.untMis}"
                                android:textStyle="bold"
                                tools:text="PZ" />

                        </androidx.appcompat.widget.LinearLayoutCompat>


                        <androidx.appcompat.widget.LinearLayoutCompat
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal">

                            <TextView
                                style="@style/AppTheme.NewMaterial.Text.Small"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="end"
                                android:text="@{UtilityNumber.decimalToString(viewModel.mtbColr.numCnf)}"
                                android:textStyle="bold"
                                tools:text="250" />

                            <TextView
                                style="@style/AppTheme.NewMaterial.Text.Small"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginStart="4dp"
                                android:gravity="end"
                                android:text="@string/unt_mis_col"
                                android:textAllCaps="true"
                                android:textStyle="bold" />

                        </androidx.appcompat.widget.LinearLayoutCompat>

                    </androidx.appcompat.widget.LinearLayoutCompat>
                </androidx.constraintlayout.widget.ConstraintLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/title_layout">


                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline_action"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="vertical"
                        app:layout_constraintGuide_percent="@{!view.enabledEditButton ? 0f : (!view.enabledDeleteButton ? 1f : 0.50f)}"
                        tools:layout_constraintGuide_percent="0.5f"/>

                    <androidx.appcompat.widget.LinearLayoutCompat
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:orientation="vertical"
                        android:clickable="true"
                        android:focusable="true"
                        android:enabled="false"
                        app:visibility="@{view.enabledEditButton}"
                        app:singleClick="@{() -> view.editMtbColr()}"
                        app:layout_constraintEnd_toStartOf="@id/guideline_action"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent">

                        <androidx.appcompat.widget.AppCompatImageView
                            android:id="@+id/bottom_sheet_actions_edit_btn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@android:color/white"
                            android:padding="16dp"
                            android:scaleX="1.5"
                            android:scaleY="1.5"
                            android:src="@drawable/ic_edit_24dp"
                            android:tint="@color/green_600"
                            android:duplicateParentState="true"/>

                        <androidx.appcompat.widget.AppCompatTextView
                            style="@style/AppTheme.NewMaterial.Text.Small"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/edit"
                            android:duplicateParentState="true" />

                    </androidx.appcompat.widget.LinearLayoutCompat>

                    <androidx.appcompat.widget.LinearLayoutCompat
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:orientation="vertical"
                        android:clickable="true"
                        android:focusable="true"
                        app:visibility="@{view.enabledDeleteButton ? View.VISIBLE : View.GONE}"
                        app:singleClick="@{() -> view.deleteMtbColr()}"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="@id/guideline_action"
                        app:layout_constraintTop_toTopOf="parent">

                        <androidx.appcompat.widget.AppCompatImageView
                            android:id="@+id/bottom_sheet_actions_delete_btn"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@android:color/white"
                            android:padding="16dp"
                            android:scaleX="1.5"
                            android:scaleY="1.5"
                            android:src="@drawable/ic_delete_24dp"
                            android:tint="@color/red_600" />

                        <androidx.appcompat.widget.AppCompatTextView
                            style="@style/AppTheme.NewMaterial.Text.Small"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/delete" />

                    </androidx.appcompat.widget.LinearLayoutCompat>

                </androidx.constraintlayout.widget.ConstraintLayout>

            </androidx.constraintlayout.widget.ConstraintLayout>

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