<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>
        <import type="android.view.View"/>
        <variable
            name="viewModel"
            type="com.wmdigit.setting.viewmodel.DataLearningViewModel" />
    </data>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".fragment.DataLearningFragment">

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

            <androidx.constraintlayout.widget.Guideline
                android:id="@+id/gl_v_46"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_constraintGuide_percent="0.46"/>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="@dimen/dp_0"
                android:layout_height="@dimen/dp_0"
                android:background="@color/black_272E3D"
                android:padding="@dimen/dp_10"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/gl_v_46"
                app:layout_constraintBottom_toTopOf="@+id/keyboard">

                <TextView
                    android:id="@+id/tv_image_desc"
                    style="@style/text_base.content.white"
                    android:text="@string/please_select_correct_goods_for_every_rect"
                    app:layout_constraintStart_toStartOf="@+id/img_preview"
                    app:layout_constraintTop_toTopOf="parent"
                    app:layout_constraintBottom_toTopOf="@+id/img_preview"/>
                
                <ImageView
                    android:id="@+id/img_preview"
                    android:layout_width="@dimen/dp_720"
                    android:layout_height="@dimen/dp_540"
                    android:adjustViewBounds="true"
                    android:background="@color/black"
                    android:layout_marginTop="@dimen/dp_10"
                    app:image="@{viewModel.frame}"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tv_image_desc"

                    />

                <TextView
                    android:id="@+id/tv_camera_status"
                    style="@style/text_base.content.white"
                    android:text="@string/camera_opening"
                    android:visibility="@{viewModel.cameraOpened ? View.INVISIBLE : View.VISIBLE}"
                    app:layout_constraintStart_toStartOf="@+id/img_preview"
                    app:layout_constraintTop_toTopOf="@+id/img_preview"
                    app:layout_constraintEnd_toEndOf="@+id/img_preview"
                    app:layout_constraintBottom_toBottomOf="@+id/img_preview"/>

            </androidx.constraintlayout.widget.ConstraintLayout>

            <!--商品列表-->
            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rv_products"
                android:layout_width="@dimen/dp_0"
                android:layout_height="@dimen/dp_0"
                android:layout_margin="@dimen/dp_5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/gl_v_46"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"/>

            <!--空数据的图-->
            <ImageView
                android:id="@+id/img_empty"
                android:layout_width="@dimen/dp_300"
                android:layout_height="wrap_content"
                android:src="@drawable/img_no_data"
                android:visibility="@{viewModel.totalPage > 0 ? View.INVISIBLE : View.VISIBLE}"
                android:adjustViewBounds="true"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/gl_v_46"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toTopOf="@+id/tv_page"/>

            <!--暂无数据-->
            <TextView
                style="@style/text_base.content"
                android:text="@string/no_data"
                android:visibility="@{viewModel.totalPage > 0 ? View.INVISIBLE : View.VISIBLE}"
                android:textColor="@color/black_333b4b"
                android:textStyle="bold"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/gl_v_46"
                app:layout_constraintBottom_toBottomOf="@+id/img_empty"/>

            <!--键盘-->
            <com.wmdigit.common.view.keyboard.EnglishAndNumberKeyboard
                android:id="@+id/keyboard"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                app:keywords="@={viewModel.keywords}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toEndOf="@+id/gl_v_46"/>

            <!--上一页-->
            <Button
                style="@style/button_base.w130"
                android:background="@{viewModel.currentPage > 1 ? @drawable/sel_rect_10_black_gray : @drawable/rect_10_gray}"
                android:text="@string/previous_page"
                android:layout_marginEnd="@dimen/dp_40"
                android:onClick="@{()->viewModel.previousPage()}"
                app:layout_constraintEnd_toStartOf="@+id/tv_page"
                app:layout_constraintBottom_toBottomOf="@+id/tv_page"
                app:layout_constraintTop_toTopOf="@+id/tv_page"
                />

            <!--当前页码-->
            <TextView
                android:id="@+id/tv_page"
                style="@style/text_base.content"
                android:text="@{String.format(@string/page_number, viewModel.currentPage, viewModel.totalPage)}"
                android:layout_marginBottom="@dimen/dp_34"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/gl_v_46"
                app:layout_constraintBottom_toBottomOf="parent"/>

            <!--下一页-->
            <Button
                style="@style/button_base.w130"
                android:text="@string/next_page"
                android:layout_marginStart="@dimen/dp_40"
                android:background="@{viewModel.currentPage &lt; viewModel.totalPage ? @drawable/sel_rect_10_black_gray : @drawable/rect_10_gray}"
                android:onClick="@{()->viewModel.nextPage()}"
                app:layout_constraintStart_toEndOf="@+id/tv_page"
                app:layout_constraintBottom_toBottomOf="@+id/tv_page"
                app:layout_constraintTop_toTopOf="@+id/tv_page"
                />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </FrameLayout>
</layout>