mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-09-10 06:45:59 +00:00
Refactor EmptyStateComposable to remove modifier from EmptyStateSpec and fix modifier usage ...
This commit is contained in:
@@ -3,7 +3,6 @@ package org.schabi.newpipe.ui.emptystate
|
|||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@@ -24,9 +23,9 @@ fun EmptyStateComposable(
|
|||||||
spec: EmptyStateSpec,
|
spec: EmptyStateSpec,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) = EmptyStateComposable(
|
) = EmptyStateComposable(
|
||||||
modifier = spec.modifier(modifier),
|
|
||||||
emojiText = spec.emojiText(),
|
emojiText = spec.emojiText(),
|
||||||
descriptionText = spec.descriptionText(),
|
descriptionText = spec.descriptionText(),
|
||||||
|
modifier = modifier
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -61,7 +60,12 @@ private fun EmptyStateComposable(
|
|||||||
@Composable
|
@Composable
|
||||||
fun EmptyStateComposableGenericErrorPreview() {
|
fun EmptyStateComposableGenericErrorPreview() {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
EmptyStateComposable(EmptyStateSpec.GenericError)
|
EmptyStateComposable(
|
||||||
|
spec = EmptyStateSpec.GenericError,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(min = 128.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +73,16 @@ fun EmptyStateComposableGenericErrorPreview() {
|
|||||||
@Composable
|
@Composable
|
||||||
fun EmptyStateComposableNoCommentPreview() {
|
fun EmptyStateComposableNoCommentPreview() {
|
||||||
AppTheme {
|
AppTheme {
|
||||||
EmptyStateComposable(EmptyStateSpec.NoComments)
|
EmptyStateComposable(
|
||||||
|
spec = EmptyStateSpec.NoComments,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(min = 128.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class EmptyStateSpec(
|
data class EmptyStateSpec(
|
||||||
val modifier: (Modifier) -> Modifier,
|
|
||||||
val emojiText: @Composable () -> String,
|
val emojiText: @Composable () -> String,
|
||||||
val descriptionText: @Composable () -> String,
|
val descriptionText: @Composable () -> String,
|
||||||
) {
|
) {
|
||||||
@@ -82,33 +90,21 @@ data class EmptyStateSpec(
|
|||||||
|
|
||||||
val GenericError =
|
val GenericError =
|
||||||
EmptyStateSpec(
|
EmptyStateSpec(
|
||||||
modifier = {
|
|
||||||
it
|
|
||||||
.fillMaxWidth()
|
|
||||||
.heightIn(min = 128.dp)
|
|
||||||
},
|
|
||||||
emojiText = { "¯\\_(ツ)_/¯" },
|
emojiText = { "¯\\_(ツ)_/¯" },
|
||||||
descriptionText = { stringResource(id = R.string.empty_list_subtitle) },
|
descriptionText = { stringResource(id = R.string.empty_list_subtitle) },
|
||||||
)
|
)
|
||||||
|
|
||||||
val NoVideos =
|
val NoVideos =
|
||||||
EmptyStateSpec(
|
EmptyStateSpec(
|
||||||
modifier = {
|
|
||||||
it
|
|
||||||
.fillMaxWidth()
|
|
||||||
.heightIn(min = 128.dp)
|
|
||||||
},
|
|
||||||
emojiText = { "(╯°-°)╯" },
|
emojiText = { "(╯°-°)╯" },
|
||||||
descriptionText = { stringResource(id = R.string.no_videos) },
|
descriptionText = { stringResource(id = R.string.no_videos) },
|
||||||
)
|
)
|
||||||
|
|
||||||
val NoComments =
|
val NoComments =
|
||||||
EmptyStateSpec(
|
EmptyStateSpec(
|
||||||
modifier = {
|
|
||||||
it
|
|
||||||
.fillMaxWidth()
|
|
||||||
.heightIn(min = 128.dp)
|
|
||||||
},
|
|
||||||
emojiText = { "¯\\_(╹x╹)_/¯" },
|
emojiText = { "¯\\_(╹x╹)_/¯" },
|
||||||
descriptionText = { stringResource(id = R.string.no_comments) },
|
descriptionText = { stringResource(id = R.string.no_comments) },
|
||||||
)
|
)
|
||||||
@@ -120,33 +116,27 @@ data class EmptyStateSpec(
|
|||||||
|
|
||||||
val NoSearchResult =
|
val NoSearchResult =
|
||||||
NoComments.copy(
|
NoComments.copy(
|
||||||
modifier = { it },
|
|
||||||
emojiText = { "╰(°●°╰)" },
|
emojiText = { "╰(°●°╰)" },
|
||||||
descriptionText = { stringResource(id = R.string.search_no_results) }
|
descriptionText = { stringResource(id = R.string.search_no_results) }
|
||||||
)
|
)
|
||||||
|
|
||||||
val NoSearchMaxSizeResult =
|
val NoSearchMaxSizeResult =
|
||||||
NoSearchResult.copy(
|
NoSearchResult
|
||||||
modifier = { it.fillMaxSize() },
|
|
||||||
)
|
|
||||||
|
|
||||||
val ContentNotSupported =
|
val ContentNotSupported =
|
||||||
NoComments.copy(
|
NoComments.copy(
|
||||||
modifier = { it.padding(top = 90.dp) },
|
|
||||||
emojiText = { "(︶︹︺)" },
|
emojiText = { "(︶︹︺)" },
|
||||||
descriptionText = { stringResource(id = R.string.content_not_supported) },
|
descriptionText = { stringResource(id = R.string.content_not_supported) },
|
||||||
)
|
)
|
||||||
|
|
||||||
val NoBookmarkedPlaylist =
|
val NoBookmarkedPlaylist =
|
||||||
EmptyStateSpec(
|
EmptyStateSpec(
|
||||||
modifier = { it },
|
|
||||||
emojiText = { "(╥﹏╥)" },
|
emojiText = { "(╥﹏╥)" },
|
||||||
descriptionText = { stringResource(id = R.string.no_playlist_bookmarked_yet) },
|
descriptionText = { stringResource(id = R.string.no_playlist_bookmarked_yet) },
|
||||||
)
|
)
|
||||||
|
|
||||||
val NoSubscriptionsHint =
|
val NoSubscriptionsHint =
|
||||||
EmptyStateSpec(
|
EmptyStateSpec(
|
||||||
modifier = { it },
|
|
||||||
emojiText = { "(꩜ᯅ꩜)" },
|
emojiText = { "(꩜ᯅ꩜)" },
|
||||||
descriptionText = { stringResource(id = R.string.import_subscriptions_hint) },
|
descriptionText = { stringResource(id = R.string.import_subscriptions_hint) },
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user