<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2022 Proton AG
  ~
  ~ This file is part of Proton Mail.
  ~
  ~ Proton Mail is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ (at your option) any later version.
  ~
  ~ Proton Mail 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 General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~ along with Proton Mail. If not, see https://www.gnu.org/licenses/.
  -->

<com.google.android.material.appbar.CollapsingToolbarLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/collapsingToolbarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/background_norm"
    app:layout_scrollFlags="scroll|exitUntilCollapsed"
    tools:showIn="@layout/activity_message_details">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:paddingStart="@dimen/toolbar_padding_start"
        android:paddingEnd="@dimen/toolbar_padding_end"
        app:contentInsetStartWithNavigation="0dp"
        app:layout_collapseMode="pin"
        app:navigationIcon="@drawable/ic_proton_arrow_left">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:id="@+id/collapsedToolbarMessagesCountTextView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:maxLines="1"
                android:textSize="@dimen/default_text_size_small"
                android:gravity="center_horizontal"
                android:textAppearance="@style/Proton.Text.DefaultSmall.Weak"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/starToggleButton"
                app:layout_constraintBottom_toTopOf="@+id/collapsedToolbarTitleTextView"
                android:visibility="gone"
                tools:visibility="visible"
                tools:text="1 Message" />

            <TextView
                android:id="@+id/expandedToolbarMessagesCountTextView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:maxLines="1"
                android:gravity="center_horizontal"
                android:textAppearance="@style/Proton.Text.DefaultSmall.Medium"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/starToggleButton"
                app:layout_constraintTop_toTopOf="parent"
                android:visibility="gone"
                tools:visibility="gone"
                tools:text="1 Message" />

            <TextView
                android:id="@+id/collapsedToolbarTitleTextView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:maxLines="1"
                android:ellipsize="end"
                android:textAppearance="@style/Proton.Text.DefaultSmall.Medium"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/starToggleButton"
                app:layout_constraintTop_toTopOf="parent"
                tools:text="@tools:sample/lorem/random" />

            <ToggleButton
                android:id="@+id/starToggleButton"
                android:layout_width="@dimen/toolbar_action_layout_icon_size"
                android:layout_height="@dimen/toolbar_action_layout_icon_size"
                android:layout_margin="@dimen/padding_m"
                android:background="@drawable/selector_star_action_icon"
                android:textOff=""
                android:textOn=""
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.appcompat.widget.Toolbar>

    <TextView
        android:id="@+id/expandedToolbarTitleTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="?attr/actionBarSize"
        android:layout_marginBottom="@dimen/expanded_toolbar_title_margin_bottom"
        android:paddingHorizontal="@dimen/expanded_toolbar_title_padding_horizontal"
        android:textAppearance="@style/Proton.Text.Headline"
        app:layout_collapseMode="parallax"
        app:layout_collapseParallaxMultiplier="0.3"
        tools:text="@tools:sample/lorem" />

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