diff --git a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/modal/ModalRenderer.kt b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/modal/ModalRenderer.kt index 80f90cb3..de5d1972 100644 --- a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/modal/ModalRenderer.kt +++ b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/modal/ModalRenderer.kt @@ -171,7 +171,7 @@ fun ModalRenderer( ) } - Modal.DeleteConfirm -> DecisionInteractiveDialog( + Modal.DeleteImageConfirm -> DecisionInteractiveDialog( title = R.string.interaction_delete_generation_title.asUiText(), text = R.string.interaction_delete_generation_sub_title.asUiText(), confirmActionResId = R.string.yes, @@ -211,5 +211,17 @@ fun ModalRenderer( ) { LanguageBottomSheet(onDismissRequest = dismiss) } + + is Modal.DeleteLocalModelConfirm -> DecisionInteractiveDialog( + title = R.string.interaction_delete_local_model_title.asUiText(), + text = UiText.Resource( + R.string.interaction_delete_local_model_sub_title, + screenModal.model.name, + ), + confirmActionResId = R.string.yes, + dismissActionResId = R.string.no, + onConfirmAction = { processIntent(ServerSetupIntent.LocalModel.DeleteConfirm(screenModal.model)) }, + onDismissRequest = dismiss, + ) } } diff --git a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/model/Modal.kt b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/model/Modal.kt index ed3b6809..98e3cbbb 100644 --- a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/model/Modal.kt +++ b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/model/Modal.kt @@ -5,6 +5,7 @@ import com.shifthackz.aisdv1.core.model.UiText import com.shifthackz.aisdv1.domain.entity.AiGenerationResult import com.shifthackz.aisdv1.domain.entity.HordeProcessStatus import com.shifthackz.aisdv1.domain.feature.diffusion.LocalDiffusion +import com.shifthackz.aisdv1.presentation.screen.setup.ServerSetupState sealed interface Modal { @@ -14,7 +15,7 @@ sealed interface Modal { data object ClearAppCache : Modal - data object DeleteConfirm : Modal + data object DeleteImageConfirm : Modal data object ConfirmExport : Modal @@ -74,6 +75,9 @@ sealed interface Modal { } } + @Immutable + data class DeleteLocalModelConfirm(val model: ServerSetupState.LocalModel) : Modal + @Immutable data class Error(val error: UiText) : Modal diff --git a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/gallery/detail/GalleryDetailViewModel.kt b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/gallery/detail/GalleryDetailViewModel.kt index 98da6928..783dd884 100644 --- a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/gallery/detail/GalleryDetailViewModel.kt +++ b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/gallery/detail/GalleryDetailViewModel.kt @@ -1,6 +1,5 @@ package com.shifthackz.aisdv1.presentation.screen.gallery.detail -import com.shifthackz.aisdv1.core.common.log.debugLog import com.shifthackz.aisdv1.core.common.log.errorLog import com.shifthackz.aisdv1.core.common.schedulers.SchedulersProvider import com.shifthackz.aisdv1.core.common.schedulers.subscribeOnMainThread @@ -43,15 +42,12 @@ class GalleryDetailViewModel( } override fun processIntent(intent: GalleryDetailIntent) { - debugLog("INTENT : $intent") when (intent) { is GalleryDetailIntent.CopyToClipboard -> { emitEffect(GalleryDetailEffect.ShareClipBoard(intent.content.toString())) } - GalleryDetailIntent.Delete.Request -> { - setActiveModal(Modal.DeleteConfirm) - } + GalleryDetailIntent.Delete.Request -> setActiveModal(Modal.DeleteImageConfirm) GalleryDetailIntent.Delete.Confirm -> { setActiveModal(Modal.None) diff --git a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupIntent.kt b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupIntent.kt index 2980d8f3..b8c47d84 100644 --- a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupIntent.kt +++ b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupIntent.kt @@ -32,8 +32,6 @@ sealed interface ServerSetupIntent : MviIntent { data class UpdateHordeDefaultApiKey(val value: Boolean) : ServerSetupIntent - data class DownloadCardButtonClick(val model: ServerSetupState.LocalModel) : ServerSetupIntent - data class SelectLocalModel(val model: ServerSetupState.LocalModel) : ServerSetupIntent data class AllowLocalCustomModel(val allow: Boolean) : ServerSetupIntent @@ -77,4 +75,13 @@ sealed interface ServerSetupIntent : MviIntent { get() = linksProvider.openAiInfoUrl } } + + sealed interface LocalModel : ServerSetupIntent { + + val model: ServerSetupState.LocalModel + + data class ClickReduce(override val model: ServerSetupState.LocalModel) : LocalModel + + data class DeleteConfirm(override val model: ServerSetupState.LocalModel) : LocalModel + } } diff --git a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupViewModel.kt b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupViewModel.kt index 82361d71..c3d1794f 100644 --- a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupViewModel.kt +++ b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/ServerSetupViewModel.kt @@ -1,6 +1,5 @@ package com.shifthackz.aisdv1.presentation.screen.setup -import com.shifthackz.aisdv1.core.common.log.debugLog import com.shifthackz.aisdv1.core.common.log.errorLog import com.shifthackz.aisdv1.core.common.schedulers.SchedulersProvider import com.shifthackz.aisdv1.core.common.schedulers.subscribeOnMainThread @@ -94,7 +93,22 @@ class ServerSetupViewModel( ServerSetupIntent.DismissDialog -> setScreenModal(Modal.None) - is ServerSetupIntent.DownloadCardButtonClick -> localModelDownloadClickReducer(intent.model) + is ServerSetupIntent.LocalModel.ClickReduce -> localModelDownloadClickReducer(intent.model) + + is ServerSetupIntent.LocalModel.DeleteConfirm -> updateState { + !deleteModelUseCase(intent.model.id) + .subscribeOnMainThread(schedulersProvider) + .subscribeBy(::errorLog) + it.copy( + screenModal = Modal.None, + localModels = currentState.localModels.withNewState( + intent.model.copy( + downloadState = DownloadState.Unknown, + downloaded = false, + ), + ), + ) + } is ServerSetupIntent.SelectLocalModel -> { if (currentState.localModels.any { it.downloadState is DownloadState.Downloading }) { @@ -319,19 +333,8 @@ class ServerSetupViewModel( } } // User deletes local model - localModel.downloaded -> { - updateState { - it.copy( - localModels = currentState.localModels.withNewState( - localModel.copy( - downloadState = DownloadState.Unknown, - downloaded = false, - ), - ), - ) - } - !deleteModelUseCase(localModel.id).subscribeOnMainThread(schedulersProvider) - .subscribeBy(::errorLog) + localModel.downloaded -> updateState { + it.copy(screenModal = Modal.DeleteLocalModelConfirm(localModel)) } // User requested new download operation else -> { @@ -364,7 +367,6 @@ class ServerSetupViewModel( setScreenModal(Modal.Error(message.asUiText())) }, onNext = { downloadState -> - debugLog("DOWNLOAD STATE : $downloadState") updateState { when (downloadState) { is DownloadState.Complete -> it.copy( diff --git a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/forms/LocalDiffusionForm.kt b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/forms/LocalDiffusionForm.kt index 252121c8..7b7080a3 100644 --- a/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/forms/LocalDiffusionForm.kt +++ b/presentation/src/main/java/com/shifthackz/aisdv1/presentation/screen/setup/forms/LocalDiffusionForm.kt @@ -99,7 +99,7 @@ fun LocalDiffusionForm( if (model.id != LocalAiModel.CUSTOM.id) { Button( modifier = Modifier.padding(end = 8.dp), - onClick = { processIntent(ServerSetupIntent.DownloadCardButtonClick(model)) }, + onClick = { processIntent(ServerSetupIntent.LocalModel.ClickReduce(model)) }, ) { Text( text = stringResource( diff --git a/presentation/src/main/res/values-ru/strings.xml b/presentation/src/main/res/values-ru/strings.xml index bda75e0d..a2042b18 100644 --- a/presentation/src/main/res/values-ru/strings.xml +++ b/presentation/src/main/res/values-ru/strings.xml @@ -194,6 +194,9 @@ Удалить изображение Вы уверены, что хотите окончательно удалить это изображение? + Удалить модель + Вы уверены, что хотите удалить модель "%1$s"? + Здесь еще ничего нет… Попытайтесь создать что-то, и вы увидите свое изображение здесь! diff --git a/presentation/src/main/res/values-tr/strings.xml b/presentation/src/main/res/values-tr/strings.xml index 66cd2ba1..2e018283 100644 --- a/presentation/src/main/res/values-tr/strings.xml +++ b/presentation/src/main/res/values-tr/strings.xml @@ -194,6 +194,9 @@ Resmi sil Kalıcı olarak bu resmi silmek istediğinize emin misiniz? + Modeli sil + Modeli silmek istediğinizden emin misiniz "%1$s"? + Burada henüz bir şey yok… Bir şeyler üretmeyi deneyin! Ürettiğiniz resimler burada gözükecektir. diff --git a/presentation/src/main/res/values-uk/strings.xml b/presentation/src/main/res/values-uk/strings.xml index f7dbee45..db0122ed 100644 --- a/presentation/src/main/res/values-uk/strings.xml +++ b/presentation/src/main/res/values-uk/strings.xml @@ -194,6 +194,9 @@ Видалити зображення Ви впевнені, що хочете остаточно видалити це зображення? + Видалити модель + Ви впевнені, що хочете видалити модель "%1$s"? + Тут ще нічого немає… Спробуйте створити щось, і ви побачите своє зображення тут! diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index fcc234e4..23093f7e 100755 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -210,7 +210,10 @@ This will reset app settings and delete all the generated images. Do you want to proceed? Delete image - Are you sure you want to permanently remove this image? + Are you sure you want to permanently delete this image? + + Delete model + Are you sure you want to delete model "%1$s"? There is nothing here yet… Try to generate something, and you will see your image here!