Промежуточное.
This commit is contained in:
parent
552b40b3d9
commit
3e81ac477d
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.
Binary file not shown.
@ -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)
|
|
||||||
|
|
||||||
|
|
@ -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)
|
|
||||||
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
package ru.ulstu.`is`.pmu.tank.dao
|
package ru.ulstu.`is`.pmu.tank.dao
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
import androidx.room.Delete
|
||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
@ -8,8 +7,6 @@ import androidx.room.Query
|
|||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import kotlinx.coroutines.flow.Flow
|
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.User
|
||||||
import ru.ulstu.`is`.pmu.tank.model.UserTankCrossRef
|
import ru.ulstu.`is`.pmu.tank.model.UserTankCrossRef
|
||||||
import ru.ulstu.`is`.pmu.tank.model.UserWithTanks
|
import ru.ulstu.`is`.pmu.tank.model.UserWithTanks
|
||||||
@ -21,7 +18,8 @@ interface UserDao {
|
|||||||
|
|
||||||
//получить нации с танками
|
//получить нации с танками
|
||||||
@Query("SELECT * FROM users")
|
@Query("SELECT * FROM users")
|
||||||
fun getUsersWithTanks(): LiveData<List<UserWithTanks>>
|
@Transaction
|
||||||
|
fun getUsersWithTanks(): List<UserWithTanks>
|
||||||
|
|
||||||
//получить конкретного пользователя
|
//получить конкретного пользователя
|
||||||
@Query("select * from users where users.userId = :uid")
|
@Query("select * from users where users.userId = :uid")
|
||||||
|
@ -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 = "third-db"
|
private const val DB_NAME: String = "seven-db"
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
private var INSTANCE: AppDatabase? = null
|
private var INSTANCE: AppDatabase? = null
|
||||||
@ -116,11 +116,11 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
|
|
||||||
userDao.insert(user)
|
userDao.insert(user)
|
||||||
|
|
||||||
userDao.insert(UserTankCrossRef(user.userId ?: 0, tank1.tankId ?: 0))
|
userDao.insert(UserTankCrossRef(user.userId, tank1.tankId ?: 0))
|
||||||
userDao.insert(UserTankCrossRef(user.userId ?: 0, tank3.tankId ?: 0))
|
userDao.insert(UserTankCrossRef(user.userId, tank3.tankId ?: 0))
|
||||||
userDao.insert(UserTankCrossRef(user.userId ?: 0, tank5.tankId ?: 0))
|
userDao.insert(UserTankCrossRef(user.userId, tank5.tankId ?: 0))
|
||||||
userDao.insert(UserTankCrossRef(user.userId ?: 0, tank7.tankId ?: 0))
|
userDao.insert(UserTankCrossRef(user.userId, tank7.tankId ?: 0))
|
||||||
userDao.insert(UserTankCrossRef(user.userId ?: 0, tank9.tankId ?: 0))
|
userDao.insert(UserTankCrossRef(user.userId, tank9.tankId ?: 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,17 +3,15 @@ package ru.ulstu.`is`.pmu.tank.model
|
|||||||
import androidx.room.Embedded
|
import androidx.room.Embedded
|
||||||
import androidx.room.Junction
|
import androidx.room.Junction
|
||||||
import androidx.room.Relation
|
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(
|
data class TankWithUsers(
|
||||||
@Embedded val tank: Tank,
|
@Embedded var tank: Tank,
|
||||||
|
|
||||||
@Relation(
|
@Relation(
|
||||||
parentColumn = "tankId",
|
parentColumn = "tankId",
|
||||||
entityColumn = "userId",
|
entityColumn = "userId",
|
||||||
associateBy = Junction(UserTankCrossRef::class)
|
associateBy = Junction(UserTankCrossRef::class,)
|
||||||
)
|
)
|
||||||
val users: List<User>
|
var users: List<User>
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@ import androidx.room.PrimaryKey
|
|||||||
tableName = "users"
|
tableName = "users"
|
||||||
)
|
)
|
||||||
data class User (
|
data class User (
|
||||||
@PrimaryKey(autoGenerate = false)
|
@PrimaryKey(autoGenerate = true)
|
||||||
val userId: Long,
|
val userId: Long,
|
||||||
@ColumnInfo(name = "nickname")
|
@ColumnInfo(name = "nickname")
|
||||||
val nickname: String,
|
val nickname: String,
|
||||||
|
@ -2,31 +2,14 @@ package ru.ulstu.`is`.pmu.tank.model
|
|||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Ignore
|
||||||
import androidx.room.Index
|
import androidx.room.Index
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import org.jetbrains.annotations.NotNull
|
import org.jetbrains.annotations.NotNull
|
||||||
|
|
||||||
//many to many for user and tank
|
//many to many for user and tank
|
||||||
@Entity(primaryKeys = ["memberUserId", "memberTankId"],
|
@Entity(primaryKeys = ["userId", "tankId"])
|
||||||
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
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
data class UserTankCrossRef(
|
data class UserTankCrossRef(
|
||||||
var memberUserId: Long,
|
val userId: Long,
|
||||||
var memberTankId: Long
|
val tankId: Long
|
||||||
)
|
)
|
||||||
|
@ -7,17 +7,13 @@ import androidx.room.Relation
|
|||||||
|
|
||||||
//для работы many to many для получения списка танков для пользователя
|
//для работы many to many для получения списка танков для пользователя
|
||||||
data class UserWithTanks(
|
data class UserWithTanks(
|
||||||
@Embedded var user: User,
|
@Embedded val user: User,
|
||||||
|
|
||||||
@Relation(
|
@Relation(
|
||||||
entity = Tank::class,
|
entity = Tank::class,
|
||||||
parentColumn = "userId",
|
parentColumn = "userId",
|
||||||
entityColumn = "tankId",
|
entityColumn = "tankId",
|
||||||
associateBy = Junction(
|
associateBy = Junction(UserTankCrossRef::class,)
|
||||||
UserTankCrossRef::class,
|
|
||||||
parentColumn = "memberTankId",
|
|
||||||
entityColumn = "memberUserId"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
var tanks: List<Tank>
|
val tanks: List<Tank>
|
||||||
)
|
)
|
||||||
|
@ -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.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@ -22,6 +23,7 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.key
|
import androidx.compose.runtime.key
|
||||||
import androidx.compose.runtime.mutableStateListOf
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@ -58,15 +60,18 @@ fun Hangar(navController: NavController){
|
|||||||
val currentScreen = currentDestination?.route?.let { Screen.getItem(it) }
|
val currentScreen = currentDestination?.route?.let { Screen.getItem(it) }
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val users = remember { mutableStateListOf<UserWithTanks>() }
|
val list = remember { mutableStateListOf<UserWithTanks>() }
|
||||||
|
val (user, setUser) = remember { mutableStateOf<UserWithTanks?>(null) }
|
||||||
val nations = remember { mutableStateListOf<Nation>() }
|
val nations = remember { mutableStateListOf<Nation>() }
|
||||||
val levels = remember { mutableStateListOf<Level>() }
|
val levels = remember { mutableStateListOf<Level>() }
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
AppDatabase.getInstance(context).userDao().getUsersWithTanks().value?.forEach() { data ->
|
AppDatabase.getInstance(context).userDao().getUsersWithTanks().forEach { data ->
|
||||||
users.clear()
|
list.clear()
|
||||||
users.add(data)
|
list.add(data)
|
||||||
}
|
}
|
||||||
|
Log.d("КОЛИЧЕСТВО", list.size.toString())
|
||||||
|
setUser(AppDatabase.getInstance(context).userDao().getUserUid(100L))
|
||||||
AppDatabase.getInstance(context).nationDao().getAll().collect { data ->
|
AppDatabase.getInstance(context).nationDao().getAll().collect { data ->
|
||||||
nations.clear()
|
nations.clear()
|
||||||
nations.addAll(data)
|
nations.addAll(data)
|
||||||
@ -81,93 +86,89 @@ fun Hangar(navController: NavController){
|
|||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(15.dp)
|
verticalArrangement = Arrangement.spacedBy(15.dp)
|
||||||
) {
|
) {
|
||||||
users.forEach { user ->
|
val countRows = user?.tanks?.size?.div(2)
|
||||||
key(user.user.userId) {
|
|
||||||
val countRows = user.tanks.size / 2
|
|
||||||
|
|
||||||
//проверяем на то, что не всё поместилось в ряды по 2 элемента
|
//проверяем на то, что не всё поместилось в ряды по 2 элемента
|
||||||
val oneLastElem = user.tanks.size % 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){
|
for(n in 1 .. (supportCountRow ?: 1)){
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceAround,
|
horizontalArrangement = Arrangement.SpaceAround,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(10.dp, 0.dp, 10.dp, 0.dp)
|
.padding(10.dp, 0.dp, 10.dp, 0.dp)
|
||||||
|
) {
|
||||||
|
//цикл для заполнения строки карточек
|
||||||
|
for (m in 0 .. 1){
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.background(CustomYellow)
|
||||||
) {
|
) {
|
||||||
//цикл для заполнения строки карточек
|
Box(
|
||||||
for (m in 0 .. 1){
|
Modifier
|
||||||
Column(
|
.background(CustomYellow)
|
||||||
modifier = 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(
|
Image(
|
||||||
Modifier
|
painter = painterResource(id = user?.tanks?.get(index)?.image ?: R.drawable.t_34_85),
|
||||||
.background(CustomYellow)
|
contentDescription = stringResource(id = R.string.tanks_main_title),
|
||||||
.height(260.dp),
|
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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user