папочка
This commit is contained in:
parent
68d533c81b
commit
f977aa8f09
@ -1,8 +1,8 @@
|
|||||||
package com.example.myapplication
|
package com.example.myapplication
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.example.myapplication.database.AppContainer
|
import com.example.myapplication.database.room.repository.AppContainer
|
||||||
import com.example.myapplication.database.AppDataContainer
|
import com.example.myapplication.database.room.repository.AppDataContainer
|
||||||
|
|
||||||
class BikeApplication : Application() {
|
class BikeApplication : Application() {
|
||||||
lateinit var container: AppContainer
|
lateinit var container: AppContainer
|
||||||
|
@ -9,8 +9,8 @@ import androidx.compose.material3.Surface
|
|||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import com.example.myapplication.composeui.navigation.MainNavbar
|
import com.example.myapplication.ui.navigation.MainNavbar
|
||||||
import com.example.myapplication.datastore.DataStoreManager
|
import com.example.myapplication.setting.DataStoreManager
|
||||||
import com.example.myapplication.ui.theme.PmudemoTheme
|
import com.example.myapplication.ui.theme.PmudemoTheme
|
||||||
|
|
||||||
class MainComposeActivity : ComponentActivity() {
|
class MainComposeActivity : ComponentActivity() {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.example.myapplication.api
|
package com.example.myapplication.api
|
||||||
|
|
||||||
import com.example.myapplication.api.bike.BikeRemote
|
import com.example.myapplication.api.bike.remote.BikeRemote
|
||||||
import com.example.myapplication.api.rent.RentRemote
|
import com.example.myapplication.api.rent.remote.RentRemote
|
||||||
import com.example.myapplication.api.item.ItemFromBikeRemote
|
import com.example.myapplication.api.item.remote.ItemFromBikeRemote
|
||||||
import com.example.myapplication.api.item.ItemRemote
|
import com.example.myapplication.api.item.remote.ItemRemote
|
||||||
import com.example.myapplication.api.item.ItemWithBikeRemote
|
import com.example.myapplication.api.item.remote.ItemWithBikeRemote
|
||||||
import com.example.myapplication.api.report.ReportRemote
|
import com.example.myapplication.api.report.remote.ReportRemote
|
||||||
import com.example.myapplication.api.user.UserRemote
|
import com.example.myapplication.api.user.remote.UserRemote
|
||||||
|
import com.example.myapplication.setting.LocalDateTimeSerializer
|
||||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.modules.SerializersModule
|
import kotlinx.serialization.modules.SerializersModule
|
||||||
@ -147,9 +148,9 @@ interface MyServerService {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
//Раздача с тлф
|
//Раздача с тлф
|
||||||
private const val BASE_URL = "http://192.168.138.47:8079/"
|
/* private const val BASE_URL = "http://192.168.138.47:8079/"*/
|
||||||
//Пк дома
|
//Пк дома
|
||||||
/*private const val BASE_URL = "http://192.168.0.104:8079/"*/
|
private const val BASE_URL = "http://192.168.0.104:8079/"
|
||||||
//private const val BASE_URL = "http://10.0.2.2:8079/"
|
//private const val BASE_URL = "http://10.0.2.2:8079/"
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
@ -165,9 +166,9 @@ interface MyServerService {
|
|||||||
serializersModule = SerializersModule {
|
serializersModule = SerializersModule {
|
||||||
contextual(LocalDateTimeSerializer)
|
contextual(LocalDateTimeSerializer)
|
||||||
}
|
}
|
||||||
} // Создаем экземпляр Json с ignoreUnknownKeys = true
|
}
|
||||||
return Retrofit.Builder().baseUrl(BASE_URL).client(client)
|
return Retrofit.Builder().baseUrl(BASE_URL).client(client)
|
||||||
.addConverterFactory(json.asConverterFactory("application/json".toMediaType())) // Применяем конфигурацию Json
|
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
|
||||||
.build().create(MyServerService::class.java).also { INSTANCE = it }
|
.build().create(MyServerService::class.java).also { INSTANCE = it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.bike
|
package com.example.myapplication.api.bike.mediator
|
||||||
|
|
||||||
import androidx.paging.ExperimentalPagingApi
|
import androidx.paging.ExperimentalPagingApi
|
||||||
import androidx.paging.LoadType
|
import androidx.paging.LoadType
|
||||||
@ -6,14 +6,15 @@ import androidx.paging.PagingState
|
|||||||
import androidx.paging.RemoteMediator
|
import androidx.paging.RemoteMediator
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.item.toItem
|
import com.example.myapplication.api.bike.remote.toBike
|
||||||
|
import com.example.myapplication.api.item.remote.toItem
|
||||||
import com.example.myapplication.database.AppDatabase
|
import com.example.myapplication.database.AppDatabase
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
|
||||||
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
|
|
||||||
import com.example.myapplication.database.entities.repository.OfflineItemRepository
|
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeyType
|
import com.example.myapplication.database.remotekeys.model.RemoteKeyType
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
||||||
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
|
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
|
||||||
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
|
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
|
||||||
|
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package com.example.myapplication.api.bike
|
package com.example.myapplication.api.bike.remote
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.bike
|
package com.example.myapplication.api.bike.repository
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.paging.ExperimentalPagingApi
|
import androidx.paging.ExperimentalPagingApi
|
||||||
@ -6,15 +6,18 @@ import androidx.paging.Pager
|
|||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.database.AppContainer
|
import com.example.myapplication.api.bike.mediator.BikeRemoteMediator
|
||||||
|
import com.example.myapplication.api.bike.remote.toBike
|
||||||
|
import com.example.myapplication.api.bike.remote.toBikeRemote
|
||||||
|
import com.example.myapplication.database.room.repository.AppContainer
|
||||||
import com.example.myapplication.database.AppDatabase
|
import com.example.myapplication.database.AppDatabase
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
|
||||||
import com.example.myapplication.database.entities.model.BikeWithItems
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.model.ItemFromBike
|
import com.example.myapplication.database.room.model.bike.BikeWithItems
|
||||||
import com.example.myapplication.database.entities.repository.BikeRepository
|
import com.example.myapplication.database.room.model.item.ItemFromBike
|
||||||
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
|
||||||
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
|
import com.example.myapplication.database.room.repository.online.BikeRepository
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
class RestBikeRepository(
|
class RestBikeRepository(
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.remote
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Serializable
|
@Serializable
|
@ -1,6 +1,6 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.remote
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.ItemFromBike
|
import com.example.myapplication.database.room.model.item.ItemFromBike
|
||||||
import kotlinx.serialization.Contextual
|
import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,8 +1,8 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.remote
|
||||||
|
|
||||||
import com.example.myapplication.api.bike.BikeRemote
|
import com.example.myapplication.api.bike.remote.BikeRemote
|
||||||
import com.example.myapplication.api.bike.toBike
|
import com.example.myapplication.api.bike.remote.toBike
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.remote
|
||||||
|
|
||||||
import com.example.myapplication.api.bike.BikeRemote
|
import com.example.myapplication.api.bike.remote.BikeRemote
|
||||||
import com.example.myapplication.api.bike.toBike
|
import com.example.myapplication.api.bike.remote.toBike
|
||||||
import com.example.myapplication.database.entities.model.ItemFromRent
|
import com.example.myapplication.database.room.model.item.ItemFromRent
|
||||||
import kotlinx.serialization.Contextual
|
import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,6 +1,6 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.remote
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import kotlinx.serialization.Contextual
|
import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,7 +1,7 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.remote
|
||||||
|
|
||||||
import com.example.myapplication.api.bike.BikeRemote
|
import com.example.myapplication.api.bike.remote.BikeRemote
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import kotlinx.serialization.Contextual
|
import kotlinx.serialization.Contextual
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.item
|
package com.example.myapplication.api.item.repository
|
||||||
|
|
||||||
import android.content.ContentResolver
|
import android.content.ContentResolver
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
@ -11,12 +11,14 @@ import android.net.Uri
|
|||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.report.ReportRemote
|
import com.example.myapplication.api.item.remote.toItem
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.api.item.remote.toItemRemote
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
|
import com.example.myapplication.api.report.remote.ReportRemote
|
||||||
import com.example.myapplication.database.entities.repository.OfflineItemRepository
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.ItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
|
||||||
|
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
|
||||||
|
import com.example.myapplication.database.room.repository.online.ItemRepository
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@ -108,7 +110,7 @@ class RestItemRepository(
|
|||||||
val canvas = page.canvas
|
val canvas = page.canvas
|
||||||
|
|
||||||
val paint = Paint()
|
val paint = Paint()
|
||||||
paint.textSize = 16f // Уменьшаем размер шрифта для лучшей видимости
|
paint.textSize = 16f
|
||||||
paint.isAntiAlias = true
|
paint.isAntiAlias = true
|
||||||
|
|
||||||
// Отображаем заголовок
|
// Отображаем заголовок
|
||||||
@ -120,8 +122,8 @@ class RestItemRepository(
|
|||||||
|
|
||||||
// Отображаем данные в виде таблицы
|
// Отображаем данные в виде таблицы
|
||||||
val tableStartY = yTitle + 60f
|
val tableStartY = yTitle + 60f
|
||||||
val columnWidths = floatArrayOf(0.5f, 1f, 0.6f, 0.5f, 1f, 1f, 1f) // Увеличиваем ширину столбцов
|
val columnWidths = floatArrayOf(0.5f, 1f, 0.6f, 0.5f, 1f, 1f, 1f)
|
||||||
val rowHeight = 30f // Увеличиваем высоту строки
|
val rowHeight = 30f
|
||||||
|
|
||||||
drawTableRow(canvas, arrayOf("ID", "Дата", "Вес", "R", "Цвет", "Кол-во", "Имя"), columnWidths, tableStartY, paint)
|
drawTableRow(canvas, arrayOf("ID", "Дата", "Вес", "R", "Цвет", "Кол-во", "Имя"), columnWidths, tableStartY, paint)
|
||||||
|
|
||||||
@ -155,7 +157,7 @@ class RestItemRepository(
|
|||||||
for (i in row.indices) {
|
for (i in row.indices) {
|
||||||
val text = row[i]
|
val text = row[i]
|
||||||
canvas.drawText(text, x, y, paint)
|
canvas.drawText(text, x, y, paint)
|
||||||
x += columnWidths[i] * 80 // Увеличиваем ширину столбцов
|
x += columnWidths[i] * 80
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.rent
|
package com.example.myapplication.api.rent.mediator
|
||||||
|
|
||||||
import androidx.paging.ExperimentalPagingApi
|
import androidx.paging.ExperimentalPagingApi
|
||||||
import androidx.paging.LoadType
|
import androidx.paging.LoadType
|
||||||
@ -6,12 +6,13 @@ import androidx.paging.PagingState
|
|||||||
import androidx.paging.RemoteMediator
|
import androidx.paging.RemoteMediator
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
|
import com.example.myapplication.api.rent.remote.toRent
|
||||||
import com.example.myapplication.database.AppDatabase
|
import com.example.myapplication.database.AppDatabase
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentRepository
|
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeyType
|
import com.example.myapplication.database.remotekeys.model.RemoteKeyType
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
||||||
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
|
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
|
||||||
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
|
import com.example.myapplication.database.room.repository.offline.OfflineRentRepository
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.example.myapplication.api.rent
|
package com.example.myapplication.api.rent.remote
|
||||||
|
|
||||||
import com.example.myapplication.api.item.ItemFromRentRemote
|
import com.example.myapplication.api.item.remote.ItemFromRentRemote
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
@ -1,11 +1,12 @@
|
|||||||
package com.example.myapplication.api.rentitem
|
package com.example.myapplication.api.rent.rentitem.repository
|
||||||
|
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.item.ItemFromRentRemote
|
import com.example.myapplication.api.item.remote.ItemFromRentRemote
|
||||||
import com.example.myapplication.api.item.toItem
|
import com.example.myapplication.api.item.remote.toItem
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.RentItemRepository
|
import com.example.myapplication.database.room.repository.online.RentItemRepository
|
||||||
|
|
||||||
|
|
||||||
class RestRentItemRepository(
|
class RestRentItemRepository(
|
||||||
private val service: MyServerService,
|
private val service: MyServerService,
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.rent
|
package com.example.myapplication.api.rent.repository
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.paging.ExperimentalPagingApi
|
import androidx.paging.ExperimentalPagingApi
|
||||||
@ -6,18 +6,21 @@ import androidx.paging.Pager
|
|||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.bike.toBikeRemote
|
import com.example.myapplication.api.bike.remote.toBikeRemote
|
||||||
import com.example.myapplication.api.item.toItemFromRent
|
import com.example.myapplication.api.item.remote.toItemFromRent
|
||||||
import com.example.myapplication.database.AppContainer
|
import com.example.myapplication.api.rent.mediator.RentRemoteMediator
|
||||||
|
import com.example.myapplication.api.rent.remote.toRent
|
||||||
|
import com.example.myapplication.api.rent.remote.toRentRemote
|
||||||
|
import com.example.myapplication.database.room.repository.AppContainer
|
||||||
import com.example.myapplication.database.AppDatabase
|
import com.example.myapplication.database.AppDatabase
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
import com.example.myapplication.database.room.model.item.ItemFromRent
|
||||||
import com.example.myapplication.database.entities.model.ItemFromRent
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.RentRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineRentRepository
|
||||||
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
|
import com.example.myapplication.database.room.repository.online.RentRepository
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
class RestRentRepository(
|
class RestRentRepository(
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.api.report
|
package com.example.myapplication.api.report.remote
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.example.myapplication.api.user
|
package com.example.myapplication.api.user.remote
|
||||||
|
|
||||||
import com.example.myapplication.api.item.ItemFromCartRemote
|
import com.example.myapplication.api.item.remote.ItemFromCartRemote
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
@ -1,15 +1,15 @@
|
|||||||
package com.example.myapplication.api.user
|
package com.example.myapplication.api.user.repository
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.item.toItemFromCart
|
import com.example.myapplication.api.item.remote.toItemFromCart
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
import com.example.myapplication.api.user.remote.toUser
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.api.user.remote.toUserRemote
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
import com.example.myapplication.database.entities.repository.OfflineUserRepository
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
import com.example.myapplication.database.entities.repository.UserRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
|
||||||
import kotlinx.coroutines.flow.Flow
|
import com.example.myapplication.database.room.repository.offline.OfflineUserRepository
|
||||||
|
import com.example.myapplication.database.room.repository.online.UserRepository
|
||||||
|
|
||||||
class RestUserRepository(
|
class RestUserRepository(
|
||||||
private val service: MyServerService,
|
private val service: MyServerService,
|
@ -1,11 +1,11 @@
|
|||||||
package com.example.myapplication.api.useritem
|
package com.example.myapplication.api.useritem.repository
|
||||||
|
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.item.ItemFromCartRemote
|
import com.example.myapplication.api.item.remote.ItemFromCartRemote
|
||||||
import com.example.myapplication.api.item.toItem
|
import com.example.myapplication.api.item.remote.toItem
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.UserItemRepository
|
import com.example.myapplication.database.room.repository.online.UserItemRepository
|
||||||
|
|
||||||
class RestUserItemRepository(
|
class RestUserItemRepository(
|
||||||
private val service: MyServerService,
|
private val service: MyServerService,
|
@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
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.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
@ -49,25 +48,23 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.example.myapplication.R
|
import com.example.myapplication.R
|
||||||
import com.example.myapplication.database.entities.composeui.AppViewModelProvider
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.composeui.CartUiState
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import com.example.myapplication.database.entities.composeui.CartViewModel
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
import com.example.myapplication.database.entities.composeui.CurrentUserViewModel
|
import com.example.myapplication.database.room.viewmodel.cart.CartUiState
|
||||||
import com.example.myapplication.database.entities.composeui.ErroreList
|
import com.example.myapplication.database.room.viewmodel.cart.CartViewModel
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
|
||||||
import com.example.myapplication.ui.theme.PmudemoTheme
|
import com.example.myapplication.ui.theme.PmudemoTheme
|
||||||
import kotlinx.coroutines.delay
|
import com.example.myapplication.ui.view.ErroreView
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.threeten.bp.format.DateTimeFormatter
|
import org.threeten.bp.format.DateTimeFormatter
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Cart(
|
fun CartList(
|
||||||
viewModel: CartViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
viewModel: CartViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
||||||
currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
||||||
) {
|
) {
|
||||||
@ -81,7 +78,7 @@ fun Cart(
|
|||||||
getUser?.uid?.let { viewModel.refreshState(it) }
|
getUser?.uid?.let { viewModel.refreshState(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
Cart(
|
CartList(
|
||||||
cartUiState = cartUiState,
|
cartUiState = cartUiState,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(all = 10.dp),
|
.padding(all = 10.dp),
|
||||||
@ -126,12 +123,12 @@ fun Cart(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
ErroreList()
|
ErroreView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun Cart(
|
private fun CartList(
|
||||||
cartUiState: CartUiState,
|
cartUiState: CartUiState,
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
onSwipe: (ItemFromCart) -> Unit,
|
onSwipe: (ItemFromCart) -> Unit,
|
||||||
@ -331,7 +328,7 @@ fun CartPreview() {
|
|||||||
Surface(
|
Surface(
|
||||||
color = MaterialTheme.colorScheme.background
|
color = MaterialTheme.colorScheme.background
|
||||||
) {
|
) {
|
||||||
Cart()
|
CartList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,21 +7,21 @@ import androidx.room.Room
|
|||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import androidx.room.TypeConverters
|
import androidx.room.TypeConverters
|
||||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
import com.example.myapplication.database.entities.dao.BikeDao
|
|
||||||
import com.example.myapplication.database.entities.dao.RentDao
|
|
||||||
import com.example.myapplication.database.entities.dao.RentItemCrossRefDao
|
|
||||||
import com.example.myapplication.database.entities.dao.ItemDao
|
|
||||||
import com.example.myapplication.database.entities.dao.UserDao
|
|
||||||
import com.example.myapplication.database.entities.dao.UserItemCrossRefDao
|
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
|
||||||
import com.example.myapplication.database.entities.model.LocalDateTimeConverter
|
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
|
||||||
import com.example.myapplication.database.entities.model.Item
|
|
||||||
import com.example.myapplication.database.entities.model.User
|
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
|
||||||
import com.example.myapplication.database.remotekeys.dao.RemoteKeysDao
|
import com.example.myapplication.database.remotekeys.dao.RemoteKeysDao
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
||||||
|
import com.example.myapplication.database.room.dao.bike.BikeDao
|
||||||
|
import com.example.myapplication.database.room.dao.item.ItemDao
|
||||||
|
import com.example.myapplication.database.room.dao.rent.RentDao
|
||||||
|
import com.example.myapplication.database.room.dao.rent.RentItemCrossRefDao
|
||||||
|
import com.example.myapplication.database.room.dao.user.UserDao
|
||||||
|
import com.example.myapplication.database.room.dao.user.UserItemCrossRefDao
|
||||||
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
|
import com.example.myapplication.database.room.model.user.User
|
||||||
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
|
import com.example.myapplication.setting.LocalDateTimeConverter
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@ -62,79 +62,7 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
val userDao = database.userDao()
|
val userDao = database.userDao()
|
||||||
val user1 = User(1, "login", "admin", "password")
|
val user1 = User(1, "login", "admin", "password")
|
||||||
userDao.insert(user1)
|
userDao.insert(user1)
|
||||||
/*// Bikes
|
|
||||||
val bikeDao = database.bikeDao()
|
|
||||||
val bike1 =
|
|
||||||
Bike(1, "a", "Desc1", createColoredImage(android.graphics.Color.BLUE), 2023)
|
|
||||||
val bike2 =
|
|
||||||
Bike(2, "b", "Desc2", createColoredImage(android.graphics.Color.GREEN), 2023)
|
|
||||||
val bike3 =
|
|
||||||
Bike(3, "c", "Desc3", createColoredImage(android.graphics.Color.RED), 2023)
|
|
||||||
val bike4 =
|
|
||||||
Bike(4, "d", "Desc4", createColoredImage(android.graphics.Color.CYAN), 2023)
|
|
||||||
bikeDao.insert(bike1)
|
|
||||||
bikeDao.insert(bike2)
|
|
||||||
bikeDao.insert(bike3)
|
|
||||||
bikeDao.insert(bike4)
|
|
||||||
|
|
||||||
for (i in 5..20) {
|
|
||||||
val bike = Bike(
|
|
||||||
uid = i,
|
|
||||||
name = generateBikeName(i),
|
|
||||||
description = "Description $i",
|
|
||||||
image = createColoredImage(getRandomColorInt()),
|
|
||||||
)
|
|
||||||
bikeDao.insert(bike)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rents
|
|
||||||
val rentDao = database.rentDao()
|
|
||||||
val rent1 = Rent(1, 1)
|
|
||||||
val rent2 = Rent(2, 1)
|
|
||||||
val rent3 = Rent(3, 1)
|
|
||||||
val rent4 = Rent(4, 1)
|
|
||||||
rentDao.insert(rent1)
|
|
||||||
rentDao.insert(rent2)
|
|
||||||
rentDao.insert(rent3)
|
|
||||||
rentDao.insert(rent4)
|
|
||||||
// Items
|
|
||||||
val itemDao = database.itemDao()
|
|
||||||
val item1 = Item(1, LocalDateTime.now(), 150.0, 120, bike1.uid)
|
|
||||||
val item2 = Item(2, LocalDateTime.now(), 200.0, 110, bike2.uid)
|
|
||||||
val item3 = Item(3, LocalDateTime.now(), 300.0, 100, bike3.uid)
|
|
||||||
val item4 = Item(4, LocalDateTime.now(), 450.0, 200, bike1.uid)
|
|
||||||
itemDao.insert(item1)
|
|
||||||
itemDao.insert(item2)
|
|
||||||
itemDao.insert(item3)
|
|
||||||
itemDao.insert(item4)
|
|
||||||
// RentItemCrossRef для связи арендаов с сеансами
|
|
||||||
val rentItemCrossRefDao = database.rentItemCrossRefDao()
|
|
||||||
if (item1.uid != null && item2.uid != null && item3.uid != null) {
|
|
||||||
val rentItemCrossRef1 =
|
|
||||||
RentItemCrossRef(rent1.uid, item3.uid, 150.0, 5)
|
|
||||||
val rentItemCrossRef2 =
|
|
||||||
RentItemCrossRef(rent1.uid, item2.uid, 300.0, 10)
|
|
||||||
val rentItemCrossRef3 =
|
|
||||||
RentItemCrossRef(rent2.uid, item2.uid, 350.0, 6)
|
|
||||||
val rentItemCrossRef4 =
|
|
||||||
RentItemCrossRef(rent3.uid, item1.uid, 250.0, 10)
|
|
||||||
val rentItemCrossRef5 =
|
|
||||||
RentItemCrossRef(rent3.uid, item3.uid, 150.0, 16)
|
|
||||||
val rentItemCrossRef6 =
|
|
||||||
RentItemCrossRef(rent4.uid, item3.uid, 150.0, 2)
|
|
||||||
rentItemCrossRefDao.insert(rentItemCrossRef1)
|
|
||||||
rentItemCrossRefDao.insert(rentItemCrossRef2)
|
|
||||||
rentItemCrossRefDao.insert(rentItemCrossRef3)
|
|
||||||
rentItemCrossRefDao.insert(rentItemCrossRef4)
|
|
||||||
rentItemCrossRefDao.insert(rentItemCrossRef5)
|
|
||||||
rentItemCrossRefDao.insert(rentItemCrossRef6)
|
|
||||||
}
|
|
||||||
// UserItems
|
|
||||||
val userItemCrossRefDao = database.userItemCrossRefDao()
|
|
||||||
val userItemCrossRef1 = UserItemCrossRef(1, 1, 5)
|
|
||||||
val userItemCrossRef2 = UserItemCrossRef(1, 3, 15)
|
|
||||||
userItemCrossRefDao.insert(userItemCrossRef1)
|
|
||||||
userItemCrossRefDao.insert(userItemCrossRef2)*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.createSavedStateHandle
|
import androidx.lifecycle.createSavedStateHandle
|
||||||
@ -7,7 +7,17 @@ import androidx.lifecycle.viewmodel.initializer
|
|||||||
import androidx.lifecycle.viewmodel.viewModelFactory
|
import androidx.lifecycle.viewmodel.viewModelFactory
|
||||||
import com.example.myapplication.BikeApplication
|
import com.example.myapplication.BikeApplication
|
||||||
import com.example.myapplication.database.entities.composeui.edit.BikeEditViewModel
|
import com.example.myapplication.database.entities.composeui.edit.BikeEditViewModel
|
||||||
import com.example.myapplication.database.entities.composeui.edit.ItemEditViewModel
|
import com.example.myapplication.database.room.viewmodel.item.ItemEditViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.bike.BikeListViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.bike.BikeViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.cart.CartViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.EntryUserViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.item.ItemListViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.RegisterUserViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.rent.RentListViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.rent.RentViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.rent.ReportViewModel
|
||||||
|
|
||||||
object AppViewModelProvider {
|
object AppViewModelProvider {
|
||||||
val Factory = viewModelFactory {
|
val Factory = viewModelFactory {
|
@ -20,10 +20,11 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.example.myapplication.R
|
import com.example.myapplication.R
|
||||||
import com.example.myapplication.api.ApiStatus
|
import com.example.myapplication.api.ApiStatus
|
||||||
import com.example.myapplication.database.entities.composeui.AppViewModelProvider
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.composeui.ErrorPage
|
import com.example.myapplication.setting.ImageUploader
|
||||||
import com.example.myapplication.database.entities.composeui.LoadingPage
|
|
||||||
import com.example.myapplication.ui.theme.PmudemoTheme
|
import com.example.myapplication.ui.theme.PmudemoTheme
|
||||||
|
import com.example.myapplication.ui.view.ErrorView
|
||||||
|
import com.example.myapplication.ui.view.LoadingView
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -32,8 +33,8 @@ fun BikeEdit(
|
|||||||
viewModel: BikeEditViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
viewModel: BikeEditViewModel = viewModel(factory = AppViewModelProvider.Factory),
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
when (viewModel.apiStatus) {
|
/* when (viewModel.apiStatus) {
|
||||||
ApiStatus.DONE -> {
|
ApiStatus.DONE -> {*/
|
||||||
BikeEdit(
|
BikeEdit(
|
||||||
bikeUiState = viewModel.bikeUiState,
|
bikeUiState = viewModel.bikeUiState,
|
||||||
onClick = {
|
onClick = {
|
||||||
@ -44,13 +45,13 @@ fun BikeEdit(
|
|||||||
},
|
},
|
||||||
onUpdate = viewModel::updateUiState,
|
onUpdate = viewModel::updateUiState,
|
||||||
)
|
)
|
||||||
}
|
/* }
|
||||||
ApiStatus.LOADING -> LoadingPage()
|
ApiStatus.LOADING -> LoadingView()
|
||||||
else -> ErrorPage(
|
else -> ErrorView(
|
||||||
message = viewModel.apiError,
|
message = viewModel.apiError,
|
||||||
onBack = { navController.popBackStack() }
|
onBack = { navController.popBackStack() }
|
||||||
)
|
)
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -6,11 +6,11 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.database.entities.composeui.LoadingViewModel
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.BikeWithItems
|
||||||
import com.example.myapplication.database.entities.model.BikeWithItems
|
import com.example.myapplication.database.room.model.item.ItemFromBike
|
||||||
import com.example.myapplication.database.entities.model.ItemFromBike
|
import com.example.myapplication.database.room.repository.online.BikeRepository
|
||||||
import com.example.myapplication.database.entities.repository.BikeRepository
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class BikeEditViewModel(
|
class BikeEditViewModel(
|
||||||
@ -37,11 +37,19 @@ class BikeEditViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateUiState(bikeDetails: BikeDetails) {
|
fun updateUiState(bikeDetails: BikeDetails) {
|
||||||
|
runInScope(
|
||||||
|
actionSuccess = {
|
||||||
bikeUiState = BikeUiState(
|
bikeUiState = BikeUiState(
|
||||||
bikeDetails = bikeDetails,
|
bikeDetails = bikeDetails,
|
||||||
isEntryValid = validateInput(bikeDetails)
|
isEntryValid = validateInput(bikeDetails)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
,
|
||||||
|
actionError = {
|
||||||
|
bikeUiState = BikeUiState()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun saveBike() {
|
suspend fun saveBike() {
|
||||||
if (validateInput()) {
|
if (validateInput()) {
|
||||||
|
@ -4,9 +4,9 @@ import androidx.room.Entity
|
|||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
import androidx.room.TypeConverters
|
import androidx.room.TypeConverters
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
|
|
||||||
enum class RemoteKeyType(private val type: String) {
|
enum class RemoteKeyType(private val type: String) {
|
||||||
CINEMA(Bike::class.simpleName ?: "Bike"),
|
CINEMA(Bike::class.simpleName ?: "Bike"),
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package com.example.myapplication.database.remotekeys.repository
|
package com.example.myapplication.database.remotekeys.repository.offline
|
||||||
|
|
||||||
import com.example.myapplication.database.remotekeys.dao.RemoteKeysDao
|
import com.example.myapplication.database.remotekeys.dao.RemoteKeysDao
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeyType
|
import com.example.myapplication.database.remotekeys.model.RemoteKeyType
|
||||||
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
import com.example.myapplication.database.remotekeys.model.RemoteKeys
|
||||||
|
import com.example.myapplication.database.remotekeys.repository.RemoteKeyRepository
|
||||||
|
|
||||||
class OfflineRemoteKeyRepository(private val remoteKeysDao: RemoteKeysDao) : RemoteKeyRepository {
|
class OfflineRemoteKeyRepository(private val remoteKeysDao: RemoteKeysDao) : RemoteKeyRepository {
|
||||||
override suspend fun getAllRemoteKeys(id: Int, type: RemoteKeyType) =
|
override suspend fun getAllRemoteKeys(id: Int, type: RemoteKeyType) =
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.dao
|
package com.example.myapplication.database.room.dao.bike
|
||||||
|
|
||||||
import androidx.paging.PagingSource
|
import androidx.paging.PagingSource
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
@ -6,8 +6,8 @@ import androidx.room.Delete
|
|||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.model.ItemFromBike
|
import com.example.myapplication.database.room.model.item.ItemFromBike
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
@Dao
|
@Dao
|
@ -1,11 +1,11 @@
|
|||||||
package com.example.myapplication.database.entities.dao
|
package com.example.myapplication.database.room.dao.item
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
import androidx.room.Delete
|
||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface ItemDao {
|
interface ItemDao {
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.dao
|
package com.example.myapplication.database.room.dao.rent
|
||||||
|
|
||||||
import androidx.paging.PagingSource
|
import androidx.paging.PagingSource
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
@ -6,8 +6,8 @@ import androidx.room.Delete
|
|||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.item.ItemFromRent
|
||||||
import com.example.myapplication.database.entities.model.ItemFromRent
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface RentDao {
|
interface RentDao {
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.dao
|
package com.example.myapplication.database.room.dao.rent
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
import androidx.room.Delete
|
||||||
@ -6,7 +6,7 @@ import androidx.room.Insert
|
|||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface RentItemCrossRefDao {
|
interface RentItemCrossRefDao {
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.dao
|
package com.example.myapplication.database.room.dao.user
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
import androidx.room.Delete
|
||||||
@ -6,8 +6,8 @@ import androidx.room.Insert
|
|||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
@Dao
|
@Dao
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.dao
|
package com.example.myapplication.database.room.dao.user
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Delete
|
import androidx.room.Delete
|
||||||
@ -6,7 +6,7 @@ import androidx.room.Insert
|
|||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
import androidx.room.Update
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface UserItemCrossRefDao {
|
interface UserItemCrossRefDao {
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.bike
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
@ -1,4 +1,6 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.bike
|
||||||
|
|
||||||
|
import com.example.myapplication.database.room.model.item.ItemFromBike
|
||||||
|
|
||||||
data class BikeWithItems(
|
data class BikeWithItems(
|
||||||
val bike: Bike,
|
val bike: Bike,
|
@ -1,10 +1,11 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.item
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
import androidx.room.Ignore
|
import androidx.room.Ignore
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
|
|
||||||
@Entity(
|
@Entity(
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.item
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,7 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.item
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Relation
|
import androidx.room.Relation
|
||||||
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
|
|
||||||
data class ItemFromCart(
|
data class ItemFromCart(
|
@ -1,7 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.item
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Relation
|
import androidx.room.Relation
|
||||||
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
|
|
||||||
data class ItemFromRent(
|
data class ItemFromRent(
|
@ -1,9 +1,10 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.rent
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.ForeignKey
|
import androidx.room.ForeignKey
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
import com.example.myapplication.database.room.model.user.User
|
||||||
|
|
||||||
@Entity(
|
@Entity(
|
||||||
tableName = "rents", foreignKeys = [
|
tableName = "rents", foreignKeys = [
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.rent
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.user
|
||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.database.room.model.user
|
||||||
|
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
@ -1,20 +1,21 @@
|
|||||||
package com.example.myapplication.database
|
package com.example.myapplication.database.room.repository
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.example.myapplication.api.MyServerService
|
import com.example.myapplication.api.MyServerService
|
||||||
import com.example.myapplication.api.bike.RestBikeRepository
|
import com.example.myapplication.api.bike.repository.RestBikeRepository
|
||||||
import com.example.myapplication.api.rent.RestRentRepository
|
import com.example.myapplication.api.rent.repository.RestRentRepository
|
||||||
import com.example.myapplication.api.rentitem.RestRentItemRepository
|
import com.example.myapplication.api.rent.rentitem.repository.RestRentItemRepository
|
||||||
import com.example.myapplication.api.item.RestItemRepository
|
import com.example.myapplication.api.item.repository.RestItemRepository
|
||||||
import com.example.myapplication.api.user.RestUserRepository
|
import com.example.myapplication.api.user.repository.RestUserRepository
|
||||||
import com.example.myapplication.api.useritem.RestUserItemRepository
|
import com.example.myapplication.api.useritem.repository.RestUserItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
|
import com.example.myapplication.database.AppDatabase
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentRepository
|
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineUserRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineRentRepository
|
||||||
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
|
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
|
||||||
|
import com.example.myapplication.database.room.repository.offline.OfflineUserRepository
|
||||||
|
|
||||||
interface AppContainer {
|
interface AppContainer {
|
||||||
val bikeRestRepository: RestBikeRepository
|
val bikeRestRepository: RestBikeRepository
|
@ -1,13 +1,14 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.offline
|
||||||
|
|
||||||
import androidx.paging.Pager
|
import androidx.paging.Pager
|
||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import androidx.paging.PagingSource
|
import androidx.paging.PagingSource
|
||||||
import com.example.myapplication.database.AppContainer
|
import com.example.myapplication.database.room.dao.bike.BikeDao
|
||||||
import com.example.myapplication.database.entities.dao.BikeDao
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.BikeWithItems
|
||||||
import com.example.myapplication.database.entities.model.BikeWithItems
|
import com.example.myapplication.database.room.repository.AppContainer
|
||||||
|
import com.example.myapplication.database.room.repository.online.BikeRepository
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
@ -1,7 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.offline
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.dao.ItemDao
|
import com.example.myapplication.database.room.dao.item.ItemDao
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
|
import com.example.myapplication.database.room.repository.online.ItemRepository
|
||||||
|
|
||||||
class OfflineItemRepository(private val itemDao: ItemDao) : ItemRepository {
|
class OfflineItemRepository(private val itemDao: ItemDao) : ItemRepository {
|
||||||
override suspend fun getItem(uid: Int): Item = itemDao.getByUid(uid)
|
override suspend fun getItem(uid: Int): Item = itemDao.getByUid(uid)
|
@ -1,7 +1,9 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.offline
|
||||||
|
|
||||||
|
import com.example.myapplication.database.room.dao.rent.RentItemCrossRefDao
|
||||||
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
|
import com.example.myapplication.database.room.repository.online.RentItemRepository
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.dao.RentItemCrossRefDao
|
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
|
||||||
|
|
||||||
class OfflineRentItemRepository(private val rentItemDao: RentItemCrossRefDao) :
|
class OfflineRentItemRepository(private val rentItemDao: RentItemCrossRefDao) :
|
||||||
RentItemRepository {
|
RentItemRepository {
|
@ -1,13 +1,14 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.offline
|
||||||
|
|
||||||
import androidx.paging.Pager
|
import androidx.paging.Pager
|
||||||
import androidx.paging.PagingConfig
|
import androidx.paging.PagingConfig
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import androidx.paging.PagingSource
|
import androidx.paging.PagingSource
|
||||||
import com.example.myapplication.database.AppContainer
|
import com.example.myapplication.database.room.dao.rent.RentDao
|
||||||
import com.example.myapplication.database.entities.dao.RentDao
|
import com.example.myapplication.database.room.model.item.ItemFromRent
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
import com.example.myapplication.database.entities.model.ItemFromRent
|
import com.example.myapplication.database.room.repository.AppContainer
|
||||||
|
import com.example.myapplication.database.room.repository.online.RentRepository
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
class OfflineRentRepository(private val rentDao: RentDao) : RentRepository {
|
class OfflineRentRepository(private val rentDao: RentDao) : RentRepository {
|
@ -1,7 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.offline
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.dao.UserItemCrossRefDao
|
import com.example.myapplication.database.room.dao.user.UserItemCrossRefDao
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
|
import com.example.myapplication.database.room.repository.online.UserItemRepository
|
||||||
|
|
||||||
class OfflineUserItemRepository(private val userItemDao: UserItemCrossRefDao) :
|
class OfflineUserItemRepository(private val userItemDao: UserItemCrossRefDao) :
|
||||||
UserItemRepository {
|
UserItemRepository {
|
@ -1,9 +1,9 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.offline
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.dao.UserDao
|
import com.example.myapplication.database.room.dao.user.UserDao
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import kotlinx.coroutines.flow.Flow
|
import com.example.myapplication.database.room.repository.online.UserRepository
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
class OfflineUserRepository(private val userDao: UserDao) : UserRepository {
|
class OfflineUserRepository(private val userDao: UserDao) : UserRepository {
|
@ -1,8 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.online
|
||||||
|
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.model.BikeWithItems
|
import com.example.myapplication.database.room.model.bike.BikeWithItems
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
interface BikeRepository {
|
interface BikeRepository {
|
@ -1,6 +1,7 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.online
|
||||||
|
|
||||||
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.Item
|
|
||||||
|
|
||||||
interface ItemRepository {
|
interface ItemRepository {
|
||||||
suspend fun getItem(uid: Int): Item
|
suspend fun getItem(uid: Int): Item
|
@ -1,6 +1,7 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.online
|
||||||
|
|
||||||
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
|
||||||
|
|
||||||
interface RentItemRepository {
|
interface RentItemRepository {
|
||||||
suspend fun insertRentItem(rentItemCrossRef: RentItemCrossRef)
|
suspend fun insertRentItem(rentItemCrossRef: RentItemCrossRef)
|
@ -1,8 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.online
|
||||||
|
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.item.ItemFromRent
|
||||||
import com.example.myapplication.database.entities.model.ItemFromRent
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
interface RentRepository {
|
interface RentRepository {
|
@ -1,6 +1,7 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.online
|
||||||
|
|
||||||
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
|
||||||
|
|
||||||
interface UserItemRepository {
|
interface UserItemRepository {
|
||||||
suspend fun insertUserItem(userItemCrossRef: UserItemCrossRef)
|
suspend fun insertUserItem(userItemCrossRef: UserItemCrossRef)
|
@ -1,8 +1,8 @@
|
|||||||
package com.example.myapplication.database.entities.repository
|
package com.example.myapplication.database.room.repository.online
|
||||||
|
|
||||||
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
|
import com.example.myapplication.database.room.model.user.User
|
||||||
|
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
|
||||||
import com.example.myapplication.database.entities.model.User
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
|
|
||||||
interface UserRepository {
|
interface UserRepository {
|
||||||
suspend fun getAllUsers(): List<User>
|
suspend fun getAllUsers(): List<User>
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel
|
||||||
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.bike
|
||||||
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
@ -7,8 +7,9 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import androidx.paging.cachedIn
|
import androidx.paging.cachedIn
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
import com.example.myapplication.database.entities.repository.BikeRepository
|
import com.example.myapplication.database.room.repository.online.BikeRepository
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.emptyFlow
|
import kotlinx.coroutines.flow.emptyFlow
|
||||||
|
|
||||||
@ -24,7 +25,6 @@ class BikeListViewModel(
|
|||||||
bikePagingFlowState = BikePagingFlowState(pagingSource.cachedIn(viewModelScope))
|
bikePagingFlowState = BikePagingFlowState(pagingSource.cachedIn(viewModelScope))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun deleteBike(bike: Bike) {
|
suspend fun deleteBike(bike: Bike) {
|
||||||
runInScope(actionSuccess = {
|
runInScope(actionSuccess = {
|
||||||
bikeRepository.deleteBike(bike)
|
bikeRepository.deleteBike(bike)
|
@ -1,12 +1,12 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.bike
|
||||||
|
|
||||||
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
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
import com.example.myapplication.database.room.model.bike.BikeWithItems
|
||||||
import com.example.myapplication.database.entities.model.BikeWithItems
|
import com.example.myapplication.database.room.repository.online.BikeRepository
|
||||||
import com.example.myapplication.database.entities.repository.BikeRepository
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
|
|
||||||
class BikeViewModel(
|
class BikeViewModel(
|
||||||
savedStateHandle: SavedStateHandle, private val bikeRepository: BikeRepository
|
savedStateHandle: SavedStateHandle, private val bikeRepository: BikeRepository
|
||||||
@ -19,7 +19,8 @@ class BikeViewModel(
|
|||||||
suspend fun refreshState() {
|
suspend fun refreshState() {
|
||||||
if (bikeUid > 0) {
|
if (bikeUid > 0) {
|
||||||
runInScope(actionSuccess = {
|
runInScope(actionSuccess = {
|
||||||
bikeUiState = BikeUiState(bikeRepository.getBike(bikeUid))
|
bikeUiState =
|
||||||
|
BikeUiState(bikeRepository.getBike(bikeUid))
|
||||||
}, actionError = {
|
}, actionError = {
|
||||||
bikeUiState = BikeUiState()
|
bikeUiState = BikeUiState()
|
||||||
})
|
})
|
@ -1,19 +1,18 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.cart
|
||||||
|
|
||||||
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
|
||||||
import androidx.lifecycle.ViewModel
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.item.ItemFromCart
|
||||||
import com.example.myapplication.database.entities.model.RentItemCrossRef
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
|
||||||
import com.example.myapplication.database.entities.model.ItemFromCart
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
import com.example.myapplication.database.room.repository.online.RentItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.RentRepository
|
import com.example.myapplication.database.room.repository.online.RentRepository
|
||||||
import com.example.myapplication.database.entities.repository.RentItemRepository
|
import com.example.myapplication.database.room.repository.online.UserItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.UserRepository
|
import com.example.myapplication.database.room.repository.online.UserRepository
|
||||||
import com.example.myapplication.database.entities.repository.UserItemRepository
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
|
|
||||||
class CartViewModel(
|
class CartViewModel(
|
||||||
private val userItemRepository: UserItemRepository,
|
private val userItemRepository: UserItemRepository,
|
@ -1,14 +1,13 @@
|
|||||||
package com.example.myapplication.database.entities.composeui.edit
|
package com.example.myapplication.database.room.viewmodel.item
|
||||||
|
|
||||||
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
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.database.entities.composeui.LoadingViewModel
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.repository.online.ItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.ItemRepository
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.item
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import com.example.myapplication.database.room.model.item.Item
|
||||||
import com.example.myapplication.database.entities.model.Item
|
import com.example.myapplication.database.room.model.item.ItemFromBike
|
||||||
import com.example.myapplication.database.entities.model.ItemFromBike
|
import com.example.myapplication.database.room.model.user.UserItemCrossRef
|
||||||
import com.example.myapplication.database.entities.model.UserItemCrossRef
|
import com.example.myapplication.database.room.repository.online.ItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.ItemRepository
|
import com.example.myapplication.database.room.repository.online.UserItemRepository
|
||||||
import com.example.myapplication.database.entities.repository.UserItemRepository
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
|
|
||||||
class ItemListViewModel(
|
class ItemListViewModel(
|
||||||
private val itemRepository: ItemRepository,
|
private val itemRepository: ItemRepository,
|
@ -1,9 +1,9 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.rent
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.paging.PagingData
|
import androidx.paging.PagingData
|
||||||
import com.example.myapplication.database.entities.model.Rent
|
import com.example.myapplication.database.room.model.rent.Rent
|
||||||
import com.example.myapplication.database.entities.repository.RentRepository
|
import com.example.myapplication.database.room.repository.online.RentRepository
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
@ -1,11 +1,11 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.rent
|
||||||
|
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.database.AppContainer
|
import com.example.myapplication.database.room.model.item.ItemFromRent
|
||||||
import com.example.myapplication.database.entities.model.ItemFromRent
|
import com.example.myapplication.database.room.repository.AppContainer
|
||||||
import com.example.myapplication.database.entities.repository.RentRepository
|
import com.example.myapplication.database.room.repository.online.RentRepository
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
@ -1,14 +1,14 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.rent
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
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
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.api.item.RestItemRepository
|
import com.example.myapplication.api.item.repository.RestItemRepository
|
||||||
import com.example.myapplication.api.report.ReportRemote
|
import com.example.myapplication.api.report.remote.ReportRemote
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
@ -1,12 +1,12 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.user
|
||||||
|
|
||||||
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
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import com.example.myapplication.database.entities.repository.UserRepository
|
import com.example.myapplication.database.room.repository.online.UserRepository
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class CurrentUserViewModel(private val userRepository: UserRepository) : LoadingViewModel(){
|
class CurrentUserViewModel(private val userRepository: UserRepository) : LoadingViewModel(){
|
@ -1,12 +1,12 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.user
|
||||||
|
|
||||||
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
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import com.example.myapplication.database.entities.repository.UserRepository
|
import com.example.myapplication.database.room.repository.online.UserRepository
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class EntryUserViewModel(private val userRepository: UserRepository) : LoadingViewModel() {
|
class EntryUserViewModel(private val userRepository: UserRepository) : LoadingViewModel() {
|
@ -1,11 +1,11 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.database.room.viewmodel.user
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import com.example.myapplication.database.entities.repository.UserRepository
|
import com.example.myapplication.database.room.repository.online.UserRepository
|
||||||
|
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class RegisterUserViewModel(private val userRepository: UserRepository) : LoadingViewModel() {
|
class RegisterUserViewModel(private val userRepository: UserRepository) : LoadingViewModel() {
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.datastore
|
package com.example.myapplication.setting
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.datastore.core.DataStore
|
import androidx.datastore.core.DataStore
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui.edit
|
package com.example.myapplication.setting
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.model
|
package com.example.myapplication.setting
|
||||||
|
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,14 +1,10 @@
|
|||||||
package com.example.myapplication.api
|
package com.example.myapplication.setting
|
||||||
|
|
||||||
import androidx.room.TypeConverters
|
|
||||||
import com.example.myapplication.database.entities.model.LocalDateTimeConverter
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.descriptors.*
|
import kotlinx.serialization.descriptors.*
|
||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
||||||
import org.threeten.bp.DateTimeUtils.toLocalDateTime
|
|
||||||
import org.threeten.bp.format.DateTimeFormatter
|
|
||||||
|
|
||||||
@Serializer(forClass = LocalDateTime::class)
|
@Serializer(forClass = LocalDateTime::class)
|
||||||
object LocalDateTimeSerializer: KSerializer<LocalDateTime> {
|
object LocalDateTimeSerializer: KSerializer<LocalDateTime> {
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.datastore
|
package com.example.myapplication.setting
|
||||||
|
|
||||||
data class SettingData(
|
data class SettingData(
|
||||||
val isDarkTheme: Boolean
|
val isDarkTheme: Boolean
|
@ -1,7 +1,6 @@
|
|||||||
package com.example.myapplication.database.entities.composeui.edit
|
package com.example.myapplication.ui.edit
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
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
|
||||||
@ -29,7 +28,6 @@ import androidx.compose.material3.rememberDatePickerState
|
|||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
@ -38,9 +36,11 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.composeui.AppViewModelProvider
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
import com.example.myapplication.database.entities.composeui.CurrentUserViewModel
|
import com.example.myapplication.database.room.viewmodel.item.ItemDetails
|
||||||
|
import com.example.myapplication.database.room.viewmodel.item.ItemEditViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.item.ItemUiState
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.threeten.bp.Instant
|
import org.threeten.bp.Instant
|
||||||
import org.threeten.bp.LocalDateTime
|
import org.threeten.bp.LocalDateTime
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.list
|
||||||
|
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
@ -45,8 +45,12 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.paging.compose.LazyPagingItems
|
import androidx.paging.compose.LazyPagingItems
|
||||||
import androidx.paging.compose.collectAsLazyPagingItems
|
import androidx.paging.compose.collectAsLazyPagingItems
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
|
import com.example.myapplication.database.room.viewmodel.bike.BikeListViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
|
import com.example.myapplication.ui.view.ErroreView
|
||||||
|
import com.example.myapplication.ui.navigation.Screen
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -56,6 +60,7 @@ fun BikeList(
|
|||||||
currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
|
||||||
) {
|
) {
|
||||||
var getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
var getUser by remember { mutableStateOf(currentUserViewModel.user) }
|
||||||
|
|
||||||
val bikePagingItems = viewModel.bikePagingFlowState.flow.collectAsLazyPagingItems()
|
val bikePagingItems = viewModel.bikePagingFlowState.flow.collectAsLazyPagingItems()
|
||||||
|
|
||||||
LaunchedEffect(getUser?.uid) {
|
LaunchedEffect(getUser?.uid) {
|
||||||
@ -113,7 +118,7 @@ fun BikeList(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ErroreList()
|
ErroreView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.list
|
||||||
|
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@ -37,7 +37,11 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.example.myapplication.R
|
import com.example.myapplication.R
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
|
import com.example.myapplication.database.room.viewmodel.bike.BikeViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.item.ItemListViewModel
|
||||||
|
import com.example.myapplication.ui.navigation.Screen
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.threeten.bp.format.DateTimeFormatter
|
import org.threeten.bp.format.DateTimeFormatter
|
||||||
|
|
@ -1,16 +1,13 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.list
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
|
||||||
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.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
@ -29,7 +26,6 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
@ -37,7 +33,11 @@ import androidx.navigation.NavController
|
|||||||
import androidx.paging.compose.collectAsLazyPagingItems
|
import androidx.paging.compose.collectAsLazyPagingItems
|
||||||
import androidx.paging.compose.itemContentType
|
import androidx.paging.compose.itemContentType
|
||||||
import androidx.paging.compose.itemKey
|
import androidx.paging.compose.itemKey
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.rent.RentListViewModel
|
||||||
|
import com.example.myapplication.ui.view.ErroreView
|
||||||
|
import com.example.myapplication.ui.navigation.Screen
|
||||||
import com.example.myapplication.ui.theme.PmudemoTheme
|
import com.example.myapplication.ui.theme.PmudemoTheme
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ fun RentList(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Пользователь не авторизован, показываем экран с сообщением
|
// Пользователь не авторизован, показываем экран с сообщением
|
||||||
ErroreList()
|
ErroreView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,5 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.list
|
||||||
|
|
||||||
import android.content.ContentResolver
|
|
||||||
import android.content.ContentValues
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Canvas
|
|
||||||
import android.graphics.Paint
|
|
||||||
import android.graphics.pdf.PdfDocument
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@ -18,7 +7,6 @@ import androidx.compose.foundation.border
|
|||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
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.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@ -35,26 +23,16 @@ import androidx.compose.material.AlertDialog
|
|||||||
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.Card
|
||||||
import androidx.compose.material3.DatePicker
|
|
||||||
import androidx.compose.material3.DisplayMode
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.material3.TextField
|
|
||||||
import androidx.compose.material3.TextFieldDefaults
|
|
||||||
import androidx.compose.material3.rememberDatePickerState
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.shadow
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.RectangleShape
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
@ -64,22 +42,15 @@ 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.example.myapplication.R
|
import com.example.myapplication.R
|
||||||
import com.example.myapplication.api.report.ReportRemote
|
import com.example.myapplication.api.report.remote.ReportRemote
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import kotlinx.coroutines.Dispatchers
|
import com.example.myapplication.database.room.viewmodel.rent.ReportViewModel
|
||||||
|
import com.example.myapplication.ui.navigation.Screen
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.io.IOException
|
|
||||||
import java.io.OutputStream
|
|
||||||
import java.text.ParseException
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.time.Year
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ReportPage (navController: NavController?, viewModel: ReportViewModel = viewModel(factory = AppViewModelProvider.Factory))
|
fun ReportList (navController: NavController?, viewModel: ReportViewModel = viewModel(factory = AppViewModelProvider.Factory))
|
||||||
{
|
{
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
@ -1,17 +1,6 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.list
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ContentResolver
|
|
||||||
import android.content.ContentValues
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.Paint
|
|
||||||
import android.graphics.pdf.PdfDocument
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.foundation.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
@ -25,7 +14,6 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
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.heightIn
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
@ -33,14 +21,9 @@ import androidx.compose.foundation.shape.CircleShape
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.BasicTextField
|
import androidx.compose.foundation.text.BasicTextField
|
||||||
import androidx.compose.material.AlertDialog
|
import androidx.compose.material.AlertDialog
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.Warning
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Snackbar
|
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.SwitchDefaults
|
import androidx.compose.material3.SwitchDefaults
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@ -53,7 +36,6 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
@ -67,22 +49,19 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.example.myapplication.R
|
import com.example.myapplication.R
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.model.User
|
import com.example.myapplication.database.room.model.user.User
|
||||||
import com.example.myapplication.datastore.DataStoreManager
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
import com.example.myapplication.datastore.SettingData
|
import com.example.myapplication.database.room.viewmodel.user.EntryUserViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import com.example.myapplication.database.room.viewmodel.user.RegisterUserViewModel
|
||||||
import kotlinx.coroutines.async
|
import com.example.myapplication.ui.navigation.Screen
|
||||||
|
import com.example.myapplication.setting.DataStoreManager
|
||||||
|
import com.example.myapplication.setting.SettingData
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
import java.io.IOException
|
|
||||||
import java.io.OutputStream
|
|
||||||
|
|
||||||
@SuppressLint("UnrememberedMutableState")
|
@SuppressLint("UnrememberedMutableState")
|
||||||
@Composable
|
@Composable
|
||||||
fun UserProfile(
|
fun UserList(
|
||||||
navController: NavController?,
|
navController: NavController?,
|
||||||
isDarkTheme: MutableState<Boolean>,
|
isDarkTheme: MutableState<Boolean>,
|
||||||
dataStoreManager: DataStoreManager,
|
dataStoreManager: DataStoreManager,
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.composeui.navigation
|
package com.example.myapplication.ui.navigation
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@ -47,19 +47,19 @@ import androidx.navigation.compose.composable
|
|||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import androidx.navigation.navArgument
|
import androidx.navigation.navArgument
|
||||||
import com.example.myapplication.composeui.Cart
|
import com.example.myapplication.composeui.CartList
|
||||||
import com.example.myapplication.database.entities.composeui.AppViewModelProvider
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.composeui.BikeList
|
|
||||||
import com.example.myapplication.database.entities.composeui.BikeView
|
|
||||||
import com.example.myapplication.database.entities.composeui.CurrentUserViewModel
|
|
||||||
import com.example.myapplication.database.entities.composeui.LoginScreen
|
|
||||||
import com.example.myapplication.database.entities.composeui.RentList
|
|
||||||
import com.example.myapplication.database.entities.composeui.RentView
|
|
||||||
import com.example.myapplication.database.entities.composeui.ReportPage
|
|
||||||
import com.example.myapplication.database.entities.composeui.UserProfile
|
|
||||||
import com.example.myapplication.database.entities.composeui.edit.BikeEdit
|
import com.example.myapplication.database.entities.composeui.edit.BikeEdit
|
||||||
import com.example.myapplication.database.entities.composeui.edit.ItemEdit
|
import com.example.myapplication.ui.list.BikeList
|
||||||
import com.example.myapplication.datastore.DataStoreManager
|
import com.example.myapplication.ui.view.BikeView
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
|
import com.example.myapplication.ui.list.LoginScreen
|
||||||
|
import com.example.myapplication.ui.list.RentList
|
||||||
|
import com.example.myapplication.ui.view.RentView
|
||||||
|
import com.example.myapplication.ui.list.ReportList
|
||||||
|
import com.example.myapplication.ui.list.UserList
|
||||||
|
import com.example.myapplication.setting.DataStoreManager
|
||||||
|
import com.example.myapplication.ui.edit.ItemEdit
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Topbar(
|
fun Topbar(
|
||||||
@ -189,9 +189,9 @@ fun Navhost(
|
|||||||
) {
|
) {
|
||||||
composable(Screen.BikeList.route) { BikeList(navController, currentUserViewModel = currentUserViewModel) }
|
composable(Screen.BikeList.route) { BikeList(navController, currentUserViewModel = currentUserViewModel) }
|
||||||
composable(Screen.RentList.route) { RentList(navController, currentUserViewModel = currentUserViewModel) }
|
composable(Screen.RentList.route) { RentList(navController, currentUserViewModel = currentUserViewModel) }
|
||||||
composable(Screen.Cart.route) { Cart(currentUserViewModel = currentUserViewModel) }
|
composable(Screen.Cart.route) { CartList(currentUserViewModel = currentUserViewModel) }
|
||||||
composable(Screen.UserProfile.route) { UserProfile(navController,isDarkTheme, dataStore, currentUserViewModel = currentUserViewModel) }
|
composable(Screen.UserProfile.route) { UserList(navController,isDarkTheme, dataStore, currentUserViewModel = currentUserViewModel) }
|
||||||
composable(Screen.Report.route) { ReportPage(navController = navController) }
|
composable(Screen.Report.route) { ReportList(navController = navController) }
|
||||||
composable(Screen.LoginScreen.route) { LoginScreen(navController) }
|
composable(Screen.LoginScreen.route) { LoginScreen(navController) }
|
||||||
composable(
|
composable(
|
||||||
Screen.BikeEdit.route,
|
Screen.BikeEdit.route,
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.composeui.navigation
|
package com.example.myapplication.ui.navigation
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.view
|
||||||
|
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
@ -35,8 +35,12 @@ 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.example.myapplication.api.ApiStatus
|
import com.example.myapplication.api.ApiStatus
|
||||||
import com.example.myapplication.composeui.navigation.Screen
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
import com.example.myapplication.database.entities.model.Bike
|
import com.example.myapplication.database.room.model.bike.Bike
|
||||||
|
import com.example.myapplication.database.room.viewmodel.bike.BikeViewModel
|
||||||
|
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
|
||||||
|
import com.example.myapplication.ui.navigation.Screen
|
||||||
|
import com.example.myapplication.ui.list.ItemList
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BikeView(
|
fun BikeView(
|
||||||
@ -151,8 +155,8 @@ fun BikeView(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiStatus.LOADING -> LoadingPage()
|
ApiStatus.LOADING -> LoadingView()
|
||||||
else -> ErrorPage(
|
else -> ErrorView(
|
||||||
message = viewModel.apiError,
|
message = viewModel.apiError,
|
||||||
onBack = { navController.popBackStack() }
|
onBack = { navController.popBackStack() }
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.view
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@ -14,7 +14,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ErroreList() {
|
fun ErroreView() {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.view
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
@ -20,7 +20,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import com.example.myapplication.R
|
import com.example.myapplication.R
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LoadingPage() {
|
fun LoadingView() {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
@ -38,7 +38,7 @@ fun LoadingPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ErrorPage(message: String, onBack: () -> Unit) {
|
fun ErrorView(message: String, onBack: () -> Unit) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.myapplication.database.entities.composeui
|
package com.example.myapplication.ui.view
|
||||||
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
@ -30,6 +30,8 @@ import androidx.compose.ui.graphics.asImageBitmap
|
|||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import com.example.myapplication.database.AppViewModelProvider
|
||||||
|
import com.example.myapplication.database.room.viewmodel.rent.RentViewModel
|
||||||
import com.example.myapplication.ui.theme.PmudemoTheme
|
import com.example.myapplication.ui.theme.PmudemoTheme
|
||||||
import org.threeten.bp.format.DateTimeFormatter
|
import org.threeten.bp.format.DateTimeFormatter
|
||||||
|
|
@ -2,9 +2,9 @@
|
|||||||
<network-security-config>
|
<network-security-config>
|
||||||
<domain-config cleartextTrafficPermitted="true">
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
<!--Раздача с тлф-->
|
<!--Раздача с тлф-->
|
||||||
<domain includeSubdomains="true">192.168.138.47</domain>
|
<!-- <domain includeSubdomains="true">192.168.138.47</domain>-->
|
||||||
<!--Дома пк-->
|
<!--Дома пк-->
|
||||||
<!-- <domain includeSubdomains="true">192.168.0.104</domain>-->
|
<domain includeSubdomains="true">192.168.0.104</domain>
|
||||||
<!-- <domain includeSubdomains="true">10.0.2.2</domain>-->
|
<!-- <domain includeSubdomains="true">10.0.2.2</domain>-->
|
||||||
</domain-config>
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
59423
server/data.json
59423
server/data.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user