Почти готово.
This commit is contained in:
parent
0f2db13184
commit
5520140746
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -16,6 +16,7 @@ import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||
@ -249,6 +250,14 @@ fun MainNavbar(navController: NavController) {
|
||||
){
|
||||
if(currentScreen?.route == Screen.TankList.route){
|
||||
DropDownList(navController)
|
||||
Button(
|
||||
onClick = {
|
||||
val route = Screen.Constructor.route.replace("{id}", 0.toString())
|
||||
navController.navigate(route)
|
||||
}
|
||||
) {
|
||||
Text(text = "Добавить")
|
||||
}
|
||||
}
|
||||
Navhost(navController)
|
||||
}
|
||||
|
@ -113,45 +113,47 @@ fun ColumnItem(
|
||||
)
|
||||
{
|
||||
tanks.forEach { tank ->
|
||||
key(tank.tankId) {
|
||||
//val studentId = Screen.StudentView.route.replace("{id}", index.toString())
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = CustomDark,
|
||||
),
|
||||
modifier = Modifier
|
||||
.size(width = 200.dp, height = 250.dp)
|
||||
.padding(all = 5.dp)
|
||||
.clickable { onClick(tank.tankId!!) }
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = tank.image),
|
||||
contentDescription = stringResource(id = R.string.tanks_main_title),
|
||||
if(tank.tankId != null){
|
||||
key(tank.tankId) {
|
||||
//val studentId = Screen.StudentView.route.replace("{id}", index.toString())
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = CustomDark,
|
||||
),
|
||||
modifier = Modifier
|
||||
.height(150.dp)
|
||||
.size(width = 200.dp, height = 250.dp)
|
||||
.padding(all = 5.dp)
|
||||
)
|
||||
Text(
|
||||
text = tank.name,
|
||||
fontSize = 30.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = CustomOrange,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
Button(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(10.dp, 0.dp, 10.dp, 10.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = CustomRed,
|
||||
contentColor = CustomDark),
|
||||
onClick = { }
|
||||
.clickable { onClick(tank.tankId) }
|
||||
) {
|
||||
//navController?.navigate(Screen.Hangar.route)
|
||||
//navController?.navigate(studentId)
|
||||
//"${student.firstName} ${student.lastName}"
|
||||
Text(text = stringResource(id = R.string.purchase_button))
|
||||
Image(
|
||||
painter = painterResource(id = tank.image),
|
||||
contentDescription = stringResource(id = R.string.tanks_main_title),
|
||||
modifier = Modifier
|
||||
.height(150.dp)
|
||||
.padding(all = 5.dp)
|
||||
)
|
||||
Text(
|
||||
text = tank.name,
|
||||
fontSize = 30.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = CustomOrange,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
Button(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(10.dp, 0.dp, 10.dp, 10.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = CustomRed,
|
||||
contentColor = CustomDark),
|
||||
onClick = { }
|
||||
) {
|
||||
//navController?.navigate(Screen.Hangar.route)
|
||||
//navController?.navigate(studentId)
|
||||
//"${student.firstName} ${student.lastName}"
|
||||
Text(text = stringResource(id = R.string.purchase_button))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +170,6 @@ private fun TankList(
|
||||
listTanks: List<Tank>,
|
||||
onClick: (uid: Long) -> Unit,
|
||||
) {
|
||||
|
||||
LazyColumn(
|
||||
verticalArrangement = Arrangement.Bottom,
|
||||
modifier = Modifier.height(300.dp * numbers.size),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.ulstu.`is`.pmu.tank.composeui.edit
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -23,6 +24,7 @@ class TankEditViewModel(
|
||||
private val tankUid: Long = checkNotNull(savedStateHandle["id"])
|
||||
|
||||
init {
|
||||
Log.d("hi-hi", tankUid.toString())
|
||||
viewModelScope.launch {
|
||||
if (tankUid > 0) {
|
||||
tankUiState = tankRepository.getTank(tankUid)
|
||||
|
@ -29,7 +29,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun userDao() : UserDao
|
||||
|
||||
companion object {
|
||||
private const val DB_NAME: String = "nine-db"
|
||||
private const val DB_NAME: String = "ten-db"
|
||||
|
||||
@Volatile
|
||||
private var INSTANCE: AppDatabase? = null
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ru.ulstu.`is`.pmu.tanks.composeui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@ -72,12 +73,15 @@ fun Constructor(
|
||||
nationDropDownViewModel: NationDropDownViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
||||
){
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
val tankUiState = tankEditViewModel.tankUiState
|
||||
Log.d("hi-2", tankUiState.tankDetails.name)
|
||||
|
||||
levelDropDownViewModel.setCurrentLevel(tankEditViewModel.tankUiState.tankDetails.levelId ?: 1)
|
||||
nationDropDownViewModel.setCurrentNation(tankEditViewModel.tankUiState.tankDetails.nationId ?: 1)
|
||||
nationDropDownViewModel.setCurrentNation(tankUiState.tankDetails.nationId ?: 1)
|
||||
|
||||
Constructor(
|
||||
tankUiState = tankEditViewModel.tankUiState,
|
||||
tankUiState = tankUiState,
|
||||
levelUiState = levelDropDownViewModel.levelUiState,
|
||||
levelsListUiState = levelDropDownViewModel.levelsListUiState,
|
||||
onLevelUpdate = levelDropDownViewModel::updateUiState,
|
||||
@ -107,16 +111,11 @@ private fun Constructor(
|
||||
onClick: () -> Unit,
|
||||
onUpdate: (TankDetails) -> Unit
|
||||
) {
|
||||
var tankName by remember { mutableStateOf(tankUiState.tankDetails.name) }
|
||||
var price by remember { mutableStateOf(tankUiState.tankDetails.price.toString()) }
|
||||
|
||||
//для работы выпадающего списка уровней
|
||||
var expandedLevels by remember { mutableStateOf(false) }
|
||||
var selectedLevel by remember { mutableIntStateOf(1) }
|
||||
|
||||
//для работы выпадающего списка наций
|
||||
var expandedNation by remember { mutableStateOf(false) }
|
||||
var selectedNation by remember { mutableStateOf("СССР") }
|
||||
|
||||
Column(
|
||||
verticalArrangement = Arrangement.spacedBy(35.dp),
|
||||
@ -153,7 +152,7 @@ private fun Constructor(
|
||||
}
|
||||
Column {
|
||||
TextField(
|
||||
value = tankName,
|
||||
value = tankUiState.tankDetails.name,
|
||||
placeholder = { Text(text = "Название", color = CustomDark) },
|
||||
onValueChange = { onUpdate(tankUiState.tankDetails.copy(name = it)) },
|
||||
modifier = Modifier
|
||||
@ -173,7 +172,7 @@ private fun Constructor(
|
||||
.menuAnchor() // menuAnchor modifier must be passed to the text field for correctness.
|
||||
.width(200.dp),
|
||||
readOnly = true,
|
||||
value = selectedLevel.toString(),
|
||||
value = levelUiState.level?.level.toString(),
|
||||
onValueChange = {},
|
||||
label = { Text("") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandedLevels) },
|
||||
@ -192,7 +191,6 @@ private fun Constructor(
|
||||
DropdownMenuItem(
|
||||
text = { Text(selectionOption.level.toString()) },
|
||||
onClick = {
|
||||
selectedLevel = selectionOption.level
|
||||
onLevelUpdate(selectionOption)
|
||||
expandedLevels = false
|
||||
},
|
||||
@ -215,7 +213,7 @@ private fun Constructor(
|
||||
.menuAnchor() // menuAnchor modifier must be passed to the text field for correctness.
|
||||
.width(200.dp),
|
||||
readOnly = true,
|
||||
value = selectedNation,
|
||||
value = nationUiState.nation?.nationName ?: "",
|
||||
onValueChange = {},
|
||||
label = { Text("") },
|
||||
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = expandedNation) },
|
||||
@ -234,7 +232,6 @@ private fun Constructor(
|
||||
DropdownMenuItem(
|
||||
text = { Text(selectionOption.nationName) },
|
||||
onClick = {
|
||||
selectedNation = selectionOption.nationName
|
||||
onNationUpdate(selectionOption)
|
||||
expandedNation = false
|
||||
},
|
||||
@ -245,7 +242,7 @@ private fun Constructor(
|
||||
}
|
||||
Spacer(Modifier.height(10.dp))
|
||||
TextField(
|
||||
value = price,
|
||||
value = tankUiState.tankDetails.price.toString(),
|
||||
placeholder = { Text(text = "Стоимость", color = CustomDark) },
|
||||
onValueChange = { onUpdate(tankUiState.tankDetails.copy(price = it.toInt())) },
|
||||
modifier = Modifier
|
||||
@ -267,7 +264,7 @@ private fun Constructor(
|
||||
containerColor = CustomOrange,
|
||||
contentColor = Color.Black
|
||||
),
|
||||
onClick = { }) {
|
||||
onClick = { onClick() }) {
|
||||
//"${student.firstName} ${student.lastName}"
|
||||
Text(text = stringResource(id = R.string.save_account_button), fontSize = 20.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user