<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<androidx.drawerlayout.widget.DrawerLayout
    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"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.habitrpg.android.habitica.ui.activities.MainActivity"
    android:background="@color/white">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions. -->
        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".ui.activities.MainActivity">
            <fragment
                android:id="@+id/nav_host_fragment"
                android:name="androidx.navigation.fragment.NavHostFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:defaultNavHost="true"
                app:navGraph="@navigation/navigation" />
            <com.google.android.material.appbar.AppBarLayout
                android:id="@+id/appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <com.google.android.material.appbar.CollapsingToolbarLayout
                    android:id="@+id/collapsing_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:titleEnabled="false"
                    app:contentScrim="?attr/headerBackgroundColor"
                    android:background="?attr/headerBackgroundColor"
                    app:expandedTitleMarginEnd="?attr/actionBarSize"
                    app:expandedTitleMarginStart="0dp"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed">

                    <include
                        android:id="@+id/avatar_with_bars"
                        layout="@layout/avatar_with_bars"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="?attr/actionBarSize"
                        android:layout_marginEnd="@dimen/header_border_spacing"
                        android:layout_marginStart="@dimen/header_border_spacing"
                        app:layout_collapseMode="parallax" />

                    <androidx.appcompat.widget.Toolbar
                        android:id="@+id/toolbar"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:minHeight="?attr/actionBarSize"
                        android:theme="@style/Toolbar.Modern"
                        android:background="?attr/headerBackgroundColor"
                        app:layout_collapseMode="pin"
                        app:popupTheme="@style/Theme.AppCompat.Light">
                        <RelativeLayout
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginEnd="16dp">

                            <TextView
                                android:id="@+id/toolbar_title"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_centerVertical="true"
                                android:ellipsize="end"
                                android:maxLines="1"
                                android:singleLine="true"
                                android:layout_toStartOf="@id/toolbar_accessory_container"
                                android:layout_alignParentStart="true"
                                style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
                                tools:text="Habitica"/>

                            <FrameLayout
                                android:id="@+id/toolbar_accessory_container"
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:scaleType="centerCrop"
                                android:adjustViewBounds="true"
                                android:layout_centerVertical="true"
                                android:layout_alignParentEnd="true"/>

                        </RelativeLayout>
                    </androidx.appcompat.widget.Toolbar>
                </com.google.android.material.appbar.CollapsingToolbarLayout>

                <com.google.android.material.tabs.TabLayout
                    android:id="@+id/detail_tabs"
                    android:layout_width="match_parent"
                    android:layout_height="54dp"
                    android:layout_gravity="bottom"
                    android:background="?headerOffsetColor"
                    android:elevation="0dp"
                    android:fillViewport="false"

                    android:theme="@style/ThemeOverlay.AppCompat.Light"
                    app:layout_anchor="@+id/collapsing_toolbar"
                    app:layout_anchorGravity="bottom"

                    app:layout_collapseMode="pin"
                    app:tabGravity="fill"
                    app:tabIndicatorColor="?colorPrimary"
                    app:tabMode="fixed" />
                <TextView
                    android:id="@+id/connection_issue_textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="@color/white"
                    android:background="@color/gray_50"
                    android:textSize="14sp"
                    android:gravity="center_horizontal"
                    android:padding="@dimen/spacing_small"
                    android:text="@string/internal_error_api"
                    android:visibility="gone"/>
            </com.google.android.material.appbar.AppBarLayout>

            <RelativeLayout
                android:id="@+id/overlayFrameLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:minHeight="60dp"
                android:layout_gravity="bottom|center_horizontal">
                <FrameLayout
                    android:id="@+id/snackbar_container"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:minHeight="158dp"
                    android:layout_alignParentBottom="true"
                    android:paddingBottom="68dp"/>
                <com.habitrpg.android.habitica.ui.views.navigation.HabiticaBottomNavigationView
                    android:id="@+id/bottom_navigation"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentStart="true"
                    android:layout_alignParentEnd="true" />
            </RelativeLayout>
        </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <!-- The drawer is given a fixed width in dp and extends the full height of
         the container. -->
    <fragment
        android:id="@+id/navigation_drawer"
        class="com.habitrpg.android.habitica.ui.fragments.NavigationDrawerFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        tools:layout="@layout/drawer_main"/>

</androidx.drawerlayout.widget.DrawerLayout>