From e53f0ff94af105e63c2d0a0806aa238768fb1190 Mon Sep 17 00:00:00 2001 From: Su TT Date: Thu, 5 Jun 2025 12:33:21 -0400 Subject: [PATCH] Update EmptyStateComposable usages to include modifiers --- .../ui/components/video/RelatedItems.kt | 8 ++++++- .../video/comment/CommentRepliesDialog.kt | 14 +++++++++-- .../video/comment/CommentSection.kt | 24 +++++++++++++++---- .../newpipe/ui/emptystate/EmptyStateUtil.kt | 10 +++++++- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt index 7267c66b3..c0f2a873b 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt @@ -4,6 +4,7 @@ import android.content.res.Configuration import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.material3.Surface import androidx.compose.material3.Switch @@ -74,7 +75,12 @@ fun RelatedItems(info: StreamInfo) { } if (info.relatedItems.isEmpty()) { item { - EmptyStateComposable(EmptyStateSpec.NoVideos) + EmptyStateComposable( + spec = EmptyStateSpec.NoComments, + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) + ) } } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt index 183651227..bbe4eab4b 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentRepliesDialog.kt @@ -1,6 +1,8 @@ package org.schabi.newpipe.ui.components.video.comment import android.content.res.Configuration +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState @@ -126,14 +128,22 @@ private fun CommentRepliesDialog( } else if (refresh is LoadState.Error) { // TODO use error panel instead EmptyStateComposable( - EmptyStateSpec.DisabledComments.copy( + spec = EmptyStateSpec.DisabledComments.copy( descriptionText = { stringResource(R.string.error_unable_to_load_comments) }, ), + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) ) } else { - EmptyStateComposable(EmptyStateSpec.NoComments) + EmptyStateComposable( + spec = EmptyStateSpec.NoComments, + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) + ) } } } else { diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt index be1efb908..b2c9f6b85 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/comment/CommentSection.kt @@ -1,6 +1,8 @@ package org.schabi.newpipe.ui.components.video.comment import android.content.res.Configuration +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState @@ -68,11 +70,22 @@ private fun CommentSection( if (commentInfo.isCommentsDisabled) { item { - EmptyStateComposable(EmptyStateSpec.DisabledComments) + EmptyStateComposable( + spec = EmptyStateSpec.DisabledComments, + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) + + ) } } else if (count == 0) { item { - EmptyStateComposable(EmptyStateSpec.NoComments) + EmptyStateComposable( + spec = EmptyStateSpec.NoComments, + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) + ) } } else { // do not show anything if the comment count is unknown @@ -121,11 +134,14 @@ private fun CommentSection( item { // TODO use error panel instead EmptyStateComposable( - EmptyStateSpec.DisabledComments.copy( + spec = EmptyStateSpec.DisabledComments.copy( descriptionText = { stringResource(R.string.error_unable_to_load_comments) } - ) + ), + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) ) } } diff --git a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt index 2fced431f..3e030407c 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/emptystate/EmptyStateUtil.kt @@ -2,12 +2,16 @@ package org.schabi.newpipe.ui.emptystate +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.contentColorFor import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.compose.ui.unit.dp import org.schabi.newpipe.ui.theme.AppTheme @JvmOverloads @@ -22,7 +26,11 @@ fun ComposeView.setEmptyStateComposable( LocalContentColor provides contentColorFor(MaterialTheme.colorScheme.background) ) { EmptyStateComposable( - spec = spec + spec = spec, + modifier = Modifier + .fillMaxWidth() + .heightIn(min = 128.dp) + ) } }