mirror of https://github.com/readrops/Readrops.git
Improve dialog for folder and feed deletion in FeedTab
This commit is contained in:
parent
6f01333065
commit
f0ac2de8e4
|
@ -34,10 +34,10 @@ import cafe.adriel.voyager.navigator.tab.TabOptions
|
||||||
import com.readrops.app.compose.R
|
import com.readrops.app.compose.R
|
||||||
import com.readrops.app.compose.feeds.dialogs.AddFeedDialog
|
import com.readrops.app.compose.feeds.dialogs.AddFeedDialog
|
||||||
import com.readrops.app.compose.feeds.dialogs.AddUpdateFolderDialog
|
import com.readrops.app.compose.feeds.dialogs.AddUpdateFolderDialog
|
||||||
import com.readrops.app.compose.feeds.dialogs.DeleteFeedDialog
|
|
||||||
import com.readrops.app.compose.feeds.dialogs.FeedModalBottomSheet
|
import com.readrops.app.compose.feeds.dialogs.FeedModalBottomSheet
|
||||||
import com.readrops.app.compose.feeds.dialogs.UpdateFeedDialog
|
import com.readrops.app.compose.feeds.dialogs.UpdateFeedDialog
|
||||||
import com.readrops.app.compose.util.components.Placeholder
|
import com.readrops.app.compose.util.components.Placeholder
|
||||||
|
import com.readrops.app.compose.util.components.TwoChoicesDialog
|
||||||
import com.readrops.app.compose.util.theme.spacing
|
import com.readrops.app.compose.util.theme.spacing
|
||||||
import com.readrops.db.entities.Feed
|
import com.readrops.db.entities.Feed
|
||||||
import org.koin.androidx.compose.getViewModel
|
import org.koin.androidx.compose.getViewModel
|
||||||
|
@ -72,10 +72,14 @@ object FeedTab : Tab {
|
||||||
}
|
}
|
||||||
|
|
||||||
is DialogState.DeleteFeed -> {
|
is DialogState.DeleteFeed -> {
|
||||||
DeleteFeedDialog(
|
TwoChoicesDialog(
|
||||||
feed = dialog.feed,
|
title = "Delete feed",
|
||||||
|
text = "Do you want to delete feed ${dialog.feed.name}?",
|
||||||
|
icon = rememberVectorPainter(image = Icons.Default.Delete),
|
||||||
|
confirmText = "Delete",
|
||||||
|
dismissText = "Cancel",
|
||||||
onDismiss = { viewModel.closeDialog() },
|
onDismiss = { viewModel.closeDialog() },
|
||||||
onDelete = {
|
onConfirm = {
|
||||||
viewModel.deleteFeed(dialog.feed)
|
viewModel.deleteFeed(dialog.feed)
|
||||||
viewModel.closeDialog()
|
viewModel.closeDialog()
|
||||||
}
|
}
|
||||||
|
@ -139,7 +143,7 @@ object FeedTab : Tab {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is DialogState.DeleteFolder -> {}
|
is DialogState.UpdateFolder -> {
|
||||||
AddUpdateFolderDialog(
|
AddUpdateFolderDialog(
|
||||||
updateFolder = true,
|
updateFolder = true,
|
||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
package com.readrops.app.compose.feeds.dialogs
|
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.Delete
|
|
||||||
import androidx.compose.material3.AlertDialog
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.TextButton
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import com.readrops.db.entities.Feed
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun DeleteFeedDialog(
|
|
||||||
feed: Feed,
|
|
||||||
onDismiss: () -> Unit,
|
|
||||||
onDelete: () -> Unit,
|
|
||||||
) {
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = onDismiss,
|
|
||||||
icon = {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Delete,
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
title = {
|
|
||||||
Text(text = "Delete feed")
|
|
||||||
},
|
|
||||||
text = {
|
|
||||||
Text(text = "Do you want to delete feed ${feed.name}?")
|
|
||||||
},
|
|
||||||
confirmButton = {
|
|
||||||
TextButton(onClick = onDelete) {
|
|
||||||
Text(text = "Delete")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dismissButton = {
|
|
||||||
TextButton(
|
|
||||||
onClick = onDismiss
|
|
||||||
) {
|
|
||||||
Text(text = "Cancel")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.readrops.app.compose.util.components
|
||||||
|
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TwoChoicesDialog(
|
||||||
|
title: String,
|
||||||
|
text: String,
|
||||||
|
icon: Painter,
|
||||||
|
confirmText: String,
|
||||||
|
dismissText: String,
|
||||||
|
onDismiss: () -> Unit,
|
||||||
|
onConfirm: () -> Unit,
|
||||||
|
) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
icon = {
|
||||||
|
Icon(
|
||||||
|
painter = icon,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
title = { Text(text = title) },
|
||||||
|
text = { Text(text = text) },
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = onConfirm) {
|
||||||
|
Text(text = confirmText)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = onDismiss
|
||||||
|
) {
|
||||||
|
Text(text = dismissText)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue