History Screen clear all dialog
This commit is contained in:
1 parent
61c75c06a9
commit
ef4e0d76ec
2 files changed
+49
-3
No files matched your search
@@ -6,6 +6,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.core.view.GravityCompat
|
||||
import com.google.accompanist.themeadapter.material3.Mdc3Theme
|
||||
import com.hippo.ehviewer.ui.scene.history.HistoryScreen
|
||||
|
||||
class HistoryComposeScreenFragmentBridge : BaseScene() {
|
||||
@@ -16,8 +17,10 @@ class HistoryComposeScreenFragmentBridge : BaseScene() {
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
HistoryScreen {
|
||||
toggleDrawer(GravityCompat.START)
|
||||
Mdc3Theme {
|
||||
HistoryScreen {
|
||||
toggleDrawer(GravityCompat.START)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,22 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@@ -30,6 +36,7 @@ import androidx.paging.compose.collectAsLazyPagingItems
|
||||
import androidx.paging.compose.items
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.R
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -42,6 +49,9 @@ fun HistoryScreen(toggleDrawer: () -> Unit) {
|
||||
EhDB.getHistoryLazyList()
|
||||
}.flow.cachedIn(coroutineScope)
|
||||
}.collectAsLazyPagingItems()
|
||||
|
||||
var clearAllDialog by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
@@ -54,7 +64,7 @@ fun HistoryScreen(toggleDrawer: () -> Unit) {
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = { /*TODO*/ }) {
|
||||
IconButton(onClick = { clearAllDialog = true }) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.v_clear_all_dark_x24),
|
||||
contentDescription = ""
|
||||
@@ -81,6 +91,39 @@ fun HistoryScreen(toggleDrawer: () -> Unit) {
|
||||
NoHistory()
|
||||
}
|
||||
}
|
||||
|
||||
if (clearAllDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { clearAllDialog = false },
|
||||
title = {
|
||||
Text(text = stringResource(id = R.string.clear_all))
|
||||
},
|
||||
text = {
|
||||
Text(text = stringResource(id = R.string.clear_all_history))
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
coroutineScope.launchIO {
|
||||
EhDB.clearHistoryInfo()
|
||||
clearAllDialog = false
|
||||
}
|
||||
}
|
||||
) {
|
||||
Text(stringResource(id = R.string.clear_all))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
clearAllDialog = false
|
||||
}
|
||||
) {
|
||||
Text(stringResource(id = android.R.string.cancel))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
Reference in new issue
Block a user