From 58bf4c05f5aed172b7ea5cd27c3daec9f58cea06 Mon Sep 17 00:00:00 2001 From: csasq Date: Tue, 17 Dec 2024 00:15:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D0=B5=20=D0=BA=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D1=8B,=20=D0=B4=D0=B8=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=B8=20=D0=B8=20=D1=8D=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D1=8B=20=D0=B2=20=D1=81=D0=BE=D0=BE=D1=82?= =?UTF-8?q?=D0=B2=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D1=81=20?= =?UTF-8?q?=D0=A4=D0=A2=D0=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drawable/round_accessible_forward_24.xml | 7 - .../drawable/round_elderly_24.xml | 5 - .../drawable/round_manage_accounts_24.xml | 9 + .../drawable/round_more_vert_24.xml | 5 + .../drawable/round_person_add_24.xml | 5 + .../drawable/round_sports_kabaddi_24.xml | 11 - .../drawable/round_support_agent_24.xml | 11 + .../commonMain/kotlin/ru/csasq/beeapp/App.kt | 100 ++++----- ...uestCard.kt => RegistrationRequestCard.kt} | 54 +++-- .../ru/csasq/beeapp/ui/components/UserCard.kt | 8 +- ...tomerRequestCard.kt => UserRequestCard.kt} | 10 +- .../ru/csasq/beeapp/ui/dialogs/UserDialog.kt | 192 ++++++++++++++++++ ...rRequestDialog.kt => UserRequestDialog.kt} | 119 +++++++---- .../beeapp/ui/screens/AuthorRequestsScreen.kt | 59 ------ .../ui/screens/CustomerRequestsScreen.kt | 71 ------- .../ui/screens/RegistrationRequestsScreen.kt | 93 +++++++++ .../beeapp/ui/screens/SignaturesScreen.kt | 38 ---- .../beeapp/ui/screens/UserRequestsScreen.kt | 89 ++++++++ .../ru/csasq/beeapp/ui/screens/UsersScreen.kt | 77 +++---- .../src/wasmJsMain/resources/index.html | 2 +- .../src/wasmJsMain/resources/styles.css | 6 +- 21 files changed, 632 insertions(+), 339 deletions(-) delete mode 100644 composeApp/src/commonMain/composeResources/drawable/round_accessible_forward_24.xml delete mode 100644 composeApp/src/commonMain/composeResources/drawable/round_elderly_24.xml create mode 100644 composeApp/src/commonMain/composeResources/drawable/round_manage_accounts_24.xml create mode 100644 composeApp/src/commonMain/composeResources/drawable/round_more_vert_24.xml create mode 100644 composeApp/src/commonMain/composeResources/drawable/round_person_add_24.xml delete mode 100644 composeApp/src/commonMain/composeResources/drawable/round_sports_kabaddi_24.xml create mode 100644 composeApp/src/commonMain/composeResources/drawable/round_support_agent_24.xml rename composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/{AuthorRequestCard.kt => RegistrationRequestCard.kt} (77%) rename composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/{CustomerRequestCard.kt => UserRequestCard.kt} (86%) create mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserDialog.kt rename composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/{CustomerRequestDialog.kt => UserRequestDialog.kt} (56%) delete mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/AuthorRequestsScreen.kt delete mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/CustomerRequestsScreen.kt create mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/RegistrationRequestsScreen.kt delete mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/SignaturesScreen.kt create mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UserRequestsScreen.kt diff --git a/composeApp/src/commonMain/composeResources/drawable/round_accessible_forward_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_accessible_forward_24.xml deleted file mode 100644 index 34dbf54..0000000 --- a/composeApp/src/commonMain/composeResources/drawable/round_accessible_forward_24.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/composeApp/src/commonMain/composeResources/drawable/round_elderly_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_elderly_24.xml deleted file mode 100644 index a6a72d4..0000000 --- a/composeApp/src/commonMain/composeResources/drawable/round_elderly_24.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/composeApp/src/commonMain/composeResources/drawable/round_manage_accounts_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_manage_accounts_24.xml new file mode 100644 index 0000000..c2bf476 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/round_manage_accounts_24.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/composeApp/src/commonMain/composeResources/drawable/round_more_vert_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_more_vert_24.xml new file mode 100644 index 0000000..9d069d4 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/round_more_vert_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composeApp/src/commonMain/composeResources/drawable/round_person_add_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_person_add_24.xml new file mode 100644 index 0000000..5cbc627 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/round_person_add_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/composeApp/src/commonMain/composeResources/drawable/round_sports_kabaddi_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_sports_kabaddi_24.xml deleted file mode 100644 index f23c869..0000000 --- a/composeApp/src/commonMain/composeResources/drawable/round_sports_kabaddi_24.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/composeApp/src/commonMain/composeResources/drawable/round_support_agent_24.xml b/composeApp/src/commonMain/composeResources/drawable/round_support_agent_24.xml new file mode 100644 index 0000000..f83d063 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/round_support_agent_24.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/App.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/App.kt index a17d456..d19f84f 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/App.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/App.kt @@ -2,6 +2,8 @@ package ru.csasq.beeapp import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.material3.Badge +import androidx.compose.material3.BadgedBox import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.LinearProgressIndicator @@ -24,16 +26,13 @@ import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import org.jetbrains.compose.resources.painterResource - import bee_app_frontend.composeapp.generated.resources.Res -import bee_app_frontend.composeapp.generated.resources.round_accessible_forward_24 -import bee_app_frontend.composeapp.generated.resources.round_elderly_24 import bee_app_frontend.composeapp.generated.resources.round_group_24 -import bee_app_frontend.composeapp.generated.resources.round_sports_kabaddi_24 +import bee_app_frontend.composeapp.generated.resources.round_person_add_24 +import bee_app_frontend.composeapp.generated.resources.round_support_agent_24 import org.jetbrains.compose.resources.DrawableResource -import ru.csasq.beeapp.ui.screens.AuthorRequestsScreen -import ru.csasq.beeapp.ui.screens.CustomerRequestsScreen -import ru.csasq.beeapp.ui.screens.SignaturesScreen +import ru.csasq.beeapp.ui.screens.RegistrationRequestsScreen +import ru.csasq.beeapp.ui.screens.UserRequestsScreen import ru.csasq.beeapp.ui.screens.UsersScreen import ru.csasq.beeapp.ui.theme.darkScheme @@ -41,27 +40,25 @@ sealed class Screen( val route: String, val title: String, val icon: DrawableResource, + val badge: Int? = null, ) { + data object UserRequests : Screen( + route = "user-requests", + title = "Обращения", + icon = Res.drawable.round_support_agent_24, + badge = 24, + ) + data object RegistrationRequests : Screen( + route = "registration-requests", + title = "Запросы на регистрацию", + icon = Res.drawable.round_person_add_24, + badge = 5, + ) data object Users : Screen( route = "users", title = "Пользователи", icon = Res.drawable.round_group_24, ) - data object AuthorRequests : Screen( - route = "author-requests", - title = "Запросы авторов", - icon = Res.drawable.round_elderly_24, - ) - data object CustomerRequests : Screen( - route = "customer-requests", - title = "Запросы пользователей", - icon = Res.drawable.round_sports_kabaddi_24, - ) - data object Signatures : Screen( - route = "signatures", - title = "Подписи", - icon = Res.drawable.round_accessible_forward_24, - ) } @OptIn(ExperimentalMaterial3Api::class) @@ -85,7 +82,7 @@ fun App() { TopAppBar( title = { Text( - text = "Пчелки «Жу-жу-жу!»", + text = "Помощник пчеловода", overflow = TextOverflow.Ellipsis, softWrap = false, ) @@ -103,18 +100,29 @@ fun App() { NavigationBar { val navBackStackEntry = navController.currentBackStackEntryAsState() val items = listOf( + Screen.UserRequests, + Screen.RegistrationRequests, Screen.Users, - Screen.AuthorRequests, - Screen.CustomerRequests, - Screen.Signatures, ) items.forEach { screen -> NavigationBarItem( icon = { - Icon( - painter = painterResource(screen.icon), - contentDescription = null, - ) + BadgedBox( + badge = { + when { + screen.badge != null -> Badge { + Text( + text = screen.badge.toString(), + ) + } + } + }, + ) { + Icon( + painter = painterResource(screen.icon), + contentDescription = null, + ) + } }, label = { Text( @@ -153,8 +161,20 @@ fun App() { ) { paddingValues -> NavHost( navController = navController, - startDestination = Screen.Users.route, + startDestination = Screen.UserRequests.route, ) { + composable(Screen.UserRequests.route) { + UserRequestsScreen( + navController = navController, + paddingValues = paddingValues, + ) + } + composable(Screen.RegistrationRequests.route) { + RegistrationRequestsScreen( + navController = navController, + paddingValues = paddingValues, + ) + } composable(Screen.Users.route) { UsersScreen( navController = navController, @@ -162,24 +182,6 @@ fun App() { addUserButtonState = floatingActionButtonState, ) } - composable(Screen.AuthorRequests.route) { - AuthorRequestsScreen( - navController = navController, - paddingValues = paddingValues, - ) - } - composable(Screen.CustomerRequests.route) { - CustomerRequestsScreen( - navController = navController, - paddingValues = paddingValues, - ) - } - composable(Screen.Signatures.route) { - SignaturesScreen( - navController = navController, - paddingValues = paddingValues, - ) - } } } } diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestCard.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/RegistrationRequestCard.kt similarity index 77% rename from composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestCard.kt rename to composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/RegistrationRequestCard.kt index 982eb2f..84fa06c 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestCard.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/RegistrationRequestCard.kt @@ -36,26 +36,40 @@ import androidx.compose.ui.unit.dp import bee_app_frontend.composeapp.generated.resources.Res import bee_app_frontend.composeapp.generated.resources.round_check_24 import bee_app_frontend.composeapp.generated.resources.round_close_24 +import bee_app_frontend.composeapp.generated.resources.round_manage_accounts_24 import org.jetbrains.compose.resources.painterResource -import ru.csasq.beeapp.ui.screens.AuthorRequest +import ru.csasq.beeapp.ui.screens.RegistrationRequest @Composable -fun AuthorRequestCard( - authorRequest: AuthorRequest, - spoilerState: MutableState, +fun RegistrationRequestCard( + registrationRequest: RegistrationRequest, + spoilerState: MutableState, onAccept: () -> Unit, + onEdit: () -> Unit, onDecline: () -> Unit, ) { val backgroundColor = animateColorAsState( - targetValue = if (spoilerState.value == authorRequest) MaterialTheme.colorScheme.primary.copy(alpha = 0.12f) else Color.Transparent, + targetValue = when (spoilerState.value) { + registrationRequest -> MaterialTheme.colorScheme.primary.copy( + alpha = 0.12f, + ) + else -> Color.Transparent + }, ) val horizontalPadding = animateDpAsState( - targetValue = if (spoilerState.value == authorRequest) 16.dp else 0.dp, + targetValue = when (spoilerState.value) { + registrationRequest -> 16.dp + else -> 0.dp + }, ) val shapeState = animateDpAsState( - targetValue = if (spoilerState.value == authorRequest) 28.0.dp else 0.0.dp, + targetValue = when (spoilerState.value) { + registrationRequest -> 28.0.dp + else -> 0.0.dp + }, ) val cardColors = CardDefaults.cardColors() + Card( modifier = Modifier .padding( @@ -64,8 +78,8 @@ fun AuthorRequestCard( .fillMaxWidth(), onClick = { spoilerState.value = when (spoilerState.value) { - authorRequest -> null - else -> authorRequest + registrationRequest -> null + else -> registrationRequest } }, shape = RoundedCornerShape(shapeState.value), @@ -83,7 +97,7 @@ fun AuthorRequestCard( .padding(16.dp), ) { Text( - text = authorRequest.title, + text = registrationRequest.fullName, overflow = TextOverflow.Ellipsis, maxLines = 1, style = MaterialTheme.typography.titleLarge, @@ -92,14 +106,14 @@ fun AuthorRequestCard( modifier = Modifier.height(4.dp), ) Text( - text = authorRequest.description, + text = registrationRequest.region, overflow = TextOverflow.Ellipsis, maxLines = 3, style = MaterialTheme.typography.bodyMedium, ) } AnimatedVisibility( - visible = spoilerState.value == authorRequest, + visible = spoilerState.value == registrationRequest, ) { HorizontalDivider() Row( @@ -108,7 +122,7 @@ fun AuthorRequestCard( .height(IntrinsicSize.Min), horizontalArrangement = Arrangement.SpaceBetween, ) { - AuthorRequestButton( + RegistrationRequestButton( modifier = Modifier .weight( weight = 1f, @@ -118,7 +132,17 @@ fun AuthorRequestCard( painter = painterResource(Res.drawable.round_check_24), onClick = onAccept, ) - AuthorRequestButton( + RegistrationRequestButton( + modifier = Modifier + .weight( + weight = 1f, + fill = true, + ), + title = "Изменить", + painter = painterResource(Res.drawable.round_manage_accounts_24), + onClick = onEdit, + ) + RegistrationRequestButton( modifier = Modifier .weight( weight = 1f, @@ -135,7 +159,7 @@ fun AuthorRequestCard( } @Composable -fun AuthorRequestButton( +fun RegistrationRequestButton( modifier: Modifier = Modifier, title: String, painter: Painter, diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserCard.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserCard.kt index e2e55cd..54bbf49 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserCard.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserCard.kt @@ -11,11 +11,11 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import ru.csasq.beeapp.ui.screens.User @Composable fun UserCard( - title: String, - caption: String, + user: User, onClick: (() -> Unit), ) { Column( @@ -27,14 +27,14 @@ fun UserCard( .padding(16.dp), ) { Text( - text = title, + text = user.fullName, style = MaterialTheme.typography.titleLarge, ) Spacer( modifier = Modifier.height(4.dp), ) Text( - text = caption, + text = user.phoneNumber, style = MaterialTheme.typography.bodyMedium, ) } diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/CustomerRequestCard.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserRequestCard.kt similarity index 86% rename from composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/CustomerRequestCard.kt rename to composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserRequestCard.kt index 8396bda..c079368 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/CustomerRequestCard.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/UserRequestCard.kt @@ -12,11 +12,11 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import ru.csasq.beeapp.ui.screens.UserRequest @Composable -fun CustomerRequestCard( - title: String, - description: String, +fun UserRequestCard( + userRequest: UserRequest, onClick: (() -> Unit), ) { Column( @@ -28,14 +28,14 @@ fun CustomerRequestCard( .padding(16.dp), ) { Text( - text = title, + text = userRequest.region, style = MaterialTheme.typography.titleLarge, ) Spacer( modifier = Modifier.height(4.dp), ) Text( - text = description, + text = userRequest.topic, overflow = TextOverflow.Ellipsis, maxLines = 3, style = MaterialTheme.typography.bodyMedium, diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserDialog.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserDialog.kt new file mode 100644 index 0000000..3185e76 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserDialog.kt @@ -0,0 +1,192 @@ +package ru.csasq.beeapp.ui.dialogs + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +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.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.OutlinedTextField +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +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.style.TextOverflow +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties +import bee_app_frontend.composeapp.generated.resources.Res +import bee_app_frontend.composeapp.generated.resources.round_close_24 +import bee_app_frontend.composeapp.generated.resources.round_more_vert_24 +import org.jetbrains.compose.resources.painterResource +import ru.csasq.beeapp.ui.screens.User + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun UserDialog( + user: User, + onDismiss: () -> Unit, + onSave: () -> Unit, + onDelete: (() -> Unit)? = null, + onDecline: (() -> Unit)? = null, + properties: DialogProperties = DialogProperties( + usePlatformDefaultWidth = false, + ), +) { + Dialog( + onDismissRequest = onDismiss, + properties = properties, + ) { + Scaffold( + modifier = Modifier + .fillMaxSize(), + topBar = { + TopAppBar( + title = { + Text( + text = when { + onDelete != null -> "Изменить пользователя" + else -> "Создать пользователя" + }, + overflow = TextOverflow.Ellipsis, + softWrap = false, + ) + }, + navigationIcon = { + IconButton( + onClick = onDismiss, + ) { + Icon( + painter = painterResource(Res.drawable.round_close_24), + contentDescription = null, + ) + } + }, + actions = { + Button( + onClick = onSave, + ) { + Text( + text = "Сохранить", + ) + } + + if (onDelete == null && onDecline == null) { + Spacer( + modifier = Modifier + .width(16.dp), + ) + return@TopAppBar + } + + val dropdownMenuState = remember { + mutableStateOf(false) + } + IconButton( + onClick = { + dropdownMenuState.value = true + }, + ) { + Icon( + painter = painterResource(Res.drawable.round_more_vert_24), + contentDescription = null, + ) + } + DropdownMenu( + expanded = dropdownMenuState.value, + onDismissRequest = { + dropdownMenuState.value = false + }, + ) { + onDelete?.let { + DropdownMenuItem( + text = { + Text( + text = "Удалить", + ) + }, + onClick = it, + ) + } + onDecline?.let { + DropdownMenuItem( + text = { + Text( + text = "Отклонить", + ) + }, + onClick = it, + ) + } + } + }, + ) + }, + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + .padding( + horizontal = 16.dp, + ), + ) { + Column( + modifier = Modifier + .weight(1f) + .verticalScroll( + state = rememberScrollState(), + ) + ) { + val fullNameState = remember { + mutableStateOf(user.fullName) + } + OutlinedTextField( + value = fullNameState.value, + onValueChange = { + fullNameState.value = it + }, + modifier = Modifier + .fillMaxWidth(), + label = { + Text( + text = "Имя пользователя", + ) + }, + ) + Spacer( + modifier = Modifier.height(16.dp), + ) + val phoneNumberState = remember { + mutableStateOf(user.phoneNumber) + } + OutlinedTextField( + value = phoneNumberState.value, + onValueChange = { + phoneNumberState.value = it + }, + modifier = Modifier + .fillMaxWidth(), + label = { + Text( + text = "Номер телефона", + ) + }, + ) + } + } + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/CustomerRequestDialog.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserRequestDialog.kt similarity index 56% rename from composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/CustomerRequestDialog.kt rename to composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserRequestDialog.kt index 12275b5..f246e7f 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/CustomerRequestDialog.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/dialogs/UserRequestDialog.kt @@ -4,27 +4,25 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize +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.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextOverflow @@ -34,31 +32,21 @@ import androidx.compose.ui.window.DialogProperties import bee_app_frontend.composeapp.generated.resources.Res import bee_app_frontend.composeapp.generated.resources.round_close_24 import org.jetbrains.compose.resources.painterResource -import ru.csasq.beeapp.ui.screens.CustomerRequest +import ru.csasq.beeapp.ui.screens.UserRequest @OptIn(ExperimentalMaterial3Api::class) @Composable -fun CustomerRequestDialog( - dialogState: MutableState, +fun UserRequestDialog( + userRequest: UserRequest, + onDismiss: () -> Unit, + onAccept: () -> Unit, + onDecline: () -> Unit, properties: DialogProperties = DialogProperties( usePlatformDefaultWidth = false, ), ) { - val coroutine = rememberCoroutineScope() - val progressIndicatorState = remember { - mutableStateOf(false) - } - val titleState = remember { - mutableStateOf(dialogState.value?.title) - } - val descriptionState = remember { - mutableStateOf(dialogState.value?.description) - } - Dialog( - onDismissRequest = { - dialogState.value = null - }, + onDismissRequest = onDismiss, properties = properties, ) { val verticalScrollState = rememberScrollState() @@ -82,18 +70,14 @@ fun CustomerRequestDialog( TopAppBar( title = { Text( - text = dialogState.value?.id?.let { - "Изменить сценарий" - } ?: "Добавить сценарий", + text = "Обращение пользователя", overflow = TextOverflow.Ellipsis, softWrap = false, ) }, navigationIcon = { IconButton( - onClick = { - dialogState.value = null - }, + onClick = onDismiss, ) { Icon( painter = painterResource(Res.drawable.round_close_24), @@ -120,21 +104,82 @@ fun CustomerRequestDialog( state = verticalScrollState, ) ) { - Text( - text = dialogState.value?.title!!, - style = MaterialTheme.typography.titleLarge, + OutlinedTextField( + value = userRequest.topic, + onValueChange = {}, + modifier = Modifier + .fillMaxWidth(), + readOnly = true, + label = { + Text( + text = "Тема обращения", + ) + }, ) Spacer( - modifier = Modifier.height(4.dp), + modifier = Modifier.height(16.dp), ) - Text( - text = dialogState.value?.description!!, - style = MaterialTheme.typography.bodyMedium, + OutlinedTextField( + value = userRequest.user.fullName, + onValueChange = {}, + modifier = Modifier + .fillMaxWidth(), + readOnly = true, + label = { + Text( + text = "ФИО заявителя", + ) + }, + ) + Spacer( + modifier = Modifier.height(16.dp), + ) + OutlinedTextField( + value = userRequest.user.phoneNumber, + onValueChange = {}, + modifier = Modifier + .fillMaxWidth(), + readOnly = true, + label = { + Text( + text = "Номер телефона", + ) + }, + ) + Spacer( + modifier = Modifier.height(16.dp), + ) + OutlinedTextField( + value = userRequest.region + ", " + userRequest.location, + onValueChange = {}, + modifier = Modifier + .fillMaxWidth(), + readOnly = true, + label = { + Text( + text = "Регион и место", + ) + }, + ) + Spacer( + modifier = Modifier.height(16.dp), + ) + OutlinedTextField( + value = userRequest.text, + onValueChange = {}, + modifier = Modifier + .fillMaxWidth(), + readOnly = true, + label = { + Text( + text = "Сутевая часть", + ) + }, ) } Row { Button( - onClick = {}, + onClick = onAccept, modifier = Modifier .weight(1f), ) { @@ -143,10 +188,10 @@ fun CustomerRequestDialog( ) } Spacer( - modifier = Modifier.width(8.dp), + modifier = Modifier.width(16.dp), ) OutlinedButton( - onClick = {}, + onClick = onDecline, modifier = Modifier .weight(1f), ) { diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/AuthorRequestsScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/AuthorRequestsScreen.kt deleted file mode 100644 index a01789a..0000000 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/AuthorRequestsScreen.kt +++ /dev/null @@ -1,59 +0,0 @@ -package ru.csasq.beeapp.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.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.navigation.NavController -import ru.csasq.beeapp.ui.components.AuthorRequestCard - -data class AuthorRequest( - val id: Int, - val title: String, - val description: String, -) - -@Composable -fun AuthorRequestsScreen( - navController: NavController, - paddingValues: PaddingValues, -) { - Column( - modifier = Modifier - .padding( - paddingValues = paddingValues, - ) - .fillMaxSize() - .verticalScroll( - state = rememberScrollState(), - ), - ) { - val authorRequestList = mutableListOf() - val spoilerState = remember { - mutableStateOf(null) - } - for (id in 1..25) { - authorRequestList.add( - AuthorRequest( - id = id, - title = "Заявляю о пропаже пчел", - description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", - ) - ) - } - authorRequestList.forEach { - AuthorRequestCard( - authorRequest = it, - spoilerState = spoilerState, - onAccept = {}, - onDecline = {}, - ) - } - } -} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/CustomerRequestsScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/CustomerRequestsScreen.kt deleted file mode 100644 index ec4893d..0000000 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/CustomerRequestsScreen.kt +++ /dev/null @@ -1,71 +0,0 @@ -package ru.csasq.beeapp.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.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.navigation.NavController -import ru.csasq.beeapp.ui.components.AuthorRequestCard -import ru.csasq.beeapp.ui.components.CustomerRequestCard -import ru.csasq.beeapp.ui.components.UserCard -import ru.csasq.beeapp.ui.dialogs.CustomerRequestDialog - -data class CustomerRequest( - val id: Int, - val title: String, - val description: String, - val attachments: List, -) - -@Composable -fun CustomerRequestsScreen( - navController: NavController, - paddingValues: PaddingValues, -) { - Column( - modifier = Modifier - .padding( - paddingValues = paddingValues, - ) - .fillMaxSize() - .verticalScroll( - state = rememberScrollState(), - ), - ) { - val customerRequestList = mutableListOf() - val dialogState = remember { - mutableStateOf(null) - } - for (id in 1..25) { - customerRequestList.add( - CustomerRequest( - id = id, - title = "Заявка $id", - description = "Я вмер", - attachments = listOf(), - ) - ) - } - customerRequestList.forEach { - CustomerRequestCard( - title = it.title, - description = it.description, - onClick = { - dialogState.value = it - }, - ) - } - - dialogState.value?.let { - CustomerRequestDialog( - dialogState = dialogState, - ) - } - } -} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/RegistrationRequestsScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/RegistrationRequestsScreen.kt new file mode 100644 index 0000000..5a02403 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/RegistrationRequestsScreen.kt @@ -0,0 +1,93 @@ +package ru.csasq.beeapp.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.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.navigation.NavController +import ru.csasq.beeapp.ui.components.RegistrationRequestCard +import ru.csasq.beeapp.ui.dialogs.UserDialog + +data class RegistrationRequest( + val id: Int, + val fullName: String, + val phoneNumber: String, + val region: String, +) + +@Composable +fun RegistrationRequestsScreen( + navController: NavController, + paddingValues: PaddingValues, +) { + Column( + modifier = Modifier + .padding( + paddingValues = paddingValues, + ) + .fillMaxSize() + .verticalScroll( + state = rememberScrollState(), + ), + ) { + val registrationRequestList = mutableListOf() + val spoilerState = remember { + mutableStateOf(null) + } + val dialogState = remember { + mutableStateOf(null) + } + + for (id in 1..5) { + registrationRequestList.add( + RegistrationRequest( + id = id, + fullName = "Иваницкий Глеб Олегович", + phoneNumber = "+79954426969", + region = "Узловский район", + ) + ) + } + + registrationRequestList.forEach { + RegistrationRequestCard( + registrationRequest = it, + spoilerState = spoilerState, + onAccept = { + spoilerState.value = null + }, + onEdit = { + dialogState.value = User( + fullName = it.fullName, + phoneNumber = it.phoneNumber, + ) + spoilerState.value = null + }, + onDecline = { + spoilerState.value = null + }, + ) + } + + dialogState.value?.let { + UserDialog( + user = it, + onDismiss = { + dialogState.value = null + }, + onSave = { + dialogState.value = null + }, + onDecline = { + dialogState.value = null + }, + ) + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/SignaturesScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/SignaturesScreen.kt deleted file mode 100644 index c6c0da2..0000000 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/SignaturesScreen.kt +++ /dev/null @@ -1,38 +0,0 @@ -package ru.csasq.beeapp.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 SignaturesScreen( - 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/beeapp/ui/screens/UserRequestsScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UserRequestsScreen.kt new file mode 100644 index 0000000..cf856b4 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UserRequestsScreen.kt @@ -0,0 +1,89 @@ +package ru.csasq.beeapp.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.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.navigation.NavController +import ru.csasq.beeapp.ui.components.UserRequestCard +import ru.csasq.beeapp.ui.dialogs.UserRequestDialog + +data class UserRequest( + val id: Int, + val user: User, + val region: String, + val location: String, + val topic: String, + val text: String, + val images: List, +) + +@Composable +fun UserRequestsScreen( + navController: NavController, + paddingValues: PaddingValues, +) { + Column( + modifier = Modifier + .padding( + paddingValues = paddingValues, + ) + .fillMaxSize() + .verticalScroll( + state = rememberScrollState(), + ), + ) { + val userRequestList = mutableListOf() + val dialogState = remember { + mutableStateOf(null) + } + val user = User( + id = 1, + fullName = "Иваницкий Глеб Олегович", + phoneNumber = "+79954426969", + ) + + for (id in 1..24) { + userRequestList.add( + UserRequest( + id = id, + user = user, + region = "Узловский район", + location = "пер. Центральный, возле поля", + topic = "Фиксация гибели пчел", + text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", + images = listOf(), + ) + ) + } + userRequestList.forEach { + UserRequestCard( + userRequest = it, + onClick = { + dialogState.value = it + }, + ) + } + + dialogState.value?.let { + UserRequestDialog( + userRequest = it, + onDismiss = { + dialogState.value = null + }, + onAccept = { + dialogState.value = null + }, + onDecline = { + dialogState.value = null + }, + ) + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt index dc7e701..fa70bb4 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt @@ -1,19 +1,13 @@ package ru.csasq.beeapp.ui.screens -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.Badge import androidx.compose.material3.ExtendedFloatingActionButton import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -21,15 +15,19 @@ import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.snapshotFlow -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp import androidx.navigation.NavController import bee_app_frontend.composeapp.generated.resources.Res import bee_app_frontend.composeapp.generated.resources.round_add_24 -import bee_app_frontend.composeapp.generated.resources.round_close_24 import org.jetbrains.compose.resources.painterResource import ru.csasq.beeapp.ui.components.UserCard +import ru.csasq.beeapp.ui.dialogs.UserDialog + +data class User( + val id: Int? = null, + var fullName: String = "", + var phoneNumber: String = "", +) @Composable fun UsersScreen( @@ -50,6 +48,10 @@ fun UsersScreen( previousValue = it } } + val dialogState = remember { + mutableStateOf(null) + } + val userList = mutableListOf() Column( modifier = Modifier @@ -61,36 +63,21 @@ fun UsersScreen( state = verticalScrollState, ), ) { - Row( - modifier = Modifier - .background( - color = MaterialTheme.colorScheme.onPrimaryContainer, + for (id in 1..17) { + userList.add( + User( + id = id, + fullName = "Иваницкий Глеб Олегович", + phoneNumber = "+79954426969", ) - .padding(16.dp) - .fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - text = "Заявки на регистрацию", - color = MaterialTheme.colorScheme.onPrimary, ) - Badge( - containerColor = MaterialTheme.colorScheme.primaryContainer, - contentColor = MaterialTheme.colorScheme.primary, - ) { - Text( - text = "24", - modifier = Modifier - .padding(8.dp), - ) - } } - repeat(25) { + userList.forEach { UserCard( - title = "Иваницкий Глеб Олегович", - caption = "Гавносос последней степени критинизма", - onClick = {}, + user = it, + onClick = { + dialogState.value = it + }, ) } } @@ -108,9 +95,27 @@ fun UsersScreen( contentDescription = null, ) }, - onClick = {}, + onClick = { + dialogState.value = User() + }, expanded = addUserButtonExpandedState.value, ) } + dialogState.value?.let { + UserDialog( + user = it, + onDismiss = { + dialogState.value = null + }, + onSave = { + dialogState.value = null + }, + onDelete = it.id?.let { + { + dialogState.value = null + } + } + ) + } } \ No newline at end of file diff --git a/composeApp/src/wasmJsMain/resources/index.html b/composeApp/src/wasmJsMain/resources/index.html index 1f3a223..d06c6e4 100644 --- a/composeApp/src/wasmJsMain/resources/index.html +++ b/composeApp/src/wasmJsMain/resources/index.html @@ -4,7 +4,7 @@ - Пчелки «Жу-жу-жу!» + Помощник пчеловода diff --git a/composeApp/src/wasmJsMain/resources/styles.css b/composeApp/src/wasmJsMain/resources/styles.css index 0549b10..258c3ec 100644 --- a/composeApp/src/wasmJsMain/resources/styles.css +++ b/composeApp/src/wasmJsMain/resources/styles.css @@ -4,4 +4,8 @@ html, body { margin: 0; padding: 0; overflow: hidden; -} \ No newline at end of file +} + +canvas { + outline: none; +}