sprint-1 #1
19
libary/src/main/java/com/example/libary/Modal.kt
Normal file
19
libary/src/main/java/com/example/libary/Modal.kt
Normal 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()
|
||||
}
|
||||
}
|
88
libary/src/main/java/com/example/libary/Select.kt
Normal file
88
libary/src/main/java/com/example/libary/Select.kt
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
libary/src/main/res/drawable/dr_1.xml
Normal file
13
libary/src/main/res/drawable/dr_1.xml
Normal 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>
|
Loading…
x
Reference in New Issue
Block a user