diff --git a/compose/.gradle/8.0/executionHistory/executionHistory.bin b/compose/.gradle/8.0/executionHistory/executionHistory.bin index 36d4c8b..5f7e818 100644 Binary files a/compose/.gradle/8.0/executionHistory/executionHistory.bin and b/compose/.gradle/8.0/executionHistory/executionHistory.bin differ diff --git a/compose/.gradle/8.0/executionHistory/executionHistory.lock b/compose/.gradle/8.0/executionHistory/executionHistory.lock index dbb7003..214e6c6 100644 Binary files a/compose/.gradle/8.0/executionHistory/executionHistory.lock and b/compose/.gradle/8.0/executionHistory/executionHistory.lock differ diff --git a/compose/.gradle/8.0/fileHashes/fileHashes.bin b/compose/.gradle/8.0/fileHashes/fileHashes.bin index 505d7b8..835e8b2 100644 Binary files a/compose/.gradle/8.0/fileHashes/fileHashes.bin and b/compose/.gradle/8.0/fileHashes/fileHashes.bin differ diff --git a/compose/.gradle/8.0/fileHashes/fileHashes.lock b/compose/.gradle/8.0/fileHashes/fileHashes.lock index f29984c..fa71d1b 100644 Binary files a/compose/.gradle/8.0/fileHashes/fileHashes.lock and b/compose/.gradle/8.0/fileHashes/fileHashes.lock differ diff --git a/compose/.gradle/8.0/fileHashes/resourceHashesCache.bin b/compose/.gradle/8.0/fileHashes/resourceHashesCache.bin index 5fe73ee..aff60ae 100644 Binary files a/compose/.gradle/8.0/fileHashes/resourceHashesCache.bin and b/compose/.gradle/8.0/fileHashes/resourceHashesCache.bin differ diff --git a/compose/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/compose/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 6cc246c..e4de179 100644 Binary files a/compose/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/compose/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/compose/.gradle/buildOutputCleanup/outputFiles.bin b/compose/.gradle/buildOutputCleanup/outputFiles.bin index da8f9fd..42d56f6 100644 Binary files a/compose/.gradle/buildOutputCleanup/outputFiles.bin and b/compose/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/compose/.gradle/file-system.probe b/compose/.gradle/file-system.probe index 043d3db..9afcdae 100644 Binary files a/compose/.gradle/file-system.probe and b/compose/.gradle/file-system.probe differ diff --git a/compose/.gradle/kotlin/errors/errors-1699722221246.log b/compose/.gradle/kotlin/errors/errors-1699722221246.log deleted file mode 100644 index 9d102ef..0000000 --- a/compose/.gradle/kotlin/errors/errors-1699722221246.log +++ /dev/null @@ -1,42 +0,0 @@ -kotlin version: 1.8.20 -error message: java.lang.NoSuchMethodError: 'kotlin.sequences.Sequence com.google.devtools.ksp.processing.Resolver.getPackagesWithAnnotation(java.lang.String)' - at androidx.room.compiler.processing.ksp.KspRoundEnv.getElementsAnnotatedWith(KspRoundEnv.kt:107) - at androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:100) - at androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$6$1.invoke(KotlinSymbolProcessingExtension.kt:291) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$6$1.invoke(KotlinSymbolProcessingExtension.kt:289) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:394) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:289) - at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:123) - at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:257) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42) - at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:248) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:88) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47) - at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168) - at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53) - at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100) - at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46) - at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101) - at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1486) - at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) - at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) - at java.base/java.lang.reflect.Method.invoke(Method.java:568) - at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360) - at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) - at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) - at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) - at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) - at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587) - at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828) - at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705) - at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) - at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704) - at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) - at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) - at java.base/java.lang.Thread.run(Thread.java:833) - - diff --git a/compose/.gradle/kotlin/errors/errors-1699722385060.log b/compose/.gradle/kotlin/errors/errors-1699722385060.log deleted file mode 100644 index 9d102ef..0000000 --- a/compose/.gradle/kotlin/errors/errors-1699722385060.log +++ /dev/null @@ -1,42 +0,0 @@ -kotlin version: 1.8.20 -error message: java.lang.NoSuchMethodError: 'kotlin.sequences.Sequence com.google.devtools.ksp.processing.Resolver.getPackagesWithAnnotation(java.lang.String)' - at androidx.room.compiler.processing.ksp.KspRoundEnv.getElementsAnnotatedWith(KspRoundEnv.kt:107) - at androidx.room.compiler.processing.CommonProcessorDelegate.processRound(XBasicAnnotationProcessor.kt:100) - at androidx.room.compiler.processing.ksp.KspBasicAnnotationProcessor.process(KspBasicAnnotationProcessor.kt:62) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$6$1.invoke(KotlinSymbolProcessingExtension.kt:291) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$6$1.invoke(KotlinSymbolProcessingExtension.kt:289) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:394) - at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:289) - at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:123) - at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:99) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:257) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:42) - at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:115) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:248) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:88) - at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47) - at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:168) - at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53) - at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:100) - at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:46) - at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101) - at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1486) - at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) - at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) - at java.base/java.lang.reflect.Method.invoke(Method.java:568) - at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360) - at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200) - at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197) - at java.base/java.security.AccessController.doPrivileged(AccessController.java:712) - at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196) - at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587) - at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828) - at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705) - at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) - at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704) - at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) - at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) - at java.base/java.lang.Thread.run(Thread.java:833) - - diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/dao/UserDao.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/dao/UserDao.kt index 5e4b411..fa80c55 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/dao/UserDao.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/dao/UserDao.kt @@ -1,6 +1,5 @@ package ru.ulstu.`is`.pmu.tank.dao -import androidx.lifecycle.LiveData import androidx.room.Dao import androidx.room.Delete import androidx.room.Insert @@ -8,8 +7,6 @@ import androidx.room.Query import androidx.room.Transaction import androidx.room.Update import kotlinx.coroutines.flow.Flow -import ru.ulstu.`is`.pmu.tank.model.Nation -import ru.ulstu.`is`.pmu.tank.model.NationWithTanks import ru.ulstu.`is`.pmu.tank.model.User import ru.ulstu.`is`.pmu.tank.model.UserTankCrossRef import ru.ulstu.`is`.pmu.tank.model.UserWithTanks @@ -21,7 +18,8 @@ interface UserDao { //получить нации с танками @Query("SELECT * FROM users") - fun getUsersWithTanks(): LiveData> + @Transaction + fun getUsersWithTanks(): List //получить конкретного пользователя @Query("select * from users where users.userId = :uid") diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/database/AppDatabase.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/database/AppDatabase.kt index 794fd31..ef321a9 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/database/AppDatabase.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/database/AppDatabase.kt @@ -29,7 +29,7 @@ abstract class AppDatabase : RoomDatabase() { abstract fun userDao() : UserDao companion object { - private const val DB_NAME: String = "third-db" + private const val DB_NAME: String = "seven-db" @Volatile private var INSTANCE: AppDatabase? = null @@ -116,11 +116,11 @@ abstract class AppDatabase : RoomDatabase() { userDao.insert(user) - userDao.insert(UserTankCrossRef(user.userId ?: 0, tank1.tankId ?: 0)) - userDao.insert(UserTankCrossRef(user.userId ?: 0, tank3.tankId ?: 0)) - userDao.insert(UserTankCrossRef(user.userId ?: 0, tank5.tankId ?: 0)) - userDao.insert(UserTankCrossRef(user.userId ?: 0, tank7.tankId ?: 0)) - userDao.insert(UserTankCrossRef(user.userId ?: 0, tank9.tankId ?: 0)) + userDao.insert(UserTankCrossRef(user.userId, tank1.tankId ?: 0)) + userDao.insert(UserTankCrossRef(user.userId, tank3.tankId ?: 0)) + userDao.insert(UserTankCrossRef(user.userId, tank5.tankId ?: 0)) + userDao.insert(UserTankCrossRef(user.userId, tank7.tankId ?: 0)) + userDao.insert(UserTankCrossRef(user.userId, tank9.tankId ?: 0)) } } diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/TankWithUsers.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/TankWithUsers.kt index 4c41319..2a8edda 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/TankWithUsers.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/TankWithUsers.kt @@ -3,17 +3,15 @@ package ru.ulstu.`is`.pmu.tank.model import androidx.room.Embedded import androidx.room.Junction import androidx.room.Relation -import ru.ulstu.`is`.pmu.tank.model.Tank -import ru.ulstu.`is`.pmu.tank.model.User -import ru.ulstu.`is`.pmu.tank.model.UserTankCrossRef +//для работы many to many для получения списка танков для пользователя data class TankWithUsers( - @Embedded val tank: Tank, + @Embedded var tank: Tank, @Relation( parentColumn = "tankId", entityColumn = "userId", - associateBy = Junction(UserTankCrossRef::class) + associateBy = Junction(UserTankCrossRef::class,) ) - val users: List + var users: List ) diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/User.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/User.kt index 914c867..67c1314 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/User.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/User.kt @@ -9,7 +9,7 @@ import androidx.room.PrimaryKey tableName = "users" ) data class User ( - @PrimaryKey(autoGenerate = false) + @PrimaryKey(autoGenerate = true) val userId: Long, @ColumnInfo(name = "nickname") val nickname: String, diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserTankCrossRef.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserTankCrossRef.kt index ccbfc97..f1869f5 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserTankCrossRef.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserTankCrossRef.kt @@ -2,31 +2,14 @@ package ru.ulstu.`is`.pmu.tank.model import androidx.room.Entity import androidx.room.ForeignKey +import androidx.room.Ignore import androidx.room.Index import androidx.room.PrimaryKey import org.jetbrains.annotations.NotNull //many to many for user and tank -@Entity(primaryKeys = ["memberUserId", "memberTankId"], - indices = [Index(value = ["memberTankId"], unique = false)], - foreignKeys = [ - ForeignKey( - entity = User::class, - parentColumns = ["userId"], - childColumns = ["memberUserId"], - onDelete = ForeignKey.CASCADE, - onUpdate = ForeignKey.CASCADE - ), - ForeignKey( - entity = Tank::class, - parentColumns = ["tankId"], - childColumns = ["memberTankId"], - onDelete = ForeignKey.CASCADE, - onUpdate = ForeignKey.CASCADE - ) - ] -) +@Entity(primaryKeys = ["userId", "tankId"]) data class UserTankCrossRef( - var memberUserId: Long, - var memberTankId: Long + val userId: Long, + val tankId: Long ) diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserWithTanks.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserWithTanks.kt index 483e7a3..0e86a7d 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserWithTanks.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tank/model/UserWithTanks.kt @@ -7,17 +7,13 @@ import androidx.room.Relation //для работы many to many для получения списка танков для пользователя data class UserWithTanks( - @Embedded var user: User, + @Embedded val user: User, @Relation( entity = Tank::class, parentColumn = "userId", entityColumn = "tankId", - associateBy = Junction( - UserTankCrossRef::class, - parentColumn = "memberTankId", - entityColumn = "memberUserId" - ) + associateBy = Junction(UserTankCrossRef::class,) ) - var tanks: List + val tanks: List ) diff --git a/compose/app/src/main/java/ru/ulstu/is/pmu/tanks/composeui/Hangar.kt b/compose/app/src/main/java/ru/ulstu/is/pmu/tanks/composeui/Hangar.kt index 8afcf1e..8455542 100644 --- a/compose/app/src/main/java/ru/ulstu/is/pmu/tanks/composeui/Hangar.kt +++ b/compose/app/src/main/java/ru/ulstu/is/pmu/tanks/composeui/Hangar.kt @@ -1,6 +1,7 @@ package ru.ulstu.`is`.pmu.tanks.composeui import android.content.res.Configuration +import android.util.Log import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -22,6 +23,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -58,15 +60,18 @@ fun Hangar(navController: NavController){ val currentScreen = currentDestination?.route?.let { Screen.getItem(it) } val context = LocalContext.current - val users = remember { mutableStateListOf() } + val list = remember { mutableStateListOf() } + val (user, setUser) = remember { mutableStateOf(null) } val nations = remember { mutableStateListOf() } val levels = remember { mutableStateListOf() } LaunchedEffect(Unit) { withContext(Dispatchers.IO) { - AppDatabase.getInstance(context).userDao().getUsersWithTanks().value?.forEach() { data -> - users.clear() - users.add(data) + AppDatabase.getInstance(context).userDao().getUsersWithTanks().forEach { data -> + list.clear() + list.add(data) } + Log.d("КОЛИЧЕСТВО", list.size.toString()) + setUser(AppDatabase.getInstance(context).userDao().getUserUid(100L)) AppDatabase.getInstance(context).nationDao().getAll().collect { data -> nations.clear() nations.addAll(data) @@ -81,93 +86,89 @@ fun Hangar(navController: NavController){ Column( verticalArrangement = Arrangement.spacedBy(15.dp) ) { - users.forEach { user -> - key(user.user.userId) { - val countRows = user.tanks.size / 2 + val countRows = user?.tanks?.size?.div(2) - //проверяем на то, что не всё поместилось в ряды по 2 элемента - val oneLastElem = user.tanks.size % 2 + //проверяем на то, что не всё поместилось в ряды по 2 элемента + val oneLastElem = user?.tanks?.size?.rem(2) - var index = 0 + var index = 0 - var supportCountRow = countRows + var supportCountRow = countRows - for(n in 1 .. supportCountRow){ - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceAround, - modifier = Modifier - .fillMaxWidth() - .padding(10.dp, 0.dp, 10.dp, 0.dp) + for(n in 1 .. (supportCountRow ?: 1)){ + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceAround, + modifier = Modifier + .fillMaxWidth() + .padding(10.dp, 0.dp, 10.dp, 0.dp) + ) { + //цикл для заполнения строки карточек + for (m in 0 .. 1){ + Column( + modifier = Modifier.background(CustomYellow) ) { - //цикл для заполнения строки карточек - for (m in 0 .. 1){ - Column( - modifier = Modifier.background(CustomYellow) + Box( + Modifier + .background(CustomYellow) + .height(260.dp), + ) + { + Card( + colors = CardDefaults.cardColors( + containerColor = CustomYellow, + ), + modifier = Modifier + .size(width = 170.dp, height = 250.dp) + .padding(10.dp, 0.dp, 10.dp, 0.dp) ) { - Box( - Modifier - .background(CustomYellow) - .height(260.dp), + Image( + painter = painterResource(id = user?.tanks?.get(index)?.image ?: R.drawable.t_34_85), + contentDescription = stringResource(id = R.string.tanks_main_title), + modifier = Modifier + .height(130.dp) + ) + Text( + text = user?.tanks?.get(index)?.name ?: "" , + fontSize = 20.sp, + fontWeight = FontWeight.Bold, + color = Color.Black, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() + ) + Text( + text = "Нация: " + nations.find{ it.uid == user?.tanks?.get(index)?.nationId }.toString(), + fontSize = 17.sp, + fontWeight = FontWeight.Bold, + color = Color.Black, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() + ) + Text( + text = "Уровень: " + levels.find{ it.uid == user?.tanks?.get(index)?.levelId }.toString(), + fontSize = 17.sp, + fontWeight = FontWeight.Bold, + color = Color.Black, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() + ) + Text( + text = "Стоимость: " + user?.tanks?.get(index)?.price.toString(), + fontSize = 17.sp, + fontWeight = FontWeight.Bold, + color = Color.Black, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() ) - { - Card( - colors = CardDefaults.cardColors( - containerColor = CustomYellow, - ), - modifier = Modifier - .size(width = 170.dp, height = 250.dp) - .padding(10.dp, 0.dp, 10.dp, 0.dp) - ) { - Image( - painter = painterResource(id = user.tanks[index].image), - contentDescription = stringResource(id = R.string.tanks_main_title), - modifier = Modifier - .height(130.dp) - ) - Text( - text = user.tanks[index].name, - fontSize = 20.sp, - fontWeight = FontWeight.Bold, - color = Color.Black, - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - Text( - text = "Нация: " + nations.find{ it.uid == user.tanks[index].nationId }.toString(), - fontSize = 17.sp, - fontWeight = FontWeight.Bold, - color = Color.Black, - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - Text( - text = "Уровень: " + levels.find{ it.uid == user.tanks[index].levelId }.toString(), - fontSize = 17.sp, - fontWeight = FontWeight.Bold, - color = Color.Black, - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - Text( - text = "Стоимость: " + user.tanks[index].price.toString(), - fontSize = 17.sp, - fontWeight = FontWeight.Bold, - color = Color.Black, - textAlign = TextAlign.Center, - modifier = Modifier.fillMaxWidth() - ) - } - } - } - index++ - - //если надо будет допечатать ещё один элемент - if(n == supportCountRow && oneLastElem != 0){ - supportCountRow = oneLastElem } } } + index++ + //если надо будет допечатать ещё один элемент + if(n == supportCountRow && oneLastElem != 0){ + supportCountRow = oneLastElem + } + } } }