limit the max height of the comments sheet

This commit is contained in:
Bnyro 2022-12-16 15:01:06 +01:00
parent 03973bcc14
commit ea72e777c1
2 changed files with 9 additions and 1 deletions

View File

@ -327,7 +327,12 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
} }
binding.commentsToggle.setOnClickListener { binding.commentsToggle.setOnClickListener {
CommentsSheet(videoId!!, comments, commentsNextPage) { comments, nextPage -> CommentsSheet(
videoId!!,
comments,
commentsNextPage,
binding.root.height - binding.player.height
) { comments, nextPage ->
this.comments.addAll(comments) this.comments.addAll(comments)
this.commentsNextPage = nextPage this.commentsNextPage = nextPage
}.show(childFragmentManager) }.show(childFragmentManager)

View File

@ -20,6 +20,7 @@ class CommentsSheet(
private val videoId: String, private val videoId: String,
private val comments: List<Comment>, private val comments: List<Comment>,
private var nextPage: String?, private var nextPage: String?,
private val maxHeight: Int,
private val onMoreComments: (comments: List<Comment>, nextPage: String?) -> Unit private val onMoreComments: (comments: List<Comment>, nextPage: String?) -> Unit
) : ExpandedBottomSheet() { ) : ExpandedBottomSheet() {
private lateinit var binding: CommentsSheetBinding private lateinit var binding: CommentsSheetBinding
@ -29,6 +30,8 @@ class CommentsSheet(
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = CommentsSheetBinding.inflate(layoutInflater) binding = CommentsSheetBinding.inflate(layoutInflater)
// set a fixed maximum height
binding.root.maxHeight = maxHeight
return binding.root return binding.root
} }