<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/colorSurface"
    android:fitsSystemWindows="true">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:importantForAccessibility="no"
        android:theme="@style/ThemeOverlay.Material3.Dark.ActionBar">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            style="?attr/collapsingToolbarLayoutLargeStyle"
            android:layout_width="match_parent"
            android:layout_height="@dimen/contact_detail_avatar_height"
            android:fitsSystemWindows="true"
            android:importantForAccessibility="no"
            app:contentScrim="?android:attr/colorBackground"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <!-- Large profile picture in the background -->
            <ch.threema.app.ui.AvatarEditView
                android:id="@+id/avatar_edit_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:contentDescription="@string/profile_picture"
                android:fitsSystemWindows="true"
                android:importantForAccessibility="no"
                app:layout_collapseMode="parallax" />

            <!-- Nickname and - potentially - the Threema Work icon. -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|left"
                android:layout_marginLeft="16dp"
                android:layout_marginRight="16dp"
                android:layout_marginBottom="32dp"
                android:gravity="bottom"
                android:importantForAccessibility="no"
                android:orientation="horizontal">

                <ch.threema.app.ui.HintedImageView
                    android:id="@+id/work_icon"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_marginRight="6dp"
                    android:layout_marginBottom="2dp"
                    android:contentDescription="@string/threema_work_contact"
                    android:foreground="@drawable/selector_avatar"
                    android:visibility="gone"
                    app:srcCompat="@drawable/ic_badge_work" />

                <ch.threema.app.emojis.EmojiTextView
                    android:id="@+id/contact_title"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="2"
                    android:textAppearance="@style/Threema.TextAppearance.DetailTitle"
                    app:layout_anchor="@id/appbar"
                    app:layout_anchorGravity="bottom|left" />
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="16dp"
                android:layout_gravity="bottom"
                android:background="@drawable/shape_detail" />

            <!-- Toolbar at the top -->
            <com.google.android.material.appbar.MaterialToolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:elevation="0dp"
                app:layout_collapseMode="pin" />

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

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

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/contact_group_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <!-- FAB for editing contact -->
    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/floating"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="@dimen/tablet_standard_padding_left_right"
        android:layout_marginBottom="-40dp"
        android:contentDescription="@string/edit_name_only"
        app:fabSize="normal"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|right|end"
        app:layout_insetEdge="bottom"
        app:srcCompat="@drawable/ic_pencil_outline" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
