diff --git a/composeApp/src/commonMain/composeResources/drawable/baseline_close_24.xml b/composeApp/src/commonMain/composeResources/drawable/baseline_close_24.xml new file mode 100644 index 0000000..ef97062 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/baseline_close_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composeApp/src/commonMain/composeResources/drawable/baseline_more_vert_24.xml b/composeApp/src/commonMain/composeResources/drawable/baseline_more_vert_24.xml new file mode 100644 index 0000000..9d069d4 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/baseline_more_vert_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/App.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/App.kt index 628cbff..eeda90a 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/App.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/App.kt @@ -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) } } } diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/SwitchButton.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/SwitchButton.kt new file mode 100644 index 0000000..3b6e81a --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/components/SwitchButton.kt @@ -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, + 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, + ) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/dialogs/ScenarioDialog.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/dialogs/ScenarioDialog.kt new file mode 100644 index 0000000..3fe6621 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/dialogs/ScenarioDialog.kt @@ -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, + 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, + ), + ) { + + } + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/ChatsScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/ChatsScreen.kt new file mode 100644 index 0000000..e463290 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/ChatsScreen.kt @@ -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, + ) + ) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/DashboardScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/DashboardScreen.kt new file mode 100644 index 0000000..93b2d11 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/DashboardScreen.kt @@ -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, + ) + ) + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/ScenariosScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/ScenariosScreen.kt new file mode 100644 index 0000000..21c7476 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/ScenariosScreen.kt @@ -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(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, + ) + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/UsersScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/UsersScreen.kt new file mode 100644 index 0000000..184df91 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/cit_is_bot/ui/screens/UsersScreen.kt @@ -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, + ) + ) + } +} \ No newline at end of file