Проработан выпадающий список типа сообщения
Этот коммит содержится в:
родитель
a51b95e9a2
Коммит
58d92406ff
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#ffffff" android:pathData="M16.5,6v11.5c0,2.21 -1.79,4 -4,4s-4,-1.79 -4,-4V5c0,-1.38 1.12,-2.5 2.5,-2.5s2.5,1.12 2.5,2.5v10.5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1V6H10v9.5c0,1.38 1.12,2.5 2.5,2.5s2.5,-1.12 2.5,-2.5V5c0,-2.21 -1.79,-4 -4,-4S7,2.79 7,5v12.5c0,3.04 2.46,5.5 5.5,5.5s5.5,-2.46 5.5,-5.5V6h-1.5z"/>
|
||||
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#ffffff" android:fillType="evenOdd" android:pathData="M13,9.5h5v-2h-5V9.5zM13,16.5h5v-2h-5V16.5zM19,21H5c-1.1,0 -2,-0.9 -2,-2V5c0,-1.1 0.9,-2 2,-2h14c1.1,0 2,0.9 2,2v14C21,20.1 20.1,21 19,21zM6,11h5V6H6V11zM7,7h3v3H7V7zM6,18h5v-5H6V18zM7,14h3v3H7V14z"/>
|
||||
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#ffffff" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM7.5,18c-0.83,0 -1.5,-0.67 -1.5,-1.5S6.67,15 7.5,15s1.5,0.67 1.5,1.5S8.33,18 7.5,18zM7.5,9C6.67,9 6,8.33 6,7.5S6.67,6 7.5,6 9,6.67 9,7.5 8.33,9 7.5,9zM12,13.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM16.5,18c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM16.5,9c-0.83,0 -1.5,-0.67 -1.5,-1.5S15.67,6 16.5,6s1.5,0.67 1.5,1.5S17.33,9 16.5,9z"/>
|
||||
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#ffffff" android:pathData="M20,0L4,0v2h16L20,0zM4,24h16v-2L4,22v2zM20,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM12,6.75c1.24,0 2.25,1.01 2.25,2.25s-1.01,2.25 -2.25,2.25S9.75,10.24 9.75,9 10.76,6.75 12,6.75zM17,17L7,17v-1.5c0,-1.67 3.33,-2.5 5,-2.5s5,0.83 5,2.5L17,17z"/>
|
||||
|
||||
</vector>
|
@ -10,10 +10,12 @@ import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@ -26,18 +28,37 @@ import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.pointer.PointerIcon
|
||||
import androidx.compose.ui.input.pointer.pointerHoverIcon
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import cit_is_bot.composeapp.generated.resources.Res
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_attach_file_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_ballot_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_casino_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_close_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_contacts_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_date_range_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_more_vert_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_title_24
|
||||
import org.jetbrains.compose.resources.DrawableResource
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import ru.csasq.cit_is_bot.ui.screens.Scenario
|
||||
|
||||
enum class MessageType(
|
||||
val id: Int,
|
||||
val displayName: String,
|
||||
val icon: DrawableResource,
|
||||
) {
|
||||
TEXT(1, "Текст", Res.drawable.baseline_title_24),
|
||||
POLL(2, "Опрос", Res.drawable.baseline_ballot_24),
|
||||
MEDIA(3, "Медиа", Res.drawable.baseline_attach_file_24),
|
||||
CONTACT(4, "Контакт", Res.drawable.baseline_contacts_24),
|
||||
DICE(5, "Игральная кость", Res.drawable.baseline_casino_24),
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ScenarioDialog(
|
||||
@ -193,12 +214,22 @@ fun ScenarioDialog(
|
||||
text = "Время запуска",
|
||||
)
|
||||
},
|
||||
placeholder = {
|
||||
Text(
|
||||
text = "0 12 * * 1-5",
|
||||
)
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painter = painterResource(Res.drawable.baseline_date_range_24),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
supportingText = {
|
||||
Text(
|
||||
text = "В формате cron",
|
||||
)
|
||||
},
|
||||
isError = false,
|
||||
singleLine = true,
|
||||
)
|
||||
@ -214,7 +245,17 @@ fun ScenarioDialog(
|
||||
modifier = Modifier
|
||||
.height(16.dp),
|
||||
)
|
||||
Card {
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainer,
|
||||
),
|
||||
) {
|
||||
val dropdownMenuState = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
val messageTypeState = remember {
|
||||
mutableStateOf(MessageType.TEXT)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(16.dp),
|
||||
@ -228,11 +269,18 @@ fun ScenarioDialog(
|
||||
.height(16.dp),
|
||||
)
|
||||
ExposedDropdownMenuBox(
|
||||
expanded = false,
|
||||
onExpandedChange = {},
|
||||
expanded = dropdownMenuState.value,
|
||||
onExpandedChange = { value ->
|
||||
dropdownMenuState.value = value
|
||||
},
|
||||
modifier = Modifier
|
||||
.pointerHoverIcon(
|
||||
icon = PointerIcon.Default,
|
||||
overrideDescendants = true,
|
||||
),
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = "Опрос",
|
||||
value = messageTypeState.value.displayName,
|
||||
onValueChange = {},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -243,25 +291,46 @@ fun ScenarioDialog(
|
||||
)
|
||||
},
|
||||
readOnly = true,
|
||||
leadingIcon = {},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painter = painterResource(messageTypeState.value.icon),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
trailingIcon = {
|
||||
ExposedDropdownMenuDefaults.TrailingIcon(
|
||||
expanded = dropdownMenuState.value,
|
||||
)
|
||||
},
|
||||
supportingText = {},
|
||||
isError = false,
|
||||
singleLine = true,
|
||||
)
|
||||
ExposedDropdownMenu(
|
||||
expanded = false,
|
||||
onDismissRequest = {},
|
||||
expanded = dropdownMenuState.value,
|
||||
onDismissRequest = {
|
||||
dropdownMenuState.value = false
|
||||
},
|
||||
) {
|
||||
// items.forEach {
|
||||
// DropdownMenuItem(
|
||||
// text = {
|
||||
// Text(
|
||||
// text = it.displayName,
|
||||
// )
|
||||
// },
|
||||
// onClick = {},
|
||||
// )
|
||||
// }
|
||||
MessageType.entries.forEach {
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
text = it.displayName,
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
messageTypeState.value = it
|
||||
dropdownMenuState.value = false
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painter = painterResource(it.icon),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user