<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipChildren="false"
        android:fitsSystemWindows="true">

        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:id="@+id/fragment_holder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true" />

        <!-- We double trackThickness as half of it will be invisible -->
        <com.google.android.material.progressindicator.CircularProgressIndicator
            android:id="@+id/fabProgress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:max="1"
            android:visibility="invisible"
            app:indicatorColor="?colorMaterial100"
            app:layout_anchor="@+id/fab"
            app:layout_anchorGravity="center"
            app:layout_behavior="io.nekohasekai.sagernet.widget.FabProgressBehavior"
            app:trackCornerRadius="@dimen/mtrl_progress_track_thickness"
            app:trackThickness="8dp" />

        <io.nekohasekai.sagernet.widget.ServiceButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:elevation="6dp"
            android:nextFocusDown="@+id/stats"
            app:backgroundTint="?fabColorBackground"
            app:layout_anchor="@id/stats"
            app:pressedTranslationZ="6dp"
            app:srcCompat="@drawable/ic_service_idle" />

        <io.nekohasekai.sagernet.widget.StatsBar
            android:id="@+id/stats"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:fitsSystemWindows="true"
            android:nextFocusUp="@+id/fab"
            app:backgroundTint="?colorMaterial300"
            app:contentInsetStart="0dp"
            app:hideOnScroll="true"
            app:layout_scrollFlags="enterAlways|scroll">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="?android:attr/selectableItemBackground"
                android:orientation="vertical"
                android:padding="16dp">

                <TextView
                    android:id="@+id/tx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:layout_gravity="fill_horizontal"
                    android:ellipsize="marquee"
                    android:singleLine="true"
                    android:textColor="?whiteOrTextPrimary"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/rx"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_columnWeight="1"
                    android:layout_gravity="fill_horizontal"
                    android:ellipsize="marquee"
                    android:singleLine="true"
                    android:textColor="?whiteOrTextPrimary"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/status"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="fill_horizontal"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:textColor="?whiteOrTextPrimary"
                    android:textSize="16sp"
                    tools:text="@string/connection_test_available" />

            </LinearLayout>

        </io.nekohasekai.sagernet.widget.StatsBar>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        style="@style/Widget.Design.NavigationView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:itemIconTint="@color/navigation_icon"
        app:itemTextColor="@color/navigation_icon"
        app:menu="@menu/main_drawer_menu" />

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view_black"
        style="@style/Widget.Design.NavigationView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:itemIconTint="@color/navigation_icon"
        app:itemShapeAppearance="@style/ShapeAppearance.MaterialComponents.MediumComponent"
        app:itemShapeFillColor="@color/navigation_item"
        app:itemTextColor="@color/navigation_icon"
        app:menu="@menu/main_drawer_menu" />

</androidx.drawerlayout.widget.DrawerLayout>