Filter is working!

This commit is contained in:
ElEgEv 2023-12-11 17:08:55 +04:00
parent b0fbd2704f
commit 61d31fee9c
12 changed files with 56 additions and 2 deletions

46
compose/.idea/assetWizardSettings.xml generated Normal file
View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WizardSettings">
<option name="children">
<map>
<entry key="vectorWizard">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="vectorAssetStep">
<value>
<PersistentState>
<option name="children">
<map>
<entry key="clipartAsset">
<value>
<PersistentState>
<option name="values">
<map>
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/drive_file_rename_outline/baseline_drive_file_rename_outline_24.xml" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
<option name="values">
<map>
<entry key="outputName" value="baseline_drive_file_rename_outline_24" />
<entry key="sourceFile" value="C:\Users\egore\Desktop\MyProjects\ULSTU\TankAppMobile\TanksApp\compose" />
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</PersistentState>
</value>
</entry>
</map>
</option>
</component>
</project>

View File

@ -154,7 +154,7 @@ fun ColumnItem(
colors = ButtonDefaults.buttonColors(
containerColor = CustomRed,
contentColor = CustomDark),
onClick = { }
onClick = { onClick(tank.tankId) }
) {
//navController?.navigate(Screen.Hangar.route)
//navController?.navigate(studentId)

View File

@ -15,7 +15,7 @@ class TankListViewModel(
private val tankRepository: TankRepository,
private var userId: Long = 100L
) : ViewModel() {
val tankListUiState: StateFlow<TankListUiState> = tankRepository.getAll().map {
val tankListUiState: StateFlow<TankListUiState> = tankRepository.getForUserAll(userId).map {
TankListUiState(it)
}.stateIn(
scope = viewModelScope,

View File

@ -35,6 +35,11 @@ interface TankDao {
)
fun getUserTanks(uid: Long): Flow<List<TankWithNationAndLevel>>
@Query(
"SELECT t.* FROM tanks AS t WHERE t.tankId NOT IN (SELECT ut.tankId FROM UserTankCrossRef AS ut WHERE ut.userId = :uid)"
)
fun getNotUserTank(uid: Long): Flow<List<Tank>>
@Insert
suspend fun insert(tank: Tank)

View File

@ -15,6 +15,8 @@ class OfflineTankRepository(
) : TankRepository {
override fun getAll(): Flow<List<Tank>> = tankDao.getAll()
override fun getForUserAll(userId: Long): Flow<List<Tank>> = tankDao.getNotUserTank(userId)
override fun getTank(uid: Long): Flow<Tank?> = tankDao.getTankUid(uid)
override fun getUserTanks(uid: Long): Flow<List<TankWithNationAndLevel>> = tankDao.getUserTanks(uid)

View File

@ -8,6 +8,7 @@ import ru.ulstu.`is`.pmu.tank.model.TankWithNationAndLevel
interface TankRepository {
fun getAll(): Flow<List<Tank>>
fun getForUserAll(userId: Long): Flow<List<Tank>>
fun getTank(uid: Long): Flow<Tank?>
fun getUserTanks(uid: Long): Flow<List<TankWithNationAndLevel>>
suspend fun insertTank(tank: Tank, image: Bitmap)