<?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="viewModel"
            type="com.topjohnwu.magisk.ui.module.ModuleViewModel" />

    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:orientation="vertical"
        android:paddingBottom="@{viewModel.insets.bottom + (int) @dimen/l1}"
        tools:layout_gravity="bottom"
        tools:paddingBottom="64dp">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/module_filter_list"
            dividerHorizontal="@{@drawable/divider_l1}"
            dividerVertical="@{@drawable/divider_l1}"
            itemBinding="@{viewModel.itemSearchBinding}"
            items="@{viewModel.itemsSearch}"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:fastScrollEnabled="true"
            app:fastScrollHorizontalThumbDrawable="@drawable/fast_scroll_thumb"
            app:fastScrollHorizontalTrackDrawable="@drawable/fast_scroll_track"
            app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll_thumb"
            app:fastScrollVerticalTrackDrawable="@drawable/fast_scroll_track"
            android:layout_marginBottom="@dimen/l1"
            android:clipToPadding="false"
            android:orientation="vertical"
            android:paddingStart="@dimen/l1"
            android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l1}"
            app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
            app:layout_constrainedHeight="true"
            app:layout_constraintBottom_toTopOf="@+id/module_filter_title_search"
            app:layout_constraintTop_toTopOf="parent"
            app:reverseLayout="false"
            app:spanCount="2"
            tools:listitem="@layout/item_repo_md2" />

        <View
            android:layout_width="match_parent"
            android:layout_height="@dimen/l_50"
            android:background="@drawable/bg_shadow"
            app:layout_constraintBottom_toBottomOf="@+id/module_filter_list" />

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/module_filter_title_search"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/l1"
            android:layout_marginEnd="@dimen/l1"
            android:layout_marginBottom="@dimen/l1"
            android:text="@string/hide_search"
            android:textAllCaps="true"
            android:textAppearance="@style/AppearanceFoundation.Caption"
            android:textColor="?colorPrimary"
            android:textStyle="bold"
            app:layout_constraintBottom_toTopOf="@+id/module_filter_search" />

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/module_filter_search"
            style="@style/WidgetFoundation.Card"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/l1"
            android:layout_marginEnd="@dimen/l1"
            android:layout_marginBottom="@dimen/l_50"
            app:cardCornerRadius="18dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/module_filter_done"
            app:layout_constraintStart_toStartOf="parent">

            <androidx.appcompat.widget.AppCompatImageView
                style="@style/WidgetFoundation.Icon"
                android:layout_width="48dp"
                android:layout_height="36dp"
                android:layout_gravity="center_vertical|start"
                android:padding="6dp"
                app:srcCompat="@drawable/ic_search_md2"
                app:tint="?colorDisabled" />

            <androidx.appcompat.widget.AppCompatEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="48dp"
                android:background="@null"
                android:hint="@string/hide_filter_hint"
                android:inputType="textUri"
                android:minHeight="36dp"
                android:paddingStart="0dp"
                android:paddingEnd="@dimen/l1"
                android:singleLine="true"
                android:text="@={viewModel.query}"
                android:textAppearance="@style/AppearanceFoundation.Body"
                android:textColor="@color/color_text_transient"
                android:textColorHint="?colorOnSurfaceVariant" />

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

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/module_filter_done"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/l1"
            app:backgroundTint="?colorPrimary"
            app:elevation="0dp"
            app:tint="?colorOnPrimary"
            app:fabSize="mini"
            app:layout_constraintBottom_toBottomOf="@+id/module_filter_search"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/module_filter_search"
            app:srcCompat="@drawable/ic_check_md2" />

        <ProgressBar
            style="@style/WidgetFoundation.ProgressBar.Indeterminate.Circular"
            goneUnless="@{viewModel.searchLoading}"
            android:layout_width="56dp"
            android:layout_height="56dp"
            app:layout_constraintBottom_toBottomOf="@+id/module_filter_done"
            app:layout_constraintEnd_toEndOf="@+id/module_filter_done"
            app:layout_constraintStart_toStartOf="@+id/module_filter_done"
            app:layout_constraintTop_toTopOf="@+id/module_filter_done" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>
