sprint-1 #1
36
libary/src/main/java/com/example/libary/BottomSheet.kt
Normal file
36
libary/src/main/java/com/example/libary/BottomSheet.kt
Normal file
@ -0,0 +1,36 @@
|
||||
package com.example.libary
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun BottomSheet(
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
ModalBottomSheet(
|
||||
modifier = modifier,
|
||||
onDismissRequest = {},
|
||||
containerColor = Color.White,
|
||||
shape = AbsoluteRoundedCornerShape(24.dp),
|
||||
dragHandle = null
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(horizontal = 20.dp)
|
||||
) {
|
||||
Spacer(Modifier.height(24.dp))
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
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(
|
||||
modifier = modifier,
|
||||
onDismissRequest = {}
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ 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.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
@ -67,14 +68,15 @@ fun Select(
|
||||
)
|
||||
|
||||
if (modal) {
|
||||
ModalWindow {
|
||||
BottomSheet {
|
||||
LazyColumn {
|
||||
items(data) {
|
||||
Text(
|
||||
text = it,
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.W600,
|
||||
modifier = Modifier.padding(5.dp)
|
||||
modifier = Modifier
|
||||
.padding(5.dp)
|
||||
.clickable {
|
||||
value.value = it
|
||||
modal = false
|
||||
@ -86,3 +88,14 @@ fun Select(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun SelectPrev() {
|
||||
val value = remember { mutableStateOf("") }
|
||||
|
||||
Select(
|
||||
value = value,
|
||||
data = listOf("test")
|
||||
)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user