This commit is contained in:
maxnes3 2023-11-11 10:52:49 +04:00
parent af2135b02f
commit a2ac394189
4 changed files with 63 additions and 17 deletions

View File

@ -1,5 +1,6 @@
package com.example.mobileapp.components
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
@ -20,6 +21,7 @@ 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.graphics.vector.ImageVector
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.tooling.preview.Preview
@ -95,11 +97,41 @@ fun SearchInputField(){
}
@Composable
fun ActiveButton(label: String, backgroundColor: Color, textColor: Color){
fun IconButton(iconLeft: ImageVector, label: String, backgroundColor: Color, textColor: Color, onClickAction: () -> Unit){
Button(
onClick = {
onClick = onClickAction,
modifier = Modifier
.fillMaxWidth()
.requiredHeight(64.dp)
.padding(top = 8.dp, start = 16.dp, bottom = 8.dp, end = 16.dp),
colors = ButtonDefaults.buttonColors(
containerColor = backgroundColor
),
shape = RoundedCornerShape(10.dp)
) {
Row(
modifier = Modifier.fillMaxWidth()
){
Icon(
imageVector = iconLeft,
contentDescription = "",
tint = textColor
)
Text(
text = label,
fontSize = 20.sp,
fontWeight = FontWeight.Bold,
color = textColor,
modifier = Modifier.padding(start = 16.dp)
)
}
}
}
},
@Composable
fun ActiveButton(label: String, backgroundColor: Color, textColor: Color, onClickAction: () -> Unit){
Button(
onClick = onClickAction,
modifier = Modifier
.fillMaxWidth()
.requiredHeight(64.dp)

View File

@ -57,13 +57,13 @@ fun DataListScroll(navController: NavHostController){
addNewListItem(navController, "editstory")
}
items(storySingleton.getStoryList()){ item ->
DataListItem(item = item)
DataListItem(item = item, navController = navController)
}
}
}
@Composable
fun DataListItem(item: Story){
fun DataListItem(item: Story, navController: NavHostController){
val isExpanded = remember {
mutableStateOf(false)
}
@ -114,8 +114,8 @@ fun DataListItem(item: Story){
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
){
DataListItemButton(label = "Изменить", ButtonColor2, Color.White)
DataListItemButton(label = "Удалить", Color.Red, Color.White)
DataListItemButton("Изменить", ButtonColor2, Color.White, onClickAction = { navController.navigate("editstory") })
DataListItemButton("Удалить", Color.Red, Color.White, onClickAction = { })
}
}
}
@ -123,9 +123,9 @@ fun DataListItem(item: Story){
}
@Composable
fun DataListItemButton(label: String, backgroundColor: Color, textColor: Color){
fun DataListItemButton(label: String, backgroundColor: Color, textColor: Color, onClickAction: () -> Unit){
Button(
onClick = { /* Действие при нажатии кнопки */ },
onClick = onClickAction,
modifier = Modifier.requiredHeight(64.dp),
shape = RoundedCornerShape(10.dp),
colors = ButtonDefaults.buttonColors(

View File

@ -39,7 +39,7 @@ fun EditStoryScreen(navController: NavHostController) {
.padding(8.dp)
.align(Alignment.CenterHorizontally))
PlaceholderInputField(label = "Название")
ActiveButton(label = "Выбрать обложку", backgroundColor = ButtonColor1, textColor = Color.Black)
ActiveButton(label = "Выбрать обложку", backgroundColor = ButtonColor1, textColor = Color.Black, onClickAction = {})
PlaceholderInputField(label = "Описание")
NavigationButton(navController = navController, destination = "listdata", label = "Назад",
backgroundColor = ButtonColor2, textColor = Color.White)

View File

@ -10,6 +10,12 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.ExitToApp
import androidx.compose.material.icons.filled.Face
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Share
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
@ -22,7 +28,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.example.mobileapp.R
import com.example.mobileapp.components.IconButton
import com.example.mobileapp.components.NavBar
import com.example.mobileapp.ui.theme.ButtonColor1
import com.example.mobileapp.ui.theme.ButtonColor2
@Composable
fun SettingsScreen(navController: NavHostController){
@ -34,7 +43,7 @@ fun SettingsScreen(navController: NavHostController){
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.9f),
verticalArrangement = Arrangement.Center,
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
){
Image(
@ -42,13 +51,18 @@ fun SettingsScreen(navController: NavHostController){
contentDescription = "settings",
contentScale = ContentScale.Crop,
modifier = Modifier
.size(512.dp)
.size(384.dp)
.padding(8.dp))
Text(
text = "Здесь будут настройки приложения",
fontSize = 20.sp,
fontWeight = FontWeight.Bold
)
IconButton(iconLeft = Icons.Default.AccountCircle, label = "Учётная запись",
backgroundColor = ButtonColor2, textColor = Color.White, onClickAction = { })
IconButton(iconLeft = Icons.Default.Face, label = "Внешний вид",
backgroundColor = ButtonColor1, textColor = Color.Black, onClickAction = { })
IconButton(iconLeft = Icons.Default.Share, label = "Контакты",
backgroundColor = ButtonColor1, textColor = Color.Black, onClickAction = { })
IconButton(iconLeft = Icons.Default.Info, label = "О приложении",
backgroundColor = ButtonColor1, textColor = Color.Black, onClickAction = { })
IconButton(iconLeft = Icons.Default.ExitToApp, label = "Выйти",
backgroundColor = Color.Red, textColor = Color.White, onClickAction = { })
}
Column(
modifier = Modifier