Разработаны новые экраны, диалоги и компоненты фронтенда
Этот коммит содержится в:
родитель
0be86b369a
Коммит
52493ed6d6
@ -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,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
|
||||
|
||||
</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="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
|
||||
|
||||
</vector>
|
@ -32,6 +32,10 @@ import cit_is_bot.composeapp.generated.resources.baseline_edit_calendar_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_supervisor_account_24
|
||||
import org.jetbrains.compose.resources.DrawableResource
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import ru.csasq.cit_is_bot.ui.screens.ChatsScreen
|
||||
import ru.csasq.cit_is_bot.ui.screens.DashboardScreen
|
||||
import ru.csasq.cit_is_bot.ui.screens.ScenariosScreen
|
||||
import ru.csasq.cit_is_bot.ui.screens.UsersScreen
|
||||
import ru.csasq.cit_is_bot.ui.theme.darkScheme
|
||||
|
||||
sealed class Screen(
|
||||
@ -64,11 +68,10 @@ sealed class Screen(
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun App() {
|
||||
val navController = rememberNavController()
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = darkScheme,
|
||||
) {
|
||||
val navController = rememberNavController()
|
||||
val snackbarHostState = remember {
|
||||
SnackbarHostState()
|
||||
}
|
||||
@ -142,7 +145,7 @@ fun App() {
|
||||
ExtendedFloatingActionButton(
|
||||
text = {
|
||||
Text(
|
||||
text = "Создать правило",
|
||||
text = "Добавить сценарий",
|
||||
)
|
||||
},
|
||||
icon = {
|
||||
@ -165,10 +168,10 @@ fun App() {
|
||||
) {
|
||||
composable(Screen.Dashboard.route) {
|
||||
scheduleFloatingActionButtonVisibleState.value = false
|
||||
// CallProtectionHomeScreen(navController, paddingValues, dataStore, snackbarHostState)
|
||||
DashboardScreen(navController, paddingValues)
|
||||
}
|
||||
composable(Screen.Messages.route) {
|
||||
// CallProtectionScheduleScreen(navController, paddingValues, database)
|
||||
ScenariosScreen(navController, paddingValues)
|
||||
scheduleFloatingActionButtonVisibleState.value = true
|
||||
|
||||
// when {
|
||||
@ -181,11 +184,11 @@ fun App() {
|
||||
}
|
||||
composable(Screen.Chats.route) {
|
||||
scheduleFloatingActionButtonVisibleState.value = false
|
||||
// CallProtectionCallLogScreen(navController, paddingValues)
|
||||
ChatsScreen(navController, paddingValues)
|
||||
}
|
||||
composable(Screen.Users.route) {
|
||||
scheduleFloatingActionButtonVisibleState.value = false
|
||||
// CallProtectionSettingsScreen(navController, paddingValues, dataStore)
|
||||
UsersScreen(navController, paddingValues)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,71 @@
|
||||
package ru.csasq.cit_is_bot.ui.components
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun SwitchButton(
|
||||
title: String,
|
||||
caption: String,
|
||||
switchState: MutableState<Boolean>,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
onClick = onClick,
|
||||
)
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
vertical = 16.dp,
|
||||
),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(
|
||||
weight = 1f,
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
)
|
||||
Spacer(
|
||||
modifier = Modifier
|
||||
.height(4.dp),
|
||||
)
|
||||
Text(
|
||||
text = caption,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
Spacer(
|
||||
modifier = Modifier
|
||||
.width(16.dp),
|
||||
)
|
||||
Switch(
|
||||
checked = switchState.value,
|
||||
onCheckedChange = onCheckedChange,
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package ru.csasq.cit_is_bot.ui.dialogs
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
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_chat_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_close_24
|
||||
import cit_is_bot.composeapp.generated.resources.baseline_more_vert_24
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import ru.csasq.cit_is_bot.ui.screens.Scenario
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun ScenarioDialog(
|
||||
scenarioDialogState: MutableState<Scenario?>,
|
||||
properties: DialogProperties = DialogProperties(
|
||||
usePlatformDefaultWidth = false,
|
||||
),
|
||||
) {
|
||||
Dialog(
|
||||
onDismissRequest = {
|
||||
scenarioDialogState.value = null
|
||||
},
|
||||
properties = properties,
|
||||
) {
|
||||
Scaffold(
|
||||
modifier = Modifier
|
||||
.fillMaxSize(),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
text = scenarioDialogState.value?.let {
|
||||
"Изменить сценарий"
|
||||
} ?: "Добавить сценарий",
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(
|
||||
onClick = {
|
||||
scenarioDialogState.value = null
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(Res.drawable.baseline_close_24),
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
Button(
|
||||
onClick = {
|
||||
scenarioDialogState.value = null
|
||||
},
|
||||
) {
|
||||
Text(
|
||||
text = "Сохранить",
|
||||
)
|
||||
}
|
||||
val dropdownMenuState = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
IconButton(
|
||||
onClick = {
|
||||
dropdownMenuState.value = true
|
||||
},
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(Res.drawable.baseline_more_vert_24),
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = dropdownMenuState.value,
|
||||
onDismissRequest = {
|
||||
dropdownMenuState.value = false
|
||||
},
|
||||
) {
|
||||
scenarioDialogState.value?.let {
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
text = "Удалить",
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
dropdownMenuState.value = false
|
||||
},
|
||||
)
|
||||
}
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
text = "Сообщить о проблеме",
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
dropdownMenuState.value = false
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
text = "Справка",
|
||||
)
|
||||
},
|
||||
onClick = {
|
||||
dropdownMenuState.value = false
|
||||
},
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(
|
||||
state = rememberScrollState(),
|
||||
)
|
||||
.padding(it)
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
),
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package ru.csasq.cit_is_bot.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
|
||||
@Composable
|
||||
fun ChatsScreen(
|
||||
navController: NavController,
|
||||
paddingValues: PaddingValues,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
paddingValues = paddingValues,
|
||||
)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(
|
||||
state = rememberScrollState(),
|
||||
),
|
||||
) {
|
||||
Text (
|
||||
text = "Здесь будут чаты",
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package ru.csasq.cit_is_bot.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import ru.csasq.cit_is_bot.ui.components.SwitchButton
|
||||
|
||||
@Composable
|
||||
fun DashboardScreen(
|
||||
navController: NavController,
|
||||
paddingValues: PaddingValues,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
paddingValues = paddingValues,
|
||||
)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(
|
||||
state = rememberScrollState(),
|
||||
),
|
||||
) {
|
||||
Text (
|
||||
text = "Здесь будет статистика",
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package ru.csasq.cit_is_bot.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import ru.csasq.cit_is_bot.ui.components.SwitchButton
|
||||
import ru.csasq.cit_is_bot.ui.dialogs.ScenarioDialog
|
||||
|
||||
data class Scenario(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val daysOfWeek: String,
|
||||
val time: String,
|
||||
val messageNumber: String,
|
||||
val isEnabled: Boolean,
|
||||
)
|
||||
|
||||
val scenarioList = listOf(
|
||||
Scenario(1, "Текущее состояние сотрудников", "ПН-ПТ", "11:00", "1 сообщение", true),
|
||||
Scenario(2, "Планы на обед", "ПН-ПТ", "11:45-12:00", "2 сообщения", false),
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun ScenariosScreen(
|
||||
navController: NavController,
|
||||
paddingValues: PaddingValues,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
paddingValues = paddingValues,
|
||||
)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(
|
||||
state = rememberScrollState(),
|
||||
),
|
||||
) {
|
||||
val scenarioDialogState = remember {
|
||||
mutableStateOf<Scenario?>(null)
|
||||
}
|
||||
scenarioList.forEach {
|
||||
val scenarioSwitchState = remember {
|
||||
mutableStateOf(it.isEnabled)
|
||||
}
|
||||
val captionAnnotatedString = buildAnnotatedString {
|
||||
append(it.daysOfWeek)
|
||||
append(" \u2022 ")
|
||||
append(it.time)
|
||||
append(" \u2022 ")
|
||||
append(it.messageNumber)
|
||||
}
|
||||
SwitchButton(
|
||||
title = it.name,
|
||||
caption = captionAnnotatedString.text,
|
||||
switchState = scenarioSwitchState,
|
||||
onCheckedChange = { value ->
|
||||
scenarioSwitchState.value = value
|
||||
},
|
||||
onClick = {
|
||||
scenarioDialogState.value = it
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
scenarioDialogState.value?.let {
|
||||
ScenarioDialog(
|
||||
scenarioDialogState = scenarioDialogState,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package ru.csasq.cit_is_bot.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
|
||||
@Composable
|
||||
fun UsersScreen(
|
||||
navController: NavController,
|
||||
paddingValues: PaddingValues,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
paddingValues = paddingValues,
|
||||
)
|
||||
.fillMaxSize()
|
||||
.verticalScroll(
|
||||
state = rememberScrollState(),
|
||||
),
|
||||
) {
|
||||
Text (
|
||||
text = "Здесь будут пользователи",
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user