From c6aeb58bdd875bbc57c5c57694f8285dbeff43e9 Mon Sep 17 00:00:00 2001 From: maxnes3 <112558334+maxnes3@users.noreply.github.com> Date: Sat, 11 Nov 2023 04:11:23 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=20=D0=B3=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0,=20=D0=B2=D1=80=D0=BE=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mobileapp/components/InputContent.kt | 38 +++++++++++- .../mobileapp/components/ListContent.kt | 58 +++++++++++++++++-- .../screens/{EditScreen.kt => EditScreens.kt} | 12 +++- .../mobileapp/screens/ListDataScreen.kt | 5 +- .../mobileapp/screens/ListMailScreen.kt | 4 +- .../example/mobileapp/screens/MainScreen.kt | 4 +- .../com/example/mobileapp/ui/theme/Color.kt | 2 +- 7 files changed, 106 insertions(+), 17 deletions(-) rename app/src/main/java/com/example/mobileapp/screens/{EditScreen.kt => EditScreens.kt} (63%) diff --git a/app/src/main/java/com/example/mobileapp/components/InputContent.kt b/app/src/main/java/com/example/mobileapp/components/InputContent.kt index 3e2f40c..d42e9c9 100644 --- a/app/src/main/java/com/example/mobileapp/components/InputContent.kt +++ b/app/src/main/java/com/example/mobileapp/components/InputContent.kt @@ -3,7 +3,11 @@ package com.example.mobileapp.components import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Search import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Surface @@ -12,6 +16,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -32,7 +37,8 @@ fun PlaceholderInputField(label: String){ }, modifier = Modifier .fillMaxWidth() - .padding(top = 8.dp, start = 16.dp, bottom = 8.dp, end = 16.dp)) + .padding(top = 8.dp, start = 16.dp, bottom = 8.dp, end = 16.dp), + shape = RoundedCornerShape(10.dp)) } @OptIn(ExperimentalMaterial3Api::class) @@ -51,7 +57,35 @@ fun PasswordInputField(label: String){ visualTransformation = PasswordVisualTransformation(), modifier = Modifier .fillMaxWidth() - .padding(top = 8.dp, start = 16.dp, bottom = 8.dp, end = 16.dp)) + .padding(top = 8.dp, start = 16.dp, bottom = 8.dp, end = 16.dp), + shape = RoundedCornerShape(10.dp)) +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun SearchInputField(){ + var text = remember { mutableStateOf("") } + + OutlinedTextField( + value = text.value, + onValueChange = { + text.value = it + }, + leadingIcon = { + Icon( + imageVector = Icons.Default.Search, + contentDescription = "", + tint = Color.Gray + ) + }, + placeholder = { + Text("Поиск") + }, + modifier = Modifier + .fillMaxWidth() + .padding(top = 16.dp, start = 16.dp, bottom = 8.dp, end = 16.dp), + shape = RoundedCornerShape(10.dp) + ) } @Preview(showBackground = true) diff --git a/app/src/main/java/com/example/mobileapp/components/ListContent.kt b/app/src/main/java/com/example/mobileapp/components/ListContent.kt index 4f600b7..f7c6f69 100644 --- a/app/src/main/java/com/example/mobileapp/components/ListContent.kt +++ b/app/src/main/java/com/example/mobileapp/components/ListContent.kt @@ -30,6 +30,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale 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 import com.example.mobileapp.R @@ -37,21 +38,24 @@ import com.example.mobileapp.entities.Mail import com.example.mobileapp.entities.MailSingleton import com.example.mobileapp.entities.Story import com.example.mobileapp.entities.StorySingleton +import com.example.mobileapp.ui.theme.BackgroundItem2 import com.example.mobileapp.ui.theme.ButtonColor1 import com.example.mobileapp.ui.theme.ButtonColor2 @Composable fun DataListScroll(){ val storySingleton = StorySingleton() + val isFirstTime = remember { mutableStateOf(true) } LazyColumn( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .fillMaxWidth() ){ - items( - storySingleton.getStoryList() - ){ item -> + item { + addNewListItem() + } + items(storySingleton.getStoryList()){ item -> DataListItem(item = item) } } @@ -144,9 +148,10 @@ fun MailListScroll(){ modifier = Modifier .fillMaxWidth() ){ - items( - mailSingleton.getMailList() - ){ item -> + item { + addNewListItem() + } + items(mailSingleton.getMailList()){ item -> MailListItem(item = item) } } @@ -219,3 +224,44 @@ fun MailListItem(item: Mail){ } } } + +@Preview(showBackground = true) +@Composable +fun addNewListItem(){ + Card( + modifier = Modifier + .fillMaxWidth() + .padding(start = 18.dp, top = 8.dp, end = 18.dp, bottom = 8.dp) + .clickable { + + }, + shape = RoundedCornerShape(15.dp), + colors = CardDefaults.cardColors( + containerColor = BackgroundItem2 + ), + elevation = CardDefaults.cardElevation( + defaultElevation = 8.dp + ) + ) { + Column( + modifier = Modifier.fillMaxSize() + ) { + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically + ){ + Image(painter = painterResource(id = R.drawable.additem), + contentDescription = "additem", + contentScale = ContentScale.Crop, + modifier = Modifier + .size(96.dp) + .padding(8.dp)) + Text( + text = "Добавить", + fontSize = 28.sp, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(start = 32.dp)) + } + } + } +} diff --git a/app/src/main/java/com/example/mobileapp/screens/EditScreen.kt b/app/src/main/java/com/example/mobileapp/screens/EditScreens.kt similarity index 63% rename from app/src/main/java/com/example/mobileapp/screens/EditScreen.kt rename to app/src/main/java/com/example/mobileapp/screens/EditScreens.kt index 5069693..1d34a2a 100644 --- a/app/src/main/java/com/example/mobileapp/screens/EditScreen.kt +++ b/app/src/main/java/com/example/mobileapp/screens/EditScreens.kt @@ -5,10 +5,18 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.navigation.NavHostController -import com.example.mobileapp.components.NavBar @Composable -fun EditScreen(navController: NavHostController) { +fun EditStoryScreen(navController: NavHostController) { + Column( + modifier = Modifier.fillMaxSize() + ) { + + } +} + +@Composable +fun EditMailScreen(navController: NavHostController) { Column( modifier = Modifier.fillMaxSize() ) { diff --git a/app/src/main/java/com/example/mobileapp/screens/ListDataScreen.kt b/app/src/main/java/com/example/mobileapp/screens/ListDataScreen.kt index e82bf5a..52ba4ef 100644 --- a/app/src/main/java/com/example/mobileapp/screens/ListDataScreen.kt +++ b/app/src/main/java/com/example/mobileapp/screens/ListDataScreen.kt @@ -9,12 +9,11 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.navigation.NavHostController import com.example.mobileapp.components.DataListScroll import com.example.mobileapp.components.NavBar import com.example.mobileapp.ui.theme.BackgroundItem1 -import com.example.mobileapp.ui.theme.ButtonColor1 +import com.example.mobileapp.ui.theme.BackgroundItem2 @Composable fun ListDataScreen(navController: NavHostController){ @@ -35,7 +34,7 @@ fun ListDataScreen(navController: NavHostController){ .fillMaxSize(), verticalArrangement = Arrangement.Center ) { - NavBar(navController = navController, itemColorFilter = Color.White) + NavBar(navController = navController, itemColorFilter = BackgroundItem2) } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/mobileapp/screens/ListMailScreen.kt b/app/src/main/java/com/example/mobileapp/screens/ListMailScreen.kt index c2da531..fd54522 100644 --- a/app/src/main/java/com/example/mobileapp/screens/ListMailScreen.kt +++ b/app/src/main/java/com/example/mobileapp/screens/ListMailScreen.kt @@ -9,11 +9,11 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.navigation.NavHostController import com.example.mobileapp.components.MailListScroll import com.example.mobileapp.components.NavBar import com.example.mobileapp.ui.theme.BackgroundItem1 +import com.example.mobileapp.ui.theme.BackgroundItem2 @Composable fun ListMailScreen(navController: NavHostController){ @@ -34,7 +34,7 @@ fun ListMailScreen(navController: NavHostController){ .fillMaxSize(), verticalArrangement = Arrangement.Center ) { - NavBar(navController = navController, itemColorFilter = Color.White) + NavBar(navController = navController, itemColorFilter = BackgroundItem2) } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/mobileapp/screens/MainScreen.kt b/app/src/main/java/com/example/mobileapp/screens/MainScreen.kt index 8b041c1..3caa0e7 100644 --- a/app/src/main/java/com/example/mobileapp/screens/MainScreen.kt +++ b/app/src/main/java/com/example/mobileapp/screens/MainScreen.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.unit.sp import androidx.navigation.NavHostController import com.example.mobileapp.R import com.example.mobileapp.components.NavBar +import com.example.mobileapp.components.SearchInputField @Composable fun MainScreen(navController: NavHostController) { @@ -28,10 +29,11 @@ fun MainScreen(navController: NavHostController) { modifier = Modifier .fillMaxSize() ) { + SearchInputField() Column( modifier = Modifier .fillMaxWidth() - .fillMaxHeight(0.9f), + .fillMaxHeight(0.89f), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { diff --git a/app/src/main/java/com/example/mobileapp/ui/theme/Color.kt b/app/src/main/java/com/example/mobileapp/ui/theme/Color.kt index 6806282..afac3ee 100644 --- a/app/src/main/java/com/example/mobileapp/ui/theme/Color.kt +++ b/app/src/main/java/com/example/mobileapp/ui/theme/Color.kt @@ -11,6 +11,6 @@ val PurpleGrey40 = Color(0xFF625b71) val Pink40 = Color(0xFF7D5260) val BackgroundItem1 = Color(0xff3a425d) -val BackgroundItem2 = Color(0xff7b5a94) +val BackgroundItem2 = Color(0xffe4ecfc) val ButtonColor1 = Color(0xffb8d0e0) val ButtonColor2 = Color(0xff3193cd) \ No newline at end of file