Шишь
This commit is contained in:
parent
0db26bb7a2
commit
e0575621c4
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.
@ -52,7 +52,7 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
abstract fun remoteKeysDao(): RemoteKeysDao
|
abstract fun remoteKeysDao(): RemoteKeysDao
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val DB_NAME: String = "24-db"
|
private const val DB_NAME: String = "25-db"
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var INSTANCE: AppDatabase? = null
|
private var INSTANCE: AppDatabase? = null
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
package ru.ulstu.`is`.pmu.tanks.composeui
|
package ru.ulstu.`is`.pmu.tanks.composeui
|
||||||
|
|
||||||
|
import android.widget.TableRow
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.defaultMinSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.Card
|
||||||
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.DatePicker
|
import androidx.compose.material3.DatePicker
|
||||||
import androidx.compose.material3.DisplayMode
|
import androidx.compose.material3.DisplayMode
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
@ -27,10 +34,12 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.TextUnit
|
import androidx.compose.ui.unit.TextUnit
|
||||||
import androidx.compose.ui.unit.TextUnitType
|
import androidx.compose.ui.unit.TextUnitType
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.application.ui.toBitmap
|
import com.application.ui.toBitmap
|
||||||
@ -40,7 +49,9 @@ import ru.ulstu.`is`.pmu.tank.composeui.ApiStatus
|
|||||||
import ru.ulstu.`is`.pmu.tank.composeui.edit.ReportViewModel
|
import ru.ulstu.`is`.pmu.tank.composeui.edit.ReportViewModel
|
||||||
import ru.ulstu.`is`.pmu.tank.model.Report
|
import ru.ulstu.`is`.pmu.tank.model.Report
|
||||||
import ru.ulstu.`is`.pmu.tanks.composeui.image.CuteImage
|
import ru.ulstu.`is`.pmu.tanks.composeui.image.CuteImage
|
||||||
|
import ru.ulstu.`is`.pmu.tanks.composeui.image.RoundedCorderImage
|
||||||
import ru.ulstu.`is`.pmu.ui.AppViewModelProvider
|
import ru.ulstu.`is`.pmu.ui.AppViewModelProvider
|
||||||
|
import ru.ulstu.`is`.pmu.ui.theme.CustomDark
|
||||||
import ru.ulstu.`is`.pmu.ui.theme.CustomRed
|
import ru.ulstu.`is`.pmu.ui.theme.CustomRed
|
||||||
import ru.ulstu.`is`.pmu.ui.theme.CustomYellow
|
import ru.ulstu.`is`.pmu.ui.theme.CustomYellow
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@ -56,6 +67,7 @@ fun Report (navController: NavController?,viewModel: ReportViewModel = viewModel
|
|||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
val reportResultPageState = viewModel.reportResultPageUiState
|
val reportResultPageState = viewModel.reportResultPageUiState
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier.background(CustomYellow),
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
)
|
)
|
||||||
@ -67,6 +79,7 @@ fun Report (navController: NavController?,viewModel: ReportViewModel = viewModel
|
|||||||
DatePicker(
|
DatePicker(
|
||||||
state = dateStateStart,
|
state = dateStateStart,
|
||||||
)
|
)
|
||||||
|
|
||||||
val selectedDateStart = dateStateStart.selectedDateMillis
|
val selectedDateStart = dateStateStart.selectedDateMillis
|
||||||
if (selectedDateStart != null) {
|
if (selectedDateStart != null) {
|
||||||
val resultDate= Date(selectedDateStart)
|
val resultDate= Date(selectedDateStart)
|
||||||
@ -76,6 +89,7 @@ fun Report (navController: NavController?,viewModel: ReportViewModel = viewModel
|
|||||||
{
|
{
|
||||||
viewModel.onUpdate(viewModel.reportPageUiState.reportDetails.copy(startDate = Date(0)))
|
viewModel.onUpdate(viewModel.reportPageUiState.reportDetails.copy(startDate = Date(0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = "Конец периода",
|
text = "Конец периода",
|
||||||
style = MaterialTheme.typography.headlineLarge
|
style = MaterialTheme.typography.headlineLarge
|
||||||
@ -83,6 +97,7 @@ fun Report (navController: NavController?,viewModel: ReportViewModel = viewModel
|
|||||||
DatePicker(
|
DatePicker(
|
||||||
state = dateStateEnd,
|
state = dateStateEnd,
|
||||||
)
|
)
|
||||||
|
|
||||||
val selectedDateEnd = dateStateEnd.selectedDateMillis
|
val selectedDateEnd = dateStateEnd.selectedDateMillis
|
||||||
if (selectedDateEnd != null) {
|
if (selectedDateEnd != null) {
|
||||||
val resultDate = Date(selectedDateEnd)
|
val resultDate = Date(selectedDateEnd)
|
||||||
@ -92,6 +107,7 @@ fun Report (navController: NavController?,viewModel: ReportViewModel = viewModel
|
|||||||
{
|
{
|
||||||
viewModel.onUpdate(viewModel.reportPageUiState.reportDetails.copy(endDate = Date(0)))
|
viewModel.onUpdate(viewModel.reportPageUiState.reportDetails.copy(endDate = Date(0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Button(
|
Button(
|
||||||
onClick = {coroutineScope.launch { viewModel.getReport() } },
|
onClick = {coroutineScope.launch { viewModel.getReport() } },
|
||||||
@ -112,6 +128,7 @@ fun Report (navController: NavController?,viewModel: ReportViewModel = viewModel
|
|||||||
text = "Результат",
|
text = "Результат",
|
||||||
style = MaterialTheme.typography.headlineLarge
|
style = MaterialTheme.typography.headlineLarge
|
||||||
)
|
)
|
||||||
|
|
||||||
if(reportResultPageState.resReport != null){
|
if(reportResultPageState.resReport != null){
|
||||||
TableScreen(reportData = reportResultPageState.resReport!!)
|
TableScreen(reportData = reportResultPageState.resReport!!)
|
||||||
}
|
}
|
||||||
@ -172,60 +189,156 @@ fun ErrorPlaceholder(message: String, onBack: () -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun RowScope.TableCell(
|
|
||||||
text: String,
|
|
||||||
weight: Float
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = text,
|
|
||||||
Modifier
|
|
||||||
.border(1.dp, Color.Black)
|
|
||||||
.weight(weight)
|
|
||||||
.padding(8.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TableScreen(reportData: Report) {
|
fun TableScreen(reportData: Report) {
|
||||||
|
|
||||||
val column1Weight = .3f // 30%
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.padding(16.dp)) {
|
.padding(16.dp)) {
|
||||||
|
|
||||||
Row(Modifier.background(Color.Gray)) {
|
Row(
|
||||||
TableCell(text = "Название танка:", weight = column1Weight)
|
Modifier
|
||||||
TableCell(text = "Стоимость танка:", weight = column1Weight)
|
.background(CustomDark)
|
||||||
//TableCell(text = "Изображение:", weight = column1Weight)
|
.padding(10.dp, 10.dp, 10.dp, 10.dp)) {
|
||||||
TableCell(text = "Уровень:", weight = column1Weight)
|
Card(
|
||||||
TableCell(text = "Нация:", weight = column1Weight)
|
colors = CardDefaults.cardColors(
|
||||||
TableCell(text = "Кол-во покупок:", weight = column1Weight)
|
containerColor = CustomYellow,
|
||||||
|
),
|
||||||
TableCell(text = "Самый популярный уровень:", weight = column1Weight)
|
modifier = Modifier
|
||||||
TableCell(text = "Кол-во покупок:", weight = column1Weight)
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
|
) {
|
||||||
TableCell(text = "Самая популярная нация:", weight = column1Weight)
|
Column {
|
||||||
TableCell(text = "Кол-во покупок:", weight = column1Weight)
|
Text(
|
||||||
|
text = "Самый популярный танк:",
|
||||||
|
fontSize = 30.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
RoundedCorderImage(
|
||||||
|
imageBitmap = reportData.miniature.asImageBitmap(),
|
||||||
|
modifier = Modifier.fillMaxWidth().fillMaxHeight()
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
Text(
|
||||||
|
text = reportData.tankName,
|
||||||
|
fontSize = 30.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Нация: " + reportData.tankNation,
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Уровень: " + reportData.tankLevel.toString(),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Стоимость: " + reportData.price.toString(),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Покупок за период: " + reportData.countTankPurchase.toString(),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.background(CustomDark)
|
||||||
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Card(
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = CustomYellow,
|
||||||
|
),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxHeight()
|
||||||
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Самый популярный уровень: " + reportData.level.toString(),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Покупок за период: " + reportData.countLevelPurchase.toString(),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.height(10.dp))
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.background(CustomDark)
|
||||||
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
|
) {
|
||||||
|
Card(
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = CustomYellow,
|
||||||
|
),
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
|
|
||||||
// Here are all the lines of your table.
|
) {
|
||||||
Row(Modifier.fillMaxWidth()) {
|
Column(
|
||||||
TableCell(text = reportData.tankName, weight = column1Weight)
|
modifier = Modifier.fillMaxHeight()
|
||||||
TableCell(text = reportData.price.toString(), weight = column1Weight)
|
.padding(10.dp, 10.dp, 10.dp, 10.dp),
|
||||||
CuteImage(
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
imageBitmap = reportData.miniature.asImageBitmap(),
|
verticalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier.fillMaxWidth()
|
) {
|
||||||
)
|
Text(
|
||||||
TableCell(text = reportData.tankLevel.toString(), weight = column1Weight)
|
text = "Самая популярная нация: " + reportData.nationName,
|
||||||
TableCell(text = reportData.tankNation, weight = column1Weight)
|
fontSize = 20.sp,
|
||||||
TableCell(text = reportData.countTankPurchase.toString(), weight = column1Weight)
|
fontWeight = FontWeight.Bold,
|
||||||
TableCell(text = reportData.level.toString(), weight = column1Weight)
|
color = Color.Black,
|
||||||
TableCell(text = reportData.countLevelPurchase.toString(), weight = column1Weight)
|
textAlign = TextAlign.Center
|
||||||
TableCell(text = reportData.nationName, weight = column1Weight)
|
)
|
||||||
TableCell(text = reportData.countNationPurchase.toString(), weight = column1Weight)
|
Text(
|
||||||
|
text = "Покупок за период: " + reportData.countNationPurchase.toString(),
|
||||||
|
fontSize = 20.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = Color.Black,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -37,7 +37,7 @@ module.exports = (req, res, next) => {
|
|||||||
//нашли самый популярный танк
|
//нашли самый популярный танк
|
||||||
const supportTank = data.tanks.find(tank => tank.id === tankList[0].tankId);
|
const supportTank = data.tanks.find(tank => tank.id === tankList[0].tankId);
|
||||||
const supportLevel = data.levels.find(level => level.id === supportTank.levelId).level;
|
const supportLevel = data.levels.find(level => level.id === supportTank.levelId).level;
|
||||||
const supportNation = data.nations.find(nation => nation.id === supportTank.levelId).nationName;
|
const supportNation = data.nations.find(nation => nation.id === supportTank.nationId).nationName;
|
||||||
|
|
||||||
const popularTank = {
|
const popularTank = {
|
||||||
id: supportTank.id,
|
id: supportTank.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user