|
@@ -53,17 +53,23 @@ import androidx.compose.material3.RadioButton
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.material.*
|
|
|
import androidx.compose.runtime.*
|
|
|
+import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
|
|
|
@OptIn(ExperimentalLayoutApi::class)
|
|
|
@Composable
|
|
|
-public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
+public fun Filters( onApplyFilters: (Type_subtype_dublicate?, Season_dublicate?, Style_dublicate?) -> Unit,
|
|
|
+ onDismiss: () -> Unit) {
|
|
|
var styledubs by remember { mutableStateOf<List<Style_dublicate>>(listOf()) }
|
|
|
var subdubtypes by remember { mutableStateOf<List<Type_subtype_dublicate>>(listOf()) }
|
|
|
var typedubs by remember { mutableStateOf<List<Type_dublicate>>(listOf()) }
|
|
|
var seasondubs by remember { mutableStateOf<List<Season_dublicate>>(listOf()) }
|
|
|
- var selectedSeasondub by remember { mutableStateOf<Season_dublicate?>(null) }
|
|
|
- var selectedStyledub by remember { mutableStateOf<Style_dublicate?>(null) }
|
|
|
- var selectedTypedub by remember { mutableStateOf<Type_subtype_dublicate?>(null) }
|
|
|
+ var selectedStyle by remember { mutableStateOf<Style_dublicate?>(null) }
|
|
|
+ var selectedSubtype by remember { mutableStateOf<Type_subtype_dublicate?>(null) }
|
|
|
+ var selectedSeason by remember { mutableStateOf<Season_dublicate?>(null) }
|
|
|
+
|
|
|
+ var selectedsubId by remember { mutableStateOf(0) }
|
|
|
+ var selectedseasonId by remember { mutableStateOf(0) }
|
|
|
+ val viewModel = MainViewModel()
|
|
|
LaunchedEffect(Unit) {
|
|
|
withContext(Dispatchers.IO) {
|
|
|
subdubtypes = Constants.supabase.from("Type_subtype_dublicate")
|
|
@@ -82,7 +88,7 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (isVisible) {
|
|
|
+
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
|
.fillMaxHeight()
|
|
@@ -104,7 +110,7 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
|
|
|
// Кнопка для закрытия фильтров
|
|
|
Button(
|
|
|
- onClick = { onClose() }, // Закрыть выбор фильтров
|
|
|
+ onClick = { onDismiss() }, // Закрыть выбор фильтров
|
|
|
modifier = Modifier.padding(top = 16.dp)
|
|
|
.background( Color(0xFFD05656),shape = ButtonDefaults.shape),
|
|
|
colors = ButtonDefaults.buttonColors(containerColor = Color.Transparent)
|
|
@@ -163,13 +169,13 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
modifier = Modifier
|
|
|
.padding(4.dp) // Отступы между элементами
|
|
|
.selectable(
|
|
|
- selected = (seasondub == selectedSeasondub),
|
|
|
- onClick = { selectedSeasondub = seasondub }
|
|
|
+ selected = (seasondub == selectedSeason),
|
|
|
+ onClick = { selectedSeason = seasondub }
|
|
|
)
|
|
|
) {
|
|
|
RadioButton(
|
|
|
- selected = (seasondub == selectedSeasondub),
|
|
|
- onClick = { selectedSeasondub = seasondub }
|
|
|
+ selected = (seasondub == selectedSeason),
|
|
|
+ onClick = { selectedSeason = seasondub }
|
|
|
)
|
|
|
Text(
|
|
|
text = seasondub.title_season,
|
|
@@ -219,13 +225,13 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
modifier = Modifier
|
|
|
|
|
|
.selectable(
|
|
|
- selected = (styledub == selectedStyledub),
|
|
|
- onClick = { selectedStyledub = styledub }
|
|
|
+ selected = (styledub == selectedStyle),
|
|
|
+ onClick = { selectedStyle = styledub }
|
|
|
)
|
|
|
) {
|
|
|
RadioButton(
|
|
|
- selected = (styledub == selectedStyledub),
|
|
|
- onClick = { selectedStyledub = styledub }
|
|
|
+ selected = (styledub == selectedStyle),
|
|
|
+ onClick = { selectedStyle = styledub }
|
|
|
)
|
|
|
Text(
|
|
|
text = styledub.title_style,
|
|
@@ -282,8 +288,8 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
modifier = Modifier
|
|
|
|
|
|
.selectable(
|
|
|
- selected = (subtypedub == selectedTypedub),
|
|
|
- onClick = { selectedTypedub = subtypedub }
|
|
|
+ selected = (subtypedub == selectedSubtype),
|
|
|
+ onClick = { selectedSubtype = subtypedub }
|
|
|
)
|
|
|
.padding(top = 14.dp)
|
|
|
|
|
@@ -291,8 +297,8 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
|
|
|
) {
|
|
|
RadioButton(
|
|
|
- selected = (subtypedub == selectedTypedub),
|
|
|
- onClick = { selectedTypedub = subtypedub }
|
|
|
+ selected = (subtypedub == selectedSubtype),
|
|
|
+ onClick = { selectedSubtype = subtypedub }
|
|
|
)
|
|
|
Text(
|
|
|
text = subtypedub.sub_type,
|
|
@@ -320,7 +326,7 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
}
|
|
|
|
|
|
Button(
|
|
|
- onClick = { /* Действие при нажатии */ },
|
|
|
+ onClick = { onApplyFilters(selectedSubtype, selectedSeason, selectedStyle) },
|
|
|
modifier = Modifier
|
|
|
.align(Alignment.BottomCenter)
|
|
|
.fillMaxWidth() // Занять всю ширину
|
|
@@ -346,5 +352,5 @@ public fun Filters(isVisible: Boolean, onClose: () -> Unit) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
}
|