This commit is contained in:
Ваше Имя 2025-05-26 11:47:57 +03:00
parent d4d210e06f
commit 7955c4b679
3 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package com.example.libary
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ModalWindow(
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
ModalBottomSheet(
onDismissRequest = {}
) {
content()
}
}

View File

@ -0,0 +1,88 @@
package com.example.libary
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@Composable
fun Select(
modifier: Modifier = Modifier,
value: MutableState<String>,
data: List<String>,
placeholder: String = ""
) {
var modal by remember { mutableStateOf(false) }
OutlinedTextField(
value = value.value,
onValueChange = {},
modifier = modifier,
shape = AbsoluteRoundedCornerShape(10.dp),
placeholder = {
Text(
text = placeholder,
fontWeight = FontWeight.W400,
fontSize = 16.sp,
color = Color(0xFF939396)
)
},
colors = TextFieldDefaults.colors(
focusedPlaceholderColor = Color(0xFF939396),
unfocusedPlaceholderColor = Color(0xFF939396),
focusedTextColor = Color.Black,
unfocusedTextColor = Color.Black,
focusedIndicatorColor = Color(0xFFEBEBEB),
unfocusedIndicatorColor = Color(0xFFEBEBEB),
focusedContainerColor = Color(0xFFF5F5F9),
unfocusedContainerColor = Color(0xFFF5F5F9)
),
trailingIcon = {
Image(
painter = painterResource(R.drawable.dr_1),
contentDescription = null,
modifier = Modifier.clickable {
modal = true
}
)
}
)
if (modal) {
ModalWindow {
LazyColumn {
items(data) {
Text(
text = it,
fontSize = 20.sp,
fontWeight = FontWeight.W600,
modifier = Modifier.padding(5.dp)
.clickable {
value.value = it
modal = false
}
)
HorizontalDivider()
}
}
}
}
}

View File

@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M5,8.5L10,13.5L15,8.5"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#7E7E9A"
android:strokeLineCap="round"/>
</vector>