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