<?xml version="1.0" encoding="utf-8"?>
<!--
  Nextcloud Android client application

  Copyright (C) 2017 Andy Scherzinger
  Copyright (C) 2017 Nextcloud

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  License as published by the Free Software Foundation; either
  version 3 of the License, or any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU AFFERO GENERAL PUBLIC LICENSE for more details.

  You should have received a copy of the GNU Affero General Public
  License along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<com.google.android.material.appbar.AppBarLayout
    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/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_drawer_header_height"
    android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/drawer_header_background"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:contentDescription="@string/drawer_header_background"
            android:scaleType="centerCrop"/>

        <androidx.appcompat.widget.Toolbar
            android:id="@id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:popupTheme="@style/Theme.AppCompat.DayNight.NoActionBar" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="bottom"
            android:orientation="vertical">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/toolbar_user_information_layout_margin"
                android:layout_marginEnd="@dimen/standard_half_margin"
                android:layout_marginLeft="@dimen/toolbar_user_information_layout_margin"
                android:layout_marginRight="@dimen/standard_half_margin"
                android:layout_marginStart="@dimen/toolbar_user_information_layout_margin"
                android:gravity="bottom"
                android:orientation="horizontal"
                android:weightSum="1">

                <FrameLayout
                    android:id="@+id/avatar_container"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <ImageView
                        android:id="@+id/user_icon"
                        android:layout_width="@dimen/nav_drawer_header_avatar"
                        android:layout_height="@dimen/nav_drawer_header_avatar"
                        android:contentDescription="@string/avatar"
                        android:src="@drawable/account_circle_white"/>
                </FrameLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginLeft="@dimen/standard_half_margin"
                    android:layout_marginRight="@dimen/standard_half_margin"
                    android:layout_toEndOf="@id/avatar_container"
                    android:layout_toRightOf="@id/avatar_container"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/userinfo_username_full"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:maxLines="1"
                        android:shadowColor="@color/drawer_shadow"
                        android:shadowDx="0.5"
                        android:shadowDy="0"
                        android:shadowRadius="2"
                        android:textColor="@color/white"
                        android:textSize="@dimen/drawer_header_text"
                        android:textStyle="bold"
                        tools:text="Max Mustermann"/>

                    <TextView
                        android:id="@+id/userinfo_username"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:lines="1"
                        android:maxLines="1"
                        android:shadowColor="@color/drawer_shadow"
                        android:shadowDx="0.5"
                        android:shadowDy="0"
                        android:shadowRadius="2"
                        android:textColor="@color/white"
                        android:textSize="@dimen/drawer_header_subtext"
                        tools:text="max@127.0.0.1/nextcloud"/>
                </LinearLayout>

            </RelativeLayout>

        <include layout="@layout/info_box"/>

    </LinearLayout>
    </RelativeLayout>

</com.google.android.material.appbar.AppBarLayout>
