<?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.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            android:id="@+id/modules_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:onRefreshListener="@{() -> viewModel.refresh(false)}"
            app:refreshing="@{viewModel.loading}">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/modules_content"
                dividerColor="@{@android:color/transparent}"
                dividerSize="@{@dimen/margin_generic}"
                itemBinding="@{viewModel.itemBinding}"
                items="@{viewModel.itemsInstalled}"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipToPadding="false"
                android:orientation="vertical"
                android:padding="@dimen/margin_generic"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                tools:listitem="@layout/item_module" />

        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/modules_status_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:fontFamily="sans-serif-light"
            android:gravity="center"
            android:text="@string/no_modules_found"
            android:textSize="20sp"
            android:textStyle="italic"
            android:visibility="gone"
            tools:visibility="visible" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:layout_margin="@dimen/fab_padding"
            android:onClick="@{() -> viewModel.fabPressed()}"
            app:fabSize="normal"
            app:layout_behavior="com.google.android.material.floatingactionbutton.FloatingActionButton$Behavior"
            app:srcCompat="@drawable/ic_add" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

</layout>