|
|
@@ -1,14 +1,26 @@
|
|
|
package io.legado.app.ui.config.readConfig
|
|
|
|
|
|
import android.content.Intent
|
|
|
-import androidx.compose.foundation.layout.*
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
+import androidx.compose.foundation.layout.fillMaxSize
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.padding
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
-import androidx.compose.material.icons.filled.SelectAll
|
|
|
-import androidx.compose.material.icons.filled.Deselect
|
|
|
-import androidx.compose.material3.*
|
|
|
-import androidx.compose.runtime.*
|
|
|
+import androidx.compose.material.icons.filled.Check
|
|
|
+import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
+import androidx.compose.runtime.getValue
|
|
|
+import androidx.compose.runtime.mutableStateOf
|
|
|
+import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.setValue
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
@@ -17,11 +29,11 @@ import androidx.compose.ui.unit.dp
|
|
|
import coil.compose.AsyncImage
|
|
|
import io.legado.app.R
|
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
|
+import io.legado.app.ui.widget.components.AdaptiveSwitch
|
|
|
+import io.legado.app.ui.widget.components.button.series.SmallPlainButton
|
|
|
+import io.legado.app.ui.widget.components.card.NormalCard
|
|
|
import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
|
|
|
import io.legado.app.ui.widget.components.text.AppText
|
|
|
-import io.legado.app.ui.widget.components.card.NormalCard
|
|
|
-import io.legado.app.ui.widget.components.button.ConfirmDismissButtonsRow
|
|
|
-import io.legado.app.ui.widget.components.button.series.SmallTonalButton
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
|
@@ -64,6 +76,15 @@ fun TextSelectMenuFilterSheet(
|
|
|
show = show,
|
|
|
onDismissRequest = onDismissRequest,
|
|
|
title = stringResource(R.string.text_select_menu_filter),
|
|
|
+ endAction = {
|
|
|
+ SmallPlainButton(
|
|
|
+ icon = Icons.Default.Check,
|
|
|
+ onClick = {
|
|
|
+ onFilterChanged(pendingFilterString)
|
|
|
+ onDismissRequest()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
) {
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
|
@@ -71,8 +92,6 @@ fun TextSelectMenuFilterSheet(
|
|
|
.fillMaxHeight(0.8f)
|
|
|
.padding(horizontal = 16.dp, vertical = 8.dp)
|
|
|
) {
|
|
|
-
|
|
|
-
|
|
|
if (apps.isEmpty()) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
@@ -126,10 +145,10 @@ fun TextSelectMenuFilterSheet(
|
|
|
) {
|
|
|
AppText(
|
|
|
text = app.title,
|
|
|
- style = MaterialTheme.typography.titleMedium
|
|
|
+ style = LegadoTheme.typography.titleMedium
|
|
|
)
|
|
|
}
|
|
|
- Switch(
|
|
|
+ AdaptiveSwitch(
|
|
|
checked = isEnabled,
|
|
|
onCheckedChange = { checked ->
|
|
|
val nextSet = if (checked) {
|
|
|
@@ -145,41 +164,6 @@ fun TextSelectMenuFilterSheet(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Row(
|
|
|
- modifier = Modifier.fillMaxWidth().padding(top = 16.dp),
|
|
|
- horizontalArrangement = Arrangement.SpaceBetween,
|
|
|
- verticalAlignment = Alignment.CenterVertically
|
|
|
- ) {
|
|
|
- Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
|
|
- IconButton(onClick = { pendingFilterString = "" }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.SelectAll,
|
|
|
- contentDescription = stringResource(R.string.show_all),
|
|
|
- tint = LegadoTheme.colorScheme.primary
|
|
|
- )
|
|
|
- }
|
|
|
- IconButton(onClick = {
|
|
|
- val allNames = apps.joinToString(",") { it.componentName }
|
|
|
- pendingFilterString = allNames
|
|
|
- }) {
|
|
|
- Icon(
|
|
|
- imageVector = Icons.Default.Deselect,
|
|
|
- contentDescription = stringResource(R.string.hide_all),
|
|
|
- tint = LegadoTheme.colorScheme.error
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- ConfirmDismissButtonsRow(
|
|
|
- modifier = Modifier.weight(1f),
|
|
|
- onDismiss = onDismissRequest,
|
|
|
- onConfirm = {
|
|
|
- onFilterChanged(pendingFilterString)
|
|
|
- onDismissRequest()
|
|
|
- },
|
|
|
- dismissText = stringResource(R.string.cancel),
|
|
|
- confirmText = stringResource(R.string.action_save)
|
|
|
- )
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|