<?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="com.topjohnwu.magisk.R" />

        <variable
            name="viewModel"
            type="com.topjohnwu.magisk.ui.hide.HideViewModel" />

    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="false"
        android:orientation="vertical"
        android:paddingStart="@dimen/l1"
        android:paddingTop="@dimen/l1"
        android:paddingEnd="@dimen/l1"
        android:paddingBottom="@dimen/l1"
        app:fitsSystemWindowsInsets="bottom"
        tools:layout_gravity="bottom"
        tools:paddingBottom="64dp">

        <TextView
            android:id="@+id/hide_filter_title_filter"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/hide_filters"
            android:textAllCaps="true"
            android:textAppearance="@style/AppearanceFoundation.Caption"
            android:textColor="?colorPrimary"
            android:textStyle="bold"
            app:layout_constraintTop_toTopOf="parent" />

        <com.google.android.material.chip.ChipGroup
            android:id="@+id/hide_filter_chip_group"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/l1"
            app:chipSpacing="2dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/hide_filter_title_filter">

            <com.google.android.material.chip.Chip
                android:id="@+id/hide_filter_system_chip"
                style="@style/Widget.MaterialComponents.Chip.Filter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="@={viewModel.showSystem}"
                android:nextFocusRight="@id/hide_filter_chip_data"
                android:nextFocusDown="@id/hide_filter_search_field"
                android:text="@string/show_system_app"
                android:textAppearance="@style/AppearanceFoundation.Caption"
                app:checkedIcon="@drawable/ic_check_md2"
                app:chipBackgroundColor="?colorSurfaceVariant"
                tools:checked="true" />

            <com.google.android.material.chip.Chip
                android:id="@+id/hide_filter_os_chip"
                style="@style/Widget.MaterialComponents.Chip.Filter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="@={viewModel.showOS}"
                android:nextFocusRight="@id/hide_filter_chip_data"
                android:nextFocusDown="@id/hide_filter_search_field"
                android:text="@string/show_os_app"
                android:textAppearance="@style/AppearanceFoundation.Caption"
                app:checkedIcon="@drawable/ic_check_md2"
                app:chipBackgroundColor="?colorSurfaceVariant"
                tools:checked="true" />

            <com.google.android.material.chip.Chip
                android:id="@+id/hide_filter_chip_data"
                style="@style/Widget.MaterialComponents.Chip.Entry"
                gone="@{viewModel.query.empty}"
                onCloseClicked="@{() -> viewModel.resetQuery()}"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checkable="false"
                android:nextFocusRight="@id/hide_filter_done"
                android:nextFocusDown="@id/hide_filter_search_field"
                android:text="@{viewModel.query}"
                android:textAppearance="@style/AppearanceFoundation.Caption"
                app:chipBackgroundColor="?colorSurfaceVariant" />

        </com.google.android.material.chip.ChipGroup>

        <TextView
            android:id="@+id/hide_filter_title_search"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/l1"
            android:text="@string/hide_search"
            android:textAllCaps="true"
            android:textAppearance="@style/AppearanceFoundation.Caption"
            android:textColor="?colorPrimary"
            android:textStyle="bold"
            app:layout_constraintTop_toBottomOf="@+id/hide_filter_chip_group" />

        <com.google.android.material.card.MaterialCardView
            android:id="@+id/hide_filter_search"
            style="@style/WidgetFoundation.Card"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="@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/hide_filter_done"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/hide_filter_title_search">

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

            <EditText
                android:id="@+id/hide_filter_search_field"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="48dp"
                android:background="@null"
                android:gravity="start|center_vertical"
                android:hint="@string/hide_filter_hint"
                android:inputType="textUri"
                android:minHeight="36dp"
                android:nextFocusRight="@id/hide_filter_done"
                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/hide_filter_done"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:nextFocusLeft="@id/hide_filter_system_chip"
            app:backgroundTint="?colorPrimary"
            app:elevation="0dp"
            app:fabSize="mini"
            app:layout_constraintBottom_toBottomOf="@+id/hide_filter_search"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@+id/hide_filter_search"
            app:srcCompat="@drawable/ic_check_md2"
            app:tint="?colorOnPrimary" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>
