<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.activities.MainActivity">

    <androidx.fragment.app.FragmentContainerView
            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"
            android:background="?attr/headerBackgroundColor">

        <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"
                app:expandedTitleMarginEnd="?attr/actionBarSize"
                app:expandedTitleMarginStart="0dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                android:clipToPadding="true"
                android:clipToOutline="true">

            <androidx.compose.ui.platform.ComposeView
                    android:id="@+id/header_view"
                    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"
                    android:layout_marginBottom="@dimen/spacing_medium"
                    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"
                    style="@style/Toolbar.Modern"
                    android:background="?attr/headerBackgroundColor"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/Theme.AppCompat.DayNight"
                    app:contentInsetStart="0dp"
                    app:contentInsetStartWithNavigation="0dp">

                <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_alignParentStart="true"
                            style="@style/ToolbarTitle"
                            tools:text="Habitica"
                            android:background="@drawable/teams_title_bg"
                            android:paddingHorizontal="@dimen/spacing_large"
                            android:paddingVertical="1dp" />

                    <FrameLayout
                            android:id="@+id/toolbar_accessory_container"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            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="48dp"
                android:layout_gravity="bottom"
                android:background="?headerOffsetColor"
                android:elevation="0dp"
                android:fillViewport="false"
                app:layout_anchor="@+id/collapsing_toolbar"
                app:layout_anchorGravity="bottom"
                app:layout_collapseMode="pin"
                app:tabGravity="fill"
                app:tabIndicatorColor="?textColorPrimary"
                app:tabSelectedTextColor="?textColorPrimary"
                app:tabMode="fixed" />

        <FrameLayout
                android:id="@+id/connection_issue_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingVertical="2dp"
                android:paddingHorizontal="@dimen/spacing_medium"
                android:background="@color/error_banner_background"
                tools:visibility="visible"
                android:visibility="gone">

            <TextView
                    android:id="@+id/connection_issue_textview"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="@color/maroon_500"
                    android:textSize="14sp"
                    android:layout_gravity="center"
                    android:gravity="center_vertical"
                    android:text="@string/internal_error_api"
                    app:drawableStartCompat="@drawable/ic_warning_black"
                    app:drawableTint="@color/maroon_500"
                    android:drawablePadding="4dp" />
        </FrameLayout>
    </com.google.android.material.appbar.AppBarLayout>

    <RelativeLayout
            android:id="@+id/overlayFrameLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="bottom|center_horizontal">

        <FrameLayout
                android:id="@+id/snackbar_container"
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:layout_alignParentBottom="true" />

        <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>
