diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/AnimeExtensionReposScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/AnimeExtensionReposScreen.kt index b1f25111a..163e17b97 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/AnimeExtensionReposScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/AnimeExtensionReposScreen.kt @@ -8,6 +8,7 @@ import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoConfirmDialog import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoConflictDialog import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoCreateDialog import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoDeleteDialog @@ -32,7 +33,7 @@ class AnimeExtensionReposScreen( val state by screenModel.state.collectAsState() LaunchedEffect(url) { - url?.let { screenModel.createRepo(it) } + url?.let { screenModel.showDialog(RepoDialog.Confirm(it)) } } if (state is RepoScreenState.Loading) { @@ -67,7 +68,6 @@ class AnimeExtensionReposScreen( repo = dialog.repo, ) } - is RepoDialog.Conflict -> { ExtensionRepoConflictDialog( onDismissRequest = screenModel::dismissDialog, @@ -76,6 +76,13 @@ class AnimeExtensionReposScreen( newRepo = dialog.newRepo, ) } + is RepoDialog.Confirm -> { + ExtensionRepoConfirmDialog( + onDismissRequest = screenModel::dismissDialog, + onCreate = { screenModel.createRepo(dialog.url) }, + repo = dialog.url, + ) + } } LaunchedEffect(Unit) { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreen.kt index eed2fed71..ce4bfc2ba 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreen.kt @@ -8,6 +8,7 @@ import androidx.compose.ui.platform.LocalContext import cafe.adriel.voyager.core.model.rememberScreenModel import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow +import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoConfirmDialog import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoConflictDialog import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoCreateDialog import eu.kanade.presentation.more.settings.screen.browse.components.ExtensionRepoDeleteDialog @@ -32,7 +33,7 @@ class MangaExtensionReposScreen( val state by screenModel.state.collectAsState() LaunchedEffect(url) { - url?.let { screenModel.createRepo(it) } + url?.let { screenModel.showDialog(RepoDialog.Confirm(it)) } } if (state is RepoScreenState.Loading) { @@ -67,7 +68,6 @@ class MangaExtensionReposScreen( repo = dialog.repo, ) } - is RepoDialog.Conflict -> { ExtensionRepoConflictDialog( onDismissRequest = screenModel::dismissDialog, @@ -76,6 +76,13 @@ class MangaExtensionReposScreen( newRepo = dialog.newRepo, ) } + is RepoDialog.Confirm -> { + ExtensionRepoConfirmDialog( + onDismissRequest = screenModel::dismissDialog, + onCreate = { screenModel.createRepo(dialog.url) }, + repo = dialog.url, + ) + } } LaunchedEffect(Unit) { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreenModel.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreenModel.kt index c8dee1ff7..e7ab8dd35 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreenModel.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/MangaExtensionReposScreenModel.kt @@ -125,6 +125,7 @@ sealed class RepoDialog { data object Create : RepoDialog() data class Delete(val repo: String) : RepoDialog() data class Conflict(val oldRepo: ExtensionRepo, val newRepo: ExtensionRepo) : RepoDialog() + data class Confirm(val url: String) : RepoDialog() } sealed class RepoScreenState { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt index 239f917d0..80cada76b 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt @@ -152,3 +152,35 @@ fun ExtensionRepoConflictDialog( }, ) } + +@Composable +fun ExtensionRepoConfirmDialog( + onDismissRequest: () -> Unit, + onCreate: () -> Unit, + repo: String, +) { + AlertDialog( + onDismissRequest = onDismissRequest, + title = { + Text(text = stringResource(MR.strings.action_add_repo)) + }, + text = { + Text(text = stringResource(MR.strings.add_repo_confirmation, repo)) + }, + confirmButton = { + TextButton( + onClick = { + onCreate() + onDismissRequest() + }, + ) { + Text(text = stringResource(MR.strings.action_add)) + } + }, + dismissButton = { + TextButton(onClick = onDismissRequest) { + Text(text = stringResource(MR.strings.action_cancel)) + } + }, + ) +} diff --git a/i18n/src/commonMain/moko-resources/base/strings.xml b/i18n/src/commonMain/moko-resources/base/strings.xml index 84741d0e3..a019609c3 100644 --- a/i18n/src/commonMain/moko-resources/base/strings.xml +++ b/i18n/src/commonMain/moko-resources/base/strings.xml @@ -312,6 +312,7 @@ Delete repo Invalid repo URL Do you wish to delete the repo \"%s\"? + Do you wish to add the repo \"%s\"? Open source repo Replace Signing Key Fingerprint Already Exists