<?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"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:clipToPadding="false"
	tools:context=".details.ui.DetailsActivity"
	tools:ignore="ViewBindingType"
	tools:viewBindingType="android.view.ViewGroup">

	<com.google.android.material.appbar.AppBarLayout
		android:id="@+id/appbar"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:elevation="0dp"
		android:fitsSystemWindows="true"
		app:elevation="0dp"
		app:liftOnScroll="false">

		<com.google.android.material.appbar.MaterialToolbar
			android:id="@id/toolbar"
			android:layout_width="match_parent"
			android:layout_height="wrap_content" />

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

	<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
		android:id="@+id/swipeRefreshLayout"
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">

		<androidx.core.widget.NestedScrollView
			android:id="@+id/scrollView"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:clipToPadding="false"
			android:scrollIndicators="top"
			android:scrollbars="vertical">

			<androidx.constraintlayout.widget.ConstraintLayout
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:paddingBottom="@dimen/margin_normal">

				<com.google.android.material.imageview.ShapeableImageView
					android:id="@+id/imageView_cover"
					android:layout_width="0dp"
					android:layout_height="0dp"
					android:layout_marginStart="16dp"
					android:layout_marginTop="16dp"
					android:background="?colorSecondaryContainer"
					android:clipToOutline="true"
					android:foreground="?selectableItemBackground"
					android:scaleType="centerCrop"
					app:layout_constraintDimensionRatio="H,13:18"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintHorizontal_bias="0"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toTopOf="parent"
					app:layout_constraintWidth_percent="0.3"
					app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Kotatsu.Cover"
					tools:background="@tools:sample/backgrounds/scenic[5]"
					tools:ignore="ContentDescription,UnusedAttribute" />

				<TextView
					android:id="@+id/textView_nsfw"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_margin="@dimen/card_indicator_offset"
					android:background="@drawable/bg_chip"
					android:backgroundTint="@color/warning"
					android:gravity="center"
					android:paddingHorizontal="4dp"
					android:paddingVertical="2dp"
					android:text="@string/nsfw"
					android:textAlignment="center"
					android:textAppearance="?textAppearanceLabelMedium"
					android:textColor="?colorOnError"
					app:layout_constraintBottom_toBottomOf="@id/imageView_cover"
					app:layout_constraintEnd_toEndOf="@id/imageView_cover" />

				<org.koitharu.kotatsu.core.ui.widgets.SelectableTextView
					android:id="@+id/textView_title"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="16dp"
					android:layout_marginTop="16dp"
					android:layout_marginEnd="16dp"
					android:ellipsize="end"
					android:maxLines="@integer/details_title_lines"
					android:textAppearance="?attr/textAppearanceHeadlineSmall"
					android:textIsSelectable="true"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintStart_toEndOf="@id/imageView_cover"
					app:layout_constraintTop_toTopOf="parent"
					tools:text="@tools:sample/lorem" />

				<org.koitharu.kotatsu.core.ui.widgets.SelectableTextView
					android:id="@+id/textView_subtitle"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="16dp"
					android:layout_marginTop="4dp"
					android:layout_marginEnd="16dp"
					android:ellipsize="end"
					android:maxLines="3"
					android:textAppearance="?attr/textAppearanceBodyMedium"
					android:textIsSelectable="true"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintStart_toEndOf="@id/imageView_cover"
					app:layout_constraintTop_toBottomOf="@id/textView_title"
					tools:text="@tools:sample/lorem[12]" />

				<com.google.android.material.chip.Chip
					android:id="@+id/chip_favorite"
					style="@style/Widget.Kotatsu.Chip.Dropdown"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginStart="16dp"
					android:layout_marginTop="8dp"
					app:chipIcon="@drawable/ic_heart_outline"
					app:layout_constraintStart_toEndOf="@id/imageView_cover"
					app:layout_constraintTop_toBottomOf="@id/textView_subtitle"
					tools:text="@string/add_to_favourites" />

				<androidx.constraintlayout.widget.Barrier
					android:id="@+id/barrier_header"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					app:barrierDirection="bottom"
					app:barrierMargin="@dimen/margin_normal"
					app:constraint_referenced_ids="imageView_cover,chip_favorite" />

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

				<TextView
					android:id="@+id/textView_description_title"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="@dimen/margin_small"
					android:layout_marginTop="@dimen/margin_normal"
					android:layout_weight="1"
					android:gravity="center_vertical|start"
					android:padding="@dimen/grid_spacing"
					android:singleLine="true"
					android:text="@string/description"
					android:textAppearance="?textAppearanceTitleSmall"
					app:layout_constraintEnd_toStartOf="@id/button_description_more"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@id/textView_progress_label" />

				<Button
					android:id="@+id/button_description_more"
					style="@style/Widget.Kotatsu.Button.More"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginEnd="8dp"
					android:text="@string/more"
					app:layout_constraintBaseline_toBaselineOf="@id/textView_description_title"
					app:layout_constraintEnd_toEndOf="parent" />

				<org.koitharu.kotatsu.core.ui.widgets.SelectableTextView
					android:id="@+id/textView_description"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="@dimen/margin_normal"
					android:layout_marginTop="@dimen/margin_small"
					android:layout_marginEnd="@dimen/margin_normal"
					android:ellipsize="end"
					android:lineSpacingMultiplier="1.2"
					android:maxLines="@integer/details_description_lines"
					android:textAppearance="?attr/textAppearanceBodyMedium"
					android:textIsSelectable="true"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@id/textView_description_title"
					tools:ignore="UnusedAttribute"
					tools:text="@tools:sample/lorem/random" />

				<org.koitharu.kotatsu.core.ui.widgets.ChipsView
					android:id="@+id/chips_tags"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginHorizontal="@dimen/screen_padding"
					android:layout_marginTop="@dimen/margin_normal"
					app:chipSpacingHorizontal="6dp"
					app:chipSpacingVertical="6dp"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@+id/textView_description" />

				<TextView
					android:id="@+id/textView_scrobbling_title"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="@dimen/margin_small"
					android:layout_marginTop="@dimen/margin_normal"
					android:layout_weight="1"
					android:gravity="center_vertical|start"
					android:padding="@dimen/grid_spacing"
					android:singleLine="true"
					android:text="@string/tracking"
					android:textAppearance="?textAppearanceTitleSmall"
					app:layout_constraintEnd_toStartOf="@id/button_scrobbling_more"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@id/chips_tags" />

				<Button
					android:id="@+id/button_scrobbling_more"
					style="@style/Widget.Kotatsu.Button.More"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginEnd="8dp"
					android:text="@string/manage"
					app:layout_constraintBaseline_toBaselineOf="@id/textView_scrobbling_title"
					app:layout_constraintEnd_toEndOf="parent" />

				<androidx.recyclerview.widget.RecyclerView
					android:id="@+id/recyclerView_scrobbling"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="16dp"
					android:layout_marginEnd="16dp"
					android:layout_marginBottom="12dp"
					android:nestedScrollingEnabled="false"
					android:orientation="vertical"
					android:overScrollMode="never"
					android:scrollbars="none"
					android:visibility="gone"
					app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@id/textView_scrobbling_title"
					tools:itemCount="2"
					tools:listitem="@layout/item_scrobbling_info"
					tools:visibility="visible" />

				<androidx.constraintlayout.widget.Group
					android:id="@+id/group_scrobbling"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:visibility="gone"
					app:constraint_referenced_ids="recyclerView_scrobbling,textView_scrobbling_title,button_scrobbling_more"
					tools:visibility="visible" />

				<TextView
					android:id="@+id/textView_related_title"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginStart="@dimen/margin_small"
					android:layout_marginTop="@dimen/margin_small"
					android:layout_weight="1"
					android:gravity="center_vertical|start"
					android:padding="@dimen/grid_spacing"
					android:singleLine="true"
					android:text="@string/related_manga"
					android:textAppearance="?textAppearanceTitleSmall"
					app:layout_constraintEnd_toStartOf="@id/button_related_more"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@id/recyclerView_scrobbling" />

				<Button
					android:id="@+id/button_related_more"
					style="@style/Widget.Kotatsu.Button.More"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:layout_marginEnd="8dp"
					android:text="@string/show_all"
					android:visibility="gone"
					app:layout_constraintBaseline_toBaselineOf="@id/textView_related_title"
					app:layout_constraintEnd_toEndOf="parent" />

				<androidx.recyclerview.widget.RecyclerView
					android:id="@+id/recyclerView_related"
					android:layout_width="0dp"
					android:layout_height="wrap_content"
					android:layout_marginBottom="6dp"
					android:clipToPadding="false"
					android:nestedScrollingEnabled="false"
					android:orientation="horizontal"
					android:paddingStart="12dp"
					android:paddingEnd="12dp"
					app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
					app:layout_constraintEnd_toEndOf="parent"
					app:layout_constraintStart_toStartOf="parent"
					app:layout_constraintTop_toBottomOf="@id/textView_related_title"
					tools:listitem="@layout/item_manga_grid" />

				<androidx.constraintlayout.widget.Group
					android:id="@+id/group_related"
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:visibility="gone"
					app:constraint_referenced_ids="recyclerView_related,textView_related_title,button_related_more"
					tools:visibility="visible" />

			</androidx.constraintlayout.widget.ConstraintLayout>

		</androidx.core.widget.NestedScrollView>
	</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

	<androidx.fragment.app.FragmentContainerView
		android:id="@+id/container_bottom_sheet"
		android:name="org.koitharu.kotatsu.details.ui.pager.ChaptersPagesSheet"
		style="@style/Widget.Material3.BottomSheet"
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:elevation="6dp"
		android:nestedScrollingEnabled="false"
		android:outlineProvider="background"
		app:behavior_fitToContents="false"
		app:behavior_hideable="false"
		app:behavior_peekHeight="@dimen/details_bs_peek_height"
		app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
		app:paddingBottomSystemWindowInsets="false"
		tools:layout="@layout/sheet_chapters_pages" />

	<View
		android:id="@+id/navbarDim"
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_gravity="bottom"
		android:background="?colorSurfaceContainerLow"
		android:elevation="9dp"
		tools:layout_height="10dp" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
