repo icon for Komikku & Keiyoushi (#291)
This commit is contained in:
parent
50b837c976
commit
8a7c005d61
6 changed files with 99 additions and 62 deletions
|
|
@ -1,14 +1,16 @@
|
||||||
package eu.kanade.presentation.more.settings.screen.browse.components
|
package eu.kanade.presentation.more.settings.screen.browse.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.Label
|
|
||||||
import androidx.compose.material.icons.automirrored.outlined.OpenInNew
|
import androidx.compose.material.icons.automirrored.outlined.OpenInNew
|
||||||
import androidx.compose.material.icons.outlined.ContentCopy
|
import androidx.compose.material.icons.outlined.ContentCopy
|
||||||
import androidx.compose.material.icons.outlined.Delete
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
|
|
@ -23,9 +25,14 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.ImageBitmap
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.res.imageResource
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import kotlinx.collections.immutable.ImmutableSet
|
import kotlinx.collections.immutable.ImmutableSet
|
||||||
import kotlinx.collections.immutable.persistentSetOf
|
import kotlinx.collections.immutable.persistentSetOf
|
||||||
|
|
@ -89,83 +96,102 @@ private fun ExtensionRepoListItem(
|
||||||
ElevatedCard(
|
ElevatedCard(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
|
// KMK -->
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.padding(start = MaterialTheme.padding.medium),
|
||||||
.padding(
|
|
||||||
start = MaterialTheme.padding.medium,
|
|
||||||
top = MaterialTheme.padding.medium,
|
|
||||||
end = MaterialTheme.padding.medium,
|
|
||||||
),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
) {
|
||||||
Icon(
|
val resId = repoResId(repo.baseUrl)
|
||||||
imageVector = Icons.AutoMirrored.Outlined.Label,
|
Image(
|
||||||
|
bitmap = ImageBitmap.imageResource(id = resId),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
// KMK -->
|
alpha = if (isDisabled) 0.4f else 1f,
|
||||||
tint = LocalContentColor.current.let { if (isDisabled) it.copy(alpha = 0.6f) else it },
|
modifier = Modifier
|
||||||
// KMK <--
|
.size(48.dp)
|
||||||
|
.clip(MaterialTheme.shapes.extraSmall)
|
||||||
|
.align(Alignment.CenterVertically),
|
||||||
)
|
)
|
||||||
Text(
|
Column {
|
||||||
text = repo.name,
|
|
||||||
modifier = Modifier.padding(start = MaterialTheme.padding.medium),
|
|
||||||
style = MaterialTheme.typography.titleMedium,
|
|
||||||
// KMK -->
|
|
||||||
color = LocalContentColor.current.let { if (isDisabled) it.copy(alpha = 0.6f) else it },
|
|
||||||
textDecoration = TextDecoration.LineThrough.takeIf { isDisabled },
|
|
||||||
// KMK <--
|
// KMK <--
|
||||||
)
|
Row(
|
||||||
}
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(
|
||||||
|
start = MaterialTheme.padding.medium,
|
||||||
|
top = MaterialTheme.padding.medium,
|
||||||
|
end = MaterialTheme.padding.medium,
|
||||||
|
),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = repo.name,
|
||||||
|
// KMK: modifier = Modifier.padding(start = MaterialTheme.padding.medium),
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
// KMK -->
|
||||||
|
color = LocalContentColor.current.let { if (isDisabled) it.copy(alpha = 0.6f) else it },
|
||||||
|
textDecoration = TextDecoration.LineThrough.takeIf { isDisabled },
|
||||||
|
// KMK <--
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.End,
|
horizontalArrangement = Arrangement.End,
|
||||||
) {
|
) {
|
||||||
IconButton(onClick = onOpenWebsite) {
|
IconButton(onClick = onOpenWebsite) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.AutoMirrored.Outlined.OpenInNew,
|
imageVector = Icons.AutoMirrored.Outlined.OpenInNew,
|
||||||
contentDescription = stringResource(MR.strings.action_open_in_browser),
|
contentDescription = stringResource(MR.strings.action_open_in_browser),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
val url = "${repo.baseUrl}/index.min.json"
|
val url = "${repo.baseUrl}/index.min.json"
|
||||||
context.copyToClipboard(url, url)
|
context.copyToClipboard(url, url)
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.ContentCopy,
|
imageVector = Icons.Outlined.ContentCopy,
|
||||||
contentDescription = stringResource(MR.strings.action_copy_to_clipboard),
|
contentDescription = stringResource(MR.strings.action_copy_to_clipboard),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
IconButton(onClick = if (isDisabled) onEnable else onDisable) {
|
IconButton(onClick = if (isDisabled) onEnable else onDisable) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = if (isDisabled) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
|
imageVector = if (isDisabled) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
|
||||||
contentDescription = stringResource(MR.strings.action_disable),
|
contentDescription = stringResource(MR.strings.action_disable),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
IconButton(onClick = onDelete) {
|
IconButton(onClick = onDelete) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Delete,
|
imageVector = Icons.Outlined.Delete,
|
||||||
contentDescription = stringResource(MR.strings.action_delete),
|
contentDescription = stringResource(MR.strings.action_delete),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
|
fun repoResId(baseUrl: String) = when (baseUrl) {
|
||||||
|
"https://raw.githubusercontent.com/komikku-app/extensions/repo" -> R.mipmap.komikku
|
||||||
|
"https://raw.githubusercontent.com/keiyoushi/extensions/repo" -> R.mipmap.keiyoushi
|
||||||
|
else -> R.mipmap.extension
|
||||||
|
}
|
||||||
|
|
||||||
@Preview
|
@Preview
|
||||||
@Composable
|
@Composable
|
||||||
fun ExtensionReposContentPreview() {
|
fun ExtensionReposContentPreview() {
|
||||||
val repos = persistentSetOf(
|
val repos = persistentSetOf(
|
||||||
ExtensionRepo("url1", "Repo 1", "", "", "key1"),
|
ExtensionRepo("https://raw.githubusercontent.com/komikku-app/extensions/repo", "Komikku", "", "", "key1"),
|
||||||
ExtensionRepo("url2", "Repo 2", "", "", "key2"),
|
ExtensionRepo("https://raw.githubusercontent.com/keiyoushi/extensions/repo", "Keiyoushi", "", "", "key2"),
|
||||||
|
ExtensionRepo("https://repo", "Other", "", "", "key2"),
|
||||||
)
|
)
|
||||||
ExtensionReposContent(
|
ExtensionReposContent(
|
||||||
repos = repos,
|
repos = repos,
|
||||||
|
|
@ -175,7 +201,7 @@ fun ExtensionReposContentPreview() {
|
||||||
onClickDelete = {},
|
onClickDelete = {},
|
||||||
onClickEnable = {},
|
onClickEnable = {},
|
||||||
onClickDisable = {},
|
onClickDisable = {},
|
||||||
disabledRepos = setOf("url2"),
|
disabledRepos = setOf("https://repo"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ fun ExtensionReposScreen(
|
||||||
EmptyScreen(
|
EmptyScreen(
|
||||||
MR.strings.information_empty_repos,
|
MR.strings.information_empty_repos,
|
||||||
modifier = Modifier.padding(paddingValues),
|
modifier = Modifier.padding(paddingValues),
|
||||||
|
// KMK -->
|
||||||
help = {
|
help = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = { context.openInBrowser(OFFICIAL_REPO_WEBSITE) },
|
onClick = { context.openInBrowser(OFFICIAL_REPO_WEBSITE) },
|
||||||
|
|
@ -86,6 +87,7 @@ fun ExtensionReposScreen(
|
||||||
Text(text = stringResource(MR.strings.label_help))
|
Text(text = stringResource(MR.strings.label_help))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
return@Scaffold
|
return@Scaffold
|
||||||
}
|
}
|
||||||
|
|
@ -112,10 +114,11 @@ fun ExtensionReposScreen(
|
||||||
private fun ExtensionReposScreenPreview() {
|
private fun ExtensionReposScreenPreview() {
|
||||||
val state = RepoScreenState.Success(
|
val state = RepoScreenState.Success(
|
||||||
repos = persistentSetOf(
|
repos = persistentSetOf(
|
||||||
ExtensionRepo("url1", "Repo 1", "", "", "key1"),
|
ExtensionRepo("https://raw.githubusercontent.com/komikku-app/extensions/repo", "Komikku", "", "", "key1"),
|
||||||
ExtensionRepo("url2", "Repo 2", "", "", "key2"),
|
ExtensionRepo("https://raw.githubusercontent.com/keiyoushi/extensions/repo", "Keiyoushi", "", "", "key2"),
|
||||||
|
ExtensionRepo("https://repo", "Other", "", "", "key2"),
|
||||||
),
|
),
|
||||||
disabledRepos = setOf("url2"),
|
disabledRepos = setOf("https://repo"),
|
||||||
)
|
)
|
||||||
ExtensionReposScreen(
|
ExtensionReposScreen(
|
||||||
state = state,
|
state = state,
|
||||||
|
|
|
||||||
BIN
app/src/main/res/mipmap/extension.png
Normal file
BIN
app/src/main/res/mipmap/extension.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
app/src/main/res/mipmap/keiyoushi.jpeg
Normal file
BIN
app/src/main/res/mipmap/keiyoushi.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/mipmap/komikku.png
Normal file
BIN
app/src/main/res/mipmap/komikku.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
|
|
@ -40,13 +40,17 @@ fun EmptyScreen(
|
||||||
stringRes: StringResource,
|
stringRes: StringResource,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
actions: ImmutableList<EmptyScreenAction>? = null,
|
actions: ImmutableList<EmptyScreenAction>? = null,
|
||||||
|
// KMK -->
|
||||||
help: @Composable (() -> Unit)? = null,
|
help: @Composable (() -> Unit)? = null,
|
||||||
|
// KMK <--
|
||||||
) {
|
) {
|
||||||
EmptyScreen(
|
EmptyScreen(
|
||||||
message = stringResource(stringRes),
|
message = stringResource(stringRes),
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
actions = actions,
|
actions = actions,
|
||||||
|
// KMK -->
|
||||||
help = help,
|
help = help,
|
||||||
|
// KMK <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,7 +59,9 @@ fun EmptyScreen(
|
||||||
message: String,
|
message: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
actions: ImmutableList<EmptyScreenAction>? = null,
|
actions: ImmutableList<EmptyScreenAction>? = null,
|
||||||
|
// KMK -->
|
||||||
help: @Composable (() -> Unit)? = null,
|
help: @Composable (() -> Unit)? = null,
|
||||||
|
// KMK <--
|
||||||
) {
|
) {
|
||||||
val face = remember { getRandomErrorFace() }
|
val face = remember { getRandomErrorFace() }
|
||||||
Column(
|
Column(
|
||||||
|
|
@ -83,7 +89,9 @@ fun EmptyScreen(
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
help?.let { help() }
|
help?.let { help() }
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
if (!actions.isNullOrEmpty()) {
|
if (!actions.isNullOrEmpty()) {
|
||||||
Row(
|
Row(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue