Лаба готова, вроде

This commit is contained in:
maxnes3 2023-11-11 04:11:23 +04:00
parent ea2618556f
commit c6aeb58bdd
7 changed files with 106 additions and 17 deletions

View File

@ -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)

View File

@ -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))
}
}
}
}

View File

@ -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()
) {

View File

@ -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)
}
}
}

View File

@ -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)
}
}
}

View File

@ -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
) {

View File

@ -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)