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

        <variable
            name="goodsBean"
            type="com.atmob.voiceai.data.api.bean.GoodsBean" />

        <variable
            name="onItemClick"
            type="android.view.View.OnClickListener" />

        <variable
            name="showDivider"
            type="Boolean" />

    </data>

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

        <Space
            android:id="@+id/space_top"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintDimensionRatio="360:12.5"
            app:layout_constraintTop_toTopOf="parent" />


        <View
            android:id="@+id/v_goods_bg"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@{goodsBean.select ? @drawable/bg_sub_goods_selected : null}"
            android:onClick="@{onItemClick}"
            app:layout_constraintDimensionRatio="328:72"
            app:layout_constraintTop_toBottomOf="@+id/space_top" />


        <TextView
            isGone="@{!goodsBean.select || !goodsBean.popular}"
            android:layout_width="wrap_content"
            android:layout_height="25dp"
            android:background="@drawable/bg_popular"
            android:gravity="center"
            android:paddingHorizontal="10dp"
            android:text="@string/sub_most_popular"
            android:textColor="@color/colorPrimary"
            android:textSize="13sp"
            android:textStyle="bold"
            app:drawableEndCompat="@drawable/icon_sub_popular"
            app:layout_constraintDimensionRatio="115:25"
            app:layout_constraintEnd_toEndOf="@id/space_top"
            app:layout_constraintStart_toStartOf="@+id/space_top"
            app:layout_constraintTop_toTopOf="@+id/space_top" />


        <ImageView
            android:id="@+id/iv_goods_select"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginStart="16dp"
            android:src="@{goodsBean.select ? @drawable/icon_sub_goods_selected :@drawable/icon_sub_goods_not_select }"
            app:layout_constraintBottom_toBottomOf="@+id/v_goods_bg"
            app:layout_constraintDimensionRatio="1:1"
            app:layout_constraintStart_toStartOf="@+id/v_goods_bg"
            app:layout_constraintTop_toTopOf="@+id/v_goods_bg"
            app:layout_constraintWidth_percent="0.0731707317073171"
            tools:src="@drawable/icon_sub_goods_selected" />

        <TextView
            android:id="@+id/tv_goods_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="12dp"
            android:text="@{goodsBean.name}"
            android:textColor="@{goodsBean.select ? @color/colorPrimaryVariant : @color/white}"
            android:textSize="20sp"
            android:textStyle="bold"
            app:layout_constraintBottom_toTopOf="@+id/tv_content"
            app:layout_constraintStart_toEndOf="@+id/iv_goods_select"
            app:layout_constraintTop_toTopOf="@+id/iv_goods_select"
            app:layout_constraintVertical_chainStyle="packed"
            tools:text="Yearly"
            tools:textColor="@color/colorPrimaryVariant" />

        <TextView
            android:id="@+id/tv_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:text="@{goodsBean.priceContent}"
            android:textColor="@color/white50"
            android:textSize="12sp"
            app:layout_constraintBottom_toBottomOf="@+id/iv_goods_select"
            app:layout_constraintStart_toStartOf="@+id/tv_goods_name"
            app:layout_constraintTop_toBottomOf="@+id/tv_goods_name"
            tools:text="$0.77/week" />

        <TextView
            android:id="@+id/tv_price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="20dp"
            android:text="@{goodsBean.gpProductInfo.formatPrice}"
            android:textColor="@color/white"
            android:textSize="20sp"
            android:textStyle="bold"
            app:layout_constraintBottom_toTopOf="@+id/tv_description"
            app:layout_constraintEnd_toEndOf="@id/v_goods_bg"
            app:layout_constraintTop_toTopOf="@id/v_goods_bg"
            app:layout_constraintVertical_chainStyle="packed"
            tools:text="$39.99" />

        <TextView
            android:id="@+id/tv_description"
            isGone="@{goodsBean.description == null || goodsBean.description.length() == 0}"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/bg_sub_goods_description"
            android:paddingHorizontal="6dp"
            android:paddingVertical="3dp"
            android:text="@{goodsBean.description}"
            android:textColor="@color/white"
            android:textSize="12sp"
            app:layout_constraintBottom_toBottomOf="@id/v_goods_bg"
            app:layout_constraintEnd_toEndOf="@+id/tv_price"
            app:layout_constraintTop_toBottomOf="@+id/tv_price"
            tools:text="80% OFF" />


        <View
            android:id="@+id/v_divider"
            isGone="@{!showDivider}"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginHorizontal="9dp"
            android:background="@drawable/bg_sub_line"
            app:layout_constraintBottom_toBottomOf="@+id/v_goods_bg" />


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