Skip to content

Commit

Permalink
Show exactly, which file will be deleted. Fixes #1500
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek committed Sep 20, 2022
1 parent 93319f6 commit a96f150
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package voice.bookOverview.deleteBook
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
Expand Down Expand Up @@ -53,6 +55,10 @@ internal fun DeleteBookDialog(
text = {
Column {
Text(stringResource(id = R.string.delete_book_dialog_content))

Spacer(modifier = Modifier.heightIn(8.dp))
Text(viewState.fileToDelete, style = MaterialTheme.typography.bodyLarge)

Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,22 @@ constructor(

override suspend fun onItemClicked(bookId: BookId, item: BottomSheetItem) {
if (item != BottomSheetItem.DeleteBook) return

_state.value = DeleteBookViewState(
id = bookId,
deleteCheckBoxChecked = false,
fileToDelete = bookId.toUri().pathSegments
.toMutableList()
.also { segments ->
if (segments.firstOrNull() == "document") {
segments.removeFirst()
}
val path = segments.firstOrNull()
if (path != null) {
segments[0] = path.removePrefix("primary:")
}
}
.joinToString(separator = "/"),
)
}

Expand Down Expand Up @@ -71,6 +84,7 @@ constructor(
data class DeleteBookViewState(
val id: BookId,
val deleteCheckBoxChecked: Boolean,
val fileToDelete: String,
) {

val confirmButtonEnabled = deleteCheckBoxChecked
Expand Down

0 comments on commit a96f150

Please sign in to comment.