1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2026-06-14 08:38:51 +00:00

shared: composable: Ensure library's developers and licenses are available

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2026-06-04 18:44:47 +08:00
parent ae42026e82
commit 8c295a34fb
2 changed files with 18 additions and 5 deletions
@@ -35,4 +35,5 @@
<string name="faq">View on website</string>
<string name="open_in_browser">Open in browser</string>
<string name="done">Done</string>
<string name="not_available">Not available</string>
</resources>
@@ -19,6 +19,7 @@ import net.newpipe.app.preview.LibraryPreviewProvider
import net.newpipe.app.preview.ThemePreviewProvider
import newpipe.shared.generated.resources.Res
import newpipe.shared.generated.resources.license
import newpipe.shared.generated.resources.not_available
import org.jetbrains.compose.resources.stringResource
/**
@@ -29,8 +30,23 @@ import org.jetbrains.compose.resources.stringResource
*/
@Composable
fun LibraryListItem(modifier: Modifier = Modifier, library: Library, onClick: () -> Unit = {}) {
val description = when {
library.developers.isNotEmpty() && library.licenses.isNotEmpty() -> {
stringResource(
Res.string.license,
library.developers.first().name,
library.licenses.first()
)
}
else -> {
stringResource(Res.string.not_available)
}
}
ListItem(
onClick = onClick,
enabled = library.licenses.isNotEmpty(),
content = {
Column {
Text(
@@ -38,11 +54,7 @@ fun LibraryListItem(modifier: Modifier = Modifier, library: Library, onClick: ()
style = MaterialTheme.typography.titleMedium
)
Text(
text = stringResource(
Res.string.license,
library.developers.first().name,
library.licenses.first()
),
text = description,
style = MaterialTheme.typography.bodyMedium
)
}