Description bottom sheet

This commit is contained in:
Koitharu
2023-07-13 15:08:39 +03:00
parent 2d670418c7
commit 55ca2b8d8d
4 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package org.koitharu.kotatsu.details.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import org.koitharu.kotatsu.core.ui.sheet.BaseAdaptiveSheet
import org.koitharu.kotatsu.core.util.ext.showDistinct
import org.koitharu.kotatsu.core.util.ext.withArgs
import org.koitharu.kotatsu.databinding.SheetDescriptionBinding
class DescriptionSheet : BaseAdaptiveSheet<SheetDescriptionBinding>() {
override fun onCreateViewBinding(inflater: LayoutInflater, container: ViewGroup?): SheetDescriptionBinding {
return SheetDescriptionBinding.inflate(inflater, container, false)
}
override fun onViewBindingCreated(binding: SheetDescriptionBinding, savedInstanceState: Bundle?) {
super.onViewBindingCreated(binding, savedInstanceState)
binding.textViewDescription.text = arguments?.getCharSequence(ARG_CONTENT)
}
companion object {
private const val ARG_CONTENT = "content"
private const val TAG = "DescriptionSheet"
fun show(fm: FragmentManager, content: CharSequence) = DescriptionSheet().withArgs(1) {
putCharSequence(ARG_CONTENT, content)
}.showDistinct(fm, TAG)
}
}

View File

@@ -191,6 +191,7 @@ class DetailsFragment :
} else {
requireViewBinding().textViewDescription.text = description
}
requireViewBinding().buttonDescriptionMore.isGone = description.isNullOrBlank()
}
private fun onLocalSizeChanged(size: Long) {
@@ -295,6 +296,10 @@ class DetailsFragment :
)
}
R.id.button_description_more -> {
DescriptionSheet.show(parentFragmentManager, viewModel.description.value ?: return)
}
R.id.button_scrobbling_more -> {
ScrobblingSelectorSheet.show(parentFragmentManager, manga, null)
}

View File

@@ -324,6 +324,7 @@
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" />

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical">
<org.koitharu.kotatsu.core.ui.sheet.AdaptiveSheetHeaderBar
android:id="@+id/headerBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/description" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<org.koitharu.kotatsu.core.ui.widgets.SelectableTextView
android:id="@+id/textView_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_normal"
android:layout_marginEnd="@dimen/margin_normal"
android:lineSpacingMultiplier="1.2"
android:paddingBottom="@dimen/margin_normal"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textIsSelectable="true"
tools:text="@tools:sample/lorem/random" />
</androidx.core.widget.NestedScrollView>
</LinearLayout>