mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 05:27:28 +01:00
Enable confirmButton only when needed to respond to user input (#8848)
* Enable `confirmButton` when appropriate * Show error in dialog instead * Follow M3 guidelines
This commit is contained in:
@@ -52,13 +52,15 @@ class CategoryScreen : Screen {
|
||||
CategoryDialog.Create -> {
|
||||
CategoryCreateDialog(
|
||||
onDismissRequest = screenModel::dismissDialog,
|
||||
onCreate = { screenModel.createCategory(it) },
|
||||
onCreate = screenModel::createCategory,
|
||||
categories = successState.categories,
|
||||
)
|
||||
}
|
||||
is CategoryDialog.Rename -> {
|
||||
CategoryRenameDialog(
|
||||
onDismissRequest = screenModel::dismissDialog,
|
||||
onRename = { screenModel.renameCategory(dialog.category, it) },
|
||||
categories = successState.categories,
|
||||
category = dialog.category,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ class CategoryScreenModel(
|
||||
coroutineScope.launch {
|
||||
when (createCategoryWithName.await(name)) {
|
||||
is CreateCategoryWithName.Result.InternalError -> _events.send(CategoryEvent.InternalError)
|
||||
CreateCategoryWithName.Result.NameAlreadyExistsError -> _events.send(CategoryEvent.CategoryWithNameAlreadyExists)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +83,6 @@ class CategoryScreenModel(
|
||||
coroutineScope.launch {
|
||||
when (renameCategory.await(category, name)) {
|
||||
is RenameCategory.Result.InternalError -> _events.send(CategoryEvent.InternalError)
|
||||
RenameCategory.Result.NameAlreadyExistsError -> _events.send(CategoryEvent.CategoryWithNameAlreadyExists)
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +115,6 @@ sealed class CategoryDialog {
|
||||
|
||||
sealed class CategoryEvent {
|
||||
sealed class LocalizedMessage(@StringRes val stringRes: Int) : CategoryEvent()
|
||||
object CategoryWithNameAlreadyExists : LocalizedMessage(R.string.error_category_exists)
|
||||
object InternalError : LocalizedMessage(R.string.internal_error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user