1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-06-28 16:13:02 +00:00

Update EmptyStateComposable usages to include modifiers

This commit is contained in:
Su TT 2025-06-05 12:33:21 -04:00
parent d4cd54fd7b
commit e53f0ff94a
4 changed files with 48 additions and 8 deletions

View File

@ -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)
)
}
}
}

View File

@ -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 {

View File

@ -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)
)
}
}

View File

@ -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)
)
}
}