папочка

This commit is contained in:
Кашин Максим 2023-12-27 03:17:40 +04:00
parent c7f73c4d5a
commit eb0ca104f1
84 changed files with 401 additions and 59827 deletions

View File

@ -1,8 +1,8 @@
package com.example.myapplication
import android.app.Application
import com.example.myapplication.database.AppContainer
import com.example.myapplication.database.AppDataContainer
import com.example.myapplication.database.room.repository.AppContainer
import com.example.myapplication.database.room.repository.AppDataContainer
class BikeApplication : Application() {
lateinit var container: AppContainer

View File

@ -9,8 +9,8 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import com.example.myapplication.composeui.navigation.MainNavbar
import com.example.myapplication.datastore.DataStoreManager
import com.example.myapplication.ui.navigation.MainNavbar
import com.example.myapplication.setting.DataStoreManager
import com.example.myapplication.ui.theme.PmudemoTheme
class MainComposeActivity : ComponentActivity() {

View File

@ -1,12 +1,13 @@
package com.example.myapplication.api
import com.example.myapplication.api.bike.BikeRemote
import com.example.myapplication.api.rent.RentRemote
import com.example.myapplication.api.item.ItemFromBikeRemote
import com.example.myapplication.api.item.ItemRemote
import com.example.myapplication.api.item.ItemWithBikeRemote
import com.example.myapplication.api.report.ReportRemote
import com.example.myapplication.api.user.UserRemote
import com.example.myapplication.api.bike.remote.BikeRemote
import com.example.myapplication.api.rent.remote.RentRemote
import com.example.myapplication.api.item.remote.ItemFromBikeRemote
import com.example.myapplication.api.item.remote.ItemRemote
import com.example.myapplication.api.item.remote.ItemWithBikeRemote
import com.example.myapplication.api.report.remote.ReportRemote
import com.example.myapplication.api.user.remote.UserRemote
import com.example.myapplication.setting.LocalDateTimeSerializer
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import kotlinx.serialization.json.Json
import kotlinx.serialization.modules.SerializersModule
@ -147,9 +148,9 @@ interface MyServerService {
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/"
@Volatile
@ -165,9 +166,9 @@ interface MyServerService {
serializersModule = SerializersModule {
contextual(LocalDateTimeSerializer)
}
} // Создаем экземпляр Json с ignoreUnknownKeys = true
}
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 }
}
}

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.bike
package com.example.myapplication.api.bike.mediator
import androidx.paging.ExperimentalPagingApi
import androidx.paging.LoadType
@ -6,14 +6,15 @@ import androidx.paging.PagingState
import androidx.paging.RemoteMediator
import androidx.room.withTransaction
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.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.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 java.io.IOException

View File

@ -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
@Serializable

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.bike
package com.example.myapplication.api.bike.repository
import android.util.Log
import androidx.paging.ExperimentalPagingApi
@ -6,15 +6,18 @@ import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
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.entities.model.Bike
import com.example.myapplication.database.entities.model.BikeWithItems
import com.example.myapplication.database.entities.model.ItemFromBike
import com.example.myapplication.database.entities.repository.BikeRepository
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
import com.example.myapplication.database.entities.repository.OfflineItemRepository
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.model.bike.BikeWithItems
import com.example.myapplication.database.room.model.item.ItemFromBike
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
import com.example.myapplication.database.room.repository.online.BikeRepository
import kotlinx.coroutines.flow.Flow
class RestBikeRepository(

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.item
package com.example.myapplication.api.item.remote
/*
@Serializable

View File

@ -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.Serializable
import org.threeten.bp.LocalDateTime

View File

@ -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.toBike
import com.example.myapplication.database.entities.model.ItemFromCart
import com.example.myapplication.api.bike.remote.BikeRemote
import com.example.myapplication.api.bike.remote.toBike
import com.example.myapplication.database.room.model.item.ItemFromCart
import kotlinx.serialization.Serializable
import org.threeten.bp.LocalDateTime

View File

@ -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.toBike
import com.example.myapplication.database.entities.model.ItemFromRent
import com.example.myapplication.api.bike.remote.BikeRemote
import com.example.myapplication.api.bike.remote.toBike
import com.example.myapplication.database.room.model.item.ItemFromRent
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import org.threeten.bp.LocalDateTime

View File

@ -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.Serializable
import org.threeten.bp.LocalDateTime

View File

@ -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.database.entities.model.Item
import com.example.myapplication.api.bike.remote.BikeRemote
import com.example.myapplication.database.room.model.item.Item
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import org.threeten.bp.LocalDateTime

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.item
package com.example.myapplication.api.item.repository
import android.content.ContentResolver
import android.content.ContentValues
@ -11,12 +11,14 @@ import android.net.Uri
import android.os.Environment
import android.provider.MediaStore
import com.example.myapplication.api.MyServerService
import com.example.myapplication.api.report.ReportRemote
import com.example.myapplication.database.entities.model.Item
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
import com.example.myapplication.database.entities.repository.OfflineItemRepository
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
import com.example.myapplication.database.entities.repository.ItemRepository
import com.example.myapplication.api.item.remote.toItem
import com.example.myapplication.api.item.remote.toItemRemote
import com.example.myapplication.api.report.remote.ReportRemote
import com.example.myapplication.database.room.model.item.Item
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
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.withContext
import java.io.IOException
@ -108,7 +110,7 @@ class RestItemRepository(
val canvas = page.canvas
val paint = Paint()
paint.textSize = 16f // Уменьшаем размер шрифта для лучшей видимости
paint.textSize = 16f
paint.isAntiAlias = true
// Отображаем заголовок
@ -120,8 +122,8 @@ class RestItemRepository(
// Отображаем данные в виде таблицы
val tableStartY = yTitle + 60f
val columnWidths = floatArrayOf(0.5f, 1f, 0.6f, 0.5f, 1f, 1f, 1f) // Увеличиваем ширину столбцов
val rowHeight = 30f // Увеличиваем высоту строки
val columnWidths = floatArrayOf(0.5f, 1f, 0.6f, 0.5f, 1f, 1f, 1f)
val rowHeight = 30f
drawTableRow(canvas, arrayOf("ID", "Дата", "Вес", "R", "Цвет", "Кол-во", "Имя"), columnWidths, tableStartY, paint)
@ -155,7 +157,7 @@ class RestItemRepository(
for (i in row.indices) {
val text = row[i]
canvas.drawText(text, x, y, paint)
x += columnWidths[i] * 80 // Увеличиваем ширину столбцов
x += columnWidths[i] * 80
}
}
}

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.rent
package com.example.myapplication.api.rent.mediator
import androidx.paging.ExperimentalPagingApi
import androidx.paging.LoadType
@ -6,12 +6,13 @@ import androidx.paging.PagingState
import androidx.paging.RemoteMediator
import androidx.room.withTransaction
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.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.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 java.io.IOException

View File

@ -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.database.entities.model.Rent
import com.example.myapplication.api.item.remote.ItemFromRentRemote
import com.example.myapplication.database.room.model.rent.Rent
import kotlinx.serialization.Serializable
@Serializable

View File

@ -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.item.ItemFromRentRemote
import com.example.myapplication.api.item.toItem
import com.example.myapplication.database.entities.model.RentItemCrossRef
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
import com.example.myapplication.database.entities.repository.RentItemRepository
import com.example.myapplication.api.item.remote.ItemFromRentRemote
import com.example.myapplication.api.item.remote.toItem
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
import com.example.myapplication.database.room.repository.online.RentItemRepository
class RestRentItemRepository(
private val service: MyServerService,

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.rent
package com.example.myapplication.api.rent.repository
import android.util.Log
import androidx.paging.ExperimentalPagingApi
@ -6,18 +6,21 @@ import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.example.myapplication.api.MyServerService
import com.example.myapplication.api.bike.toBikeRemote
import com.example.myapplication.api.item.toItemFromRent
import com.example.myapplication.database.AppContainer
import com.example.myapplication.api.bike.remote.toBikeRemote
import com.example.myapplication.api.item.remote.toItemFromRent
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.entities.model.Rent
import com.example.myapplication.database.entities.model.RentItemCrossRef
import com.example.myapplication.database.entities.model.ItemFromRent
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
import com.example.myapplication.database.entities.repository.OfflineRentRepository
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
import com.example.myapplication.database.entities.repository.RentRepository
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
import com.example.myapplication.database.room.model.item.ItemFromRent
import com.example.myapplication.database.room.model.rent.Rent
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
import com.example.myapplication.database.room.repository.offline.OfflineRentRepository
import com.example.myapplication.database.room.repository.online.RentRepository
import kotlinx.coroutines.flow.Flow
class RestRentRepository(

View File

@ -1,4 +1,4 @@
package com.example.myapplication.api.report
package com.example.myapplication.api.report.remote
import kotlinx.serialization.Serializable

View File

@ -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.database.entities.model.User
import com.example.myapplication.api.item.remote.ItemFromCartRemote
import com.example.myapplication.database.room.model.user.User
import kotlinx.serialization.Serializable
@Serializable

View File

@ -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.item.toItemFromCart
import com.example.myapplication.database.entities.model.ItemFromCart
import com.example.myapplication.database.entities.model.User
import com.example.myapplication.database.entities.model.UserItemCrossRef
import com.example.myapplication.database.entities.repository.OfflineUserRepository
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
import com.example.myapplication.database.entities.repository.UserRepository
import kotlinx.coroutines.flow.Flow
import com.example.myapplication.api.item.remote.toItemFromCart
import com.example.myapplication.api.user.remote.toUser
import com.example.myapplication.api.user.remote.toUserRemote
import com.example.myapplication.database.room.model.item.ItemFromCart
import com.example.myapplication.database.room.model.user.User
import com.example.myapplication.database.room.model.user.UserItemCrossRef
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
import com.example.myapplication.database.room.repository.offline.OfflineUserRepository
import com.example.myapplication.database.room.repository.online.UserRepository
class RestUserRepository(
private val service: MyServerService,

View File

@ -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.item.ItemFromCartRemote
import com.example.myapplication.api.item.toItem
import com.example.myapplication.database.entities.model.UserItemCrossRef
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
import com.example.myapplication.database.entities.repository.UserItemRepository
import com.example.myapplication.api.item.remote.ItemFromCartRemote
import com.example.myapplication.api.item.remote.toItem
import com.example.myapplication.database.room.model.user.UserItemCrossRef
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
import com.example.myapplication.database.room.repository.online.UserItemRepository
class RestUserItemRepository(
private val service: MyServerService,

View File

@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.myapplication.R
import com.example.myapplication.database.entities.composeui.AppViewModelProvider
import com.example.myapplication.database.entities.composeui.CartUiState
import com.example.myapplication.database.entities.composeui.CartViewModel
import com.example.myapplication.database.entities.composeui.CurrentUserViewModel
import com.example.myapplication.database.entities.composeui.ErroreList
import com.example.myapplication.database.entities.model.Item
import com.example.myapplication.database.entities.model.ItemFromCart
import com.example.myapplication.database.AppViewModelProvider
import com.example.myapplication.database.room.model.item.Item
import com.example.myapplication.database.room.model.item.ItemFromCart
import com.example.myapplication.database.room.viewmodel.cart.CartUiState
import com.example.myapplication.database.room.viewmodel.cart.CartViewModel
import com.example.myapplication.database.room.viewmodel.user.CurrentUserViewModel
import com.example.myapplication.ui.theme.PmudemoTheme
import kotlinx.coroutines.delay
import com.example.myapplication.ui.view.ErroreView
import kotlinx.coroutines.launch
import org.threeten.bp.format.DateTimeFormatter
@Composable
fun Cart(
fun CartList(
viewModel: CartViewModel = viewModel(factory = AppViewModelProvider.Factory),
currentUserViewModel: CurrentUserViewModel = viewModel(factory = AppViewModelProvider.Factory)
) {
@ -81,7 +78,7 @@ fun Cart(
getUser?.uid?.let { viewModel.refreshState(it) }
}
Cart(
CartList(
cartUiState = cartUiState,
modifier = Modifier
.padding(all = 10.dp),
@ -126,12 +123,12 @@ fun Cart(
}
)
} else {
ErroreList()
ErroreView()
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun Cart(
private fun CartList(
cartUiState: CartUiState,
modifier: Modifier,
onSwipe: (ItemFromCart) -> Unit,
@ -331,7 +328,7 @@ fun CartPreview() {
Surface(
color = MaterialTheme.colorScheme.background
) {
Cart()
CartList()
}
}
}

View File

@ -7,21 +7,21 @@ import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
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.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.Dispatchers
import kotlinx.coroutines.launch
@ -62,79 +62,7 @@ abstract class AppDatabase : RoomDatabase() {
val userDao = database.userDao()
val user1 = User(1, "login", "admin", "password")
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)*/
}
}

View File

@ -1,4 +1,4 @@
package com.example.myapplication.database.entities.composeui
package com.example.myapplication.database
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.createSavedStateHandle
@ -7,7 +7,17 @@ import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import com.example.myapplication.BikeApplication
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 {
val Factory = viewModelFactory {

View File

@ -4,9 +4,9 @@ import androidx.room.Entity
import androidx.room.PrimaryKey
import androidx.room.TypeConverter
import androidx.room.TypeConverters
import com.example.myapplication.database.entities.model.Bike
import com.example.myapplication.database.entities.model.Rent
import com.example.myapplication.database.entities.model.Item
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
enum class RemoteKeyType(private val type: String) {
CINEMA(Bike::class.simpleName ?: "Bike"),

View File

@ -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.model.RemoteKeyType
import com.example.myapplication.database.remotekeys.model.RemoteKeys
import com.example.myapplication.database.remotekeys.repository.RemoteKeyRepository
class OfflineRemoteKeyRepository(private val remoteKeysDao: RemoteKeysDao) : RemoteKeyRepository {
override suspend fun getAllRemoteKeys(id: Int, type: RemoteKeyType) =

View File

@ -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.room.Dao
@ -6,8 +6,8 @@ import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.myapplication.database.entities.model.Bike
import com.example.myapplication.database.entities.model.ItemFromBike
import com.example.myapplication.database.room.model.bike.Bike
import com.example.myapplication.database.room.model.item.ItemFromBike
import kotlinx.coroutines.flow.Flow
@Dao

View File

@ -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.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.myapplication.database.entities.model.Item
import com.example.myapplication.database.room.model.item.Item
@Dao
interface ItemDao {

View File

@ -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.room.Dao
@ -6,8 +6,8 @@ import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.myapplication.database.entities.model.Rent
import com.example.myapplication.database.entities.model.ItemFromRent
import com.example.myapplication.database.room.model.item.ItemFromRent
import com.example.myapplication.database.room.model.rent.Rent
@Dao
interface RentDao {

View File

@ -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.Delete
@ -6,7 +6,7 @@ import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.myapplication.database.entities.model.RentItemCrossRef
import com.example.myapplication.database.room.model.rent.RentItemCrossRef
@Dao
interface RentItemCrossRefDao {

View File

@ -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.Delete
@ -6,8 +6,8 @@ import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.myapplication.database.entities.model.ItemFromCart
import com.example.myapplication.database.entities.model.User
import com.example.myapplication.database.room.model.item.ItemFromCart
import com.example.myapplication.database.room.model.user.User
import kotlinx.coroutines.flow.Flow
@Dao

View File

@ -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.Delete
@ -6,7 +6,7 @@ import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.myapplication.database.entities.model.UserItemCrossRef
import com.example.myapplication.database.room.model.user.UserItemCrossRef
@Dao
interface UserItemCrossRefDao {

View File

@ -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.Entity

View File

@ -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(
val bike: Bike,

View File

@ -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.Entity
import androidx.room.ForeignKey
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.example.myapplication.database.room.model.bike.Bike
import org.threeten.bp.LocalDateTime
@Entity(

View File

@ -1,4 +1,4 @@
package com.example.myapplication.database.entities.model
package com.example.myapplication.database.room.model.item
import androidx.room.ColumnInfo
import org.threeten.bp.LocalDateTime

View File

@ -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.Relation
import com.example.myapplication.database.room.model.bike.Bike
import org.threeten.bp.LocalDateTime
data class ItemFromCart(

View File

@ -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.Relation
import com.example.myapplication.database.room.model.bike.Bike
import org.threeten.bp.LocalDateTime
data class ItemFromRent(

View File

@ -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.Entity
import androidx.room.ForeignKey
import androidx.room.PrimaryKey
import com.example.myapplication.database.room.model.user.User
@Entity(
tableName = "rents", foreignKeys = [

View File

@ -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.Entity

View File

@ -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.PrimaryKey

View File

@ -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.Entity

View File

@ -1,20 +1,21 @@
package com.example.myapplication.database
package com.example.myapplication.database.room.repository
import android.content.Context
import com.example.myapplication.api.MyServerService
import com.example.myapplication.api.bike.RestBikeRepository
import com.example.myapplication.api.rent.RestRentRepository
import com.example.myapplication.api.rentitem.RestRentItemRepository
import com.example.myapplication.api.item.RestItemRepository
import com.example.myapplication.api.user.RestUserRepository
import com.example.myapplication.api.useritem.RestUserItemRepository
import com.example.myapplication.database.entities.repository.OfflineBikeRepository
import com.example.myapplication.database.entities.repository.OfflineRentRepository
import com.example.myapplication.database.entities.repository.OfflineRentItemRepository
import com.example.myapplication.database.entities.repository.OfflineItemRepository
import com.example.myapplication.database.entities.repository.OfflineUserRepository
import com.example.myapplication.database.entities.repository.OfflineUserItemRepository
import com.example.myapplication.database.remotekeys.repository.OfflineRemoteKeyRepository
import com.example.myapplication.api.bike.repository.RestBikeRepository
import com.example.myapplication.api.rent.repository.RestRentRepository
import com.example.myapplication.api.rent.rentitem.repository.RestRentItemRepository
import com.example.myapplication.api.item.repository.RestItemRepository
import com.example.myapplication.api.user.repository.RestUserRepository
import com.example.myapplication.api.useritem.repository.RestUserItemRepository
import com.example.myapplication.database.AppDatabase
import com.example.myapplication.database.remotekeys.repository.offline.OfflineRemoteKeyRepository
import com.example.myapplication.database.room.repository.offline.OfflineBikeRepository
import com.example.myapplication.database.room.repository.offline.OfflineItemRepository
import com.example.myapplication.database.room.repository.offline.OfflineRentItemRepository
import com.example.myapplication.database.room.repository.offline.OfflineRentRepository
import com.example.myapplication.database.room.repository.offline.OfflineUserItemRepository
import com.example.myapplication.database.room.repository.offline.OfflineUserRepository
interface AppContainer {
val bikeRestRepository: RestBikeRepository

View File

@ -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.PagingConfig
import androidx.paging.PagingData
import androidx.paging.PagingSource
import com.example.myapplication.database.AppContainer
import com.example.myapplication.database.entities.dao.BikeDao
import com.example.myapplication.database.entities.model.Bike
import com.example.myapplication.database.entities.model.BikeWithItems
import com.example.myapplication.database.room.dao.bike.BikeDao
import com.example.myapplication.database.room.model.bike.Bike
import com.example.myapplication.database.room.model.bike.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.first
import kotlinx.coroutines.flow.map

View File

@ -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.entities.model.Item
import com.example.myapplication.database.room.dao.item.ItemDao
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 {
override suspend fun getItem(uid: Int): Item = itemDao.getByUid(uid)

View File

@ -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) :
RentItemRepository {

View File

@ -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.PagingConfig
import androidx.paging.PagingData
import androidx.paging.PagingSource
import com.example.myapplication.database.AppContainer
import com.example.myapplication.database.entities.dao.RentDao
import com.example.myapplication.database.entities.model.Rent
import com.example.myapplication.database.entities.model.ItemFromRent
import com.example.myapplication.database.room.dao.rent.RentDao
import com.example.myapplication.database.room.model.item.ItemFromRent
import com.example.myapplication.database.room.model.rent.Rent
import com.example.myapplication.database.room.repository.AppContainer
import com.example.myapplication.database.room.repository.online.RentRepository
import kotlinx.coroutines.flow.Flow
class OfflineRentRepository(private val rentDao: RentDao) : RentRepository {

View File

@ -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.entities.model.UserItemCrossRef
import com.example.myapplication.database.room.dao.user.UserItemCrossRefDao
import com.example.myapplication.database.room.model.user.UserItemCrossRef
import com.example.myapplication.database.room.repository.online.UserItemRepository
class OfflineUserItemRepository(private val userItemDao: UserItemCrossRefDao) :
UserItemRepository {

View File

@ -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.entities.model.ItemFromCart
import com.example.myapplication.database.entities.model.User
import kotlinx.coroutines.flow.Flow
import com.example.myapplication.database.room.dao.user.UserDao
import com.example.myapplication.database.room.model.item.ItemFromCart
import com.example.myapplication.database.room.model.user.User
import com.example.myapplication.database.room.repository.online.UserRepository
import kotlinx.coroutines.flow.first
class OfflineUserRepository(private val userDao: UserDao) : UserRepository {

View File

@ -1,8 +1,8 @@
package com.example.myapplication.database.entities.repository
package com.example.myapplication.database.room.repository.online
import androidx.paging.PagingData
import com.example.myapplication.database.entities.model.Bike
import com.example.myapplication.database.entities.model.BikeWithItems
import com.example.myapplication.database.room.model.bike.Bike
import com.example.myapplication.database.room.model.bike.BikeWithItems
import kotlinx.coroutines.flow.Flow
interface BikeRepository {

View File

@ -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 {
suspend fun getItem(uid: Int): Item

View File

@ -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 {
suspend fun insertRentItem(rentItemCrossRef: RentItemCrossRef)

View File

@ -1,8 +1,8 @@
package com.example.myapplication.database.entities.repository
package com.example.myapplication.database.room.repository.online
import androidx.paging.PagingData
import com.example.myapplication.database.entities.model.Rent
import com.example.myapplication.database.entities.model.ItemFromRent
import com.example.myapplication.database.room.model.item.ItemFromRent
import com.example.myapplication.database.room.model.rent.Rent
import kotlinx.coroutines.flow.Flow
interface RentRepository {

View File

@ -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 {
suspend fun insertUserItem(userItemCrossRef: UserItemCrossRef)

View File

@ -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 {
suspend fun getAllUsers(): List<User>

View File

@ -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.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
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.ItemFromCart
import com.example.myapplication.database.entities.model.UserItemCrossRef
import com.example.myapplication.database.entities.repository.RentRepository
import com.example.myapplication.database.entities.repository.RentItemRepository
import com.example.myapplication.database.entities.repository.UserRepository
import com.example.myapplication.database.entities.repository.UserItemRepository
import kotlinx.coroutines.delay
import com.example.myapplication.database.room.model.item.Item
import com.example.myapplication.database.room.model.item.ItemFromCart
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.UserItemCrossRef
import com.example.myapplication.database.room.repository.online.RentItemRepository
import com.example.myapplication.database.room.repository.online.RentRepository
import com.example.myapplication.database.room.repository.online.UserItemRepository
import com.example.myapplication.database.room.repository.online.UserRepository
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
class CartViewModel(
private val userItemRepository: UserItemRepository,

View File

@ -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.entities.model.Item
import com.example.myapplication.database.entities.model.ItemFromBike
import com.example.myapplication.database.entities.model.UserItemCrossRef
import com.example.myapplication.database.entities.repository.ItemRepository
import com.example.myapplication.database.entities.repository.UserItemRepository
import com.example.myapplication.database.room.model.item.Item
import com.example.myapplication.database.room.model.item.ItemFromBike
import com.example.myapplication.database.room.model.user.UserItemCrossRef
import com.example.myapplication.database.room.repository.online.ItemRepository
import com.example.myapplication.database.room.repository.online.UserItemRepository
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
class ItemListViewModel(
private val itemRepository: ItemRepository,

View File

@ -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 com.example.myapplication.database.entities.model.Rent
import com.example.myapplication.database.entities.repository.RentRepository
import com.example.myapplication.database.room.model.rent.Rent
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.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow

View File

@ -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.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.database.AppContainer
import com.example.myapplication.database.entities.model.ItemFromRent
import com.example.myapplication.database.entities.repository.RentRepository
import com.example.myapplication.database.room.model.item.ItemFromRent
import com.example.myapplication.database.room.repository.AppContainer
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.StateFlow
import kotlinx.coroutines.flow.flow

View File

@ -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.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.api.item.RestItemRepository
import com.example.myapplication.api.report.ReportRemote
import com.example.myapplication.api.item.repository.RestItemRepository
import com.example.myapplication.api.report.remote.ReportRemote
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
import kotlinx.coroutines.launch
import java.text.ParseException
import java.text.SimpleDateFormat

View File

@ -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.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.database.entities.model.User
import com.example.myapplication.database.entities.repository.UserRepository
import com.example.myapplication.database.room.model.user.User
import com.example.myapplication.database.room.repository.online.UserRepository
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
import kotlinx.coroutines.launch
class CurrentUserViewModel(private val userRepository: UserRepository) : ViewModel(){

View File

@ -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.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.database.entities.model.User
import com.example.myapplication.database.entities.repository.UserRepository
import com.example.myapplication.database.room.model.user.User
import com.example.myapplication.database.room.repository.online.UserRepository
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
import kotlinx.coroutines.launch
class EntryUserViewModel(private val userRepository: UserRepository) : ViewModel() {

View File

@ -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.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.database.entities.model.User
import com.example.myapplication.database.entities.repository.UserRepository
import com.example.myapplication.database.room.model.user.User
import com.example.myapplication.database.room.repository.online.UserRepository
import com.example.myapplication.database.room.viewmodel.LoadingViewModel
import kotlinx.coroutines.launch
class RegisterUserViewModel(private val userRepository: UserRepository) : ViewModel() {

View File

@ -1,4 +1,4 @@
package com.example.myapplication.datastore
package com.example.myapplication.setting
import android.content.Context
import androidx.datastore.core.DataStore

View File

@ -1,4 +1,4 @@
package com.example.myapplication.database.entities.composeui.edit
package com.example.myapplication.setting
import android.graphics.Bitmap
import android.graphics.BitmapFactory

View File

@ -1,4 +1,4 @@
package com.example.myapplication.database.entities.model
package com.example.myapplication.setting
import androidx.room.TypeConverter
import org.threeten.bp.LocalDateTime

View File

@ -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.descriptors.*
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import org.threeten.bp.LocalDateTime
import org.threeten.bp.DateTimeUtils.toLocalDateTime
import org.threeten.bp.format.DateTimeFormatter
@Serializer(forClass = LocalDateTime::class)
object LocalDateTimeSerializer: KSerializer<LocalDateTime> {

View File

@ -1,4 +1,4 @@
package com.example.myapplication.datastore
package com.example.myapplication.setting
data class SettingData(
val isDarkTheme: Boolean

View File

@ -1,7 +1,6 @@
package com.example.myapplication.database.entities.composeui.edit
package com.example.myapplication.ui.edit
import android.annotation.SuppressLint
import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@ -29,7 +28,6 @@ import androidx.compose.material3.rememberDatePickerState
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
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.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import com.example.myapplication.composeui.navigation.Screen
import com.example.myapplication.database.entities.composeui.AppViewModelProvider
import com.example.myapplication.database.entities.composeui.CurrentUserViewModel
import com.example.myapplication.database.AppViewModelProvider
import com.example.myapplication.database.room.viewmodel.user.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 org.threeten.bp.Instant
import org.threeten.bp.LocalDateTime

View File

@ -1,4 +1,4 @@
package com.example.myapplication.database.entities.composeui
package com.example.myapplication.ui.list
import android.graphics.BitmapFactory
import android.util.Log
@ -37,7 +37,11 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
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 org.threeten.bp.format.DateTimeFormatter

View File

@ -1,16 +1,13 @@
package com.example.myapplication.database.entities.composeui
package com.example.myapplication.ui.list
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
@ -29,7 +26,6 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
@ -37,7 +33,11 @@ import androidx.navigation.NavController
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemContentType
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 kotlinx.coroutines.launch
@ -105,7 +105,7 @@ fun RentList(
}
} else {
// Пользователь не авторизован, показываем экран с сообщением
ErroreList()
ErroreView()
}
}

View File

@ -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.foundation.BorderStroke
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.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
@ -35,26 +23,16 @@ import androidx.compose.material.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DisplayMode
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
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.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
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.res.stringResource
import androidx.compose.ui.text.TextStyle
@ -64,22 +42,15 @@ import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import com.example.myapplication.R
import com.example.myapplication.api.report.ReportRemote
import com.example.myapplication.composeui.navigation.Screen
import kotlinx.coroutines.Dispatchers
import com.example.myapplication.api.report.remote.ReportRemote
import com.example.myapplication.database.AppViewModelProvider
import com.example.myapplication.database.room.viewmodel.rent.ReportViewModel
import com.example.myapplication.ui.navigation.Screen
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)
@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

View File

@ -1,17 +1,6 @@
package com.example.myapplication.database.entities.composeui
package com.example.myapplication.ui.list
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 androidx.compose.animation.AnimatedVisibility
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.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
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.text.BasicTextField
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.Card
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Snackbar
import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text
@ -53,7 +36,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
@ -67,22 +49,19 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import com.example.myapplication.R
import com.example.myapplication.composeui.navigation.Screen
import com.example.myapplication.database.entities.model.User
import com.example.myapplication.datastore.DataStoreManager
import com.example.myapplication.datastore.SettingData
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import com.example.myapplication.database.AppViewModelProvider
import com.example.myapplication.database.room.model.user.User
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.user.RegisterUserViewModel
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.withContext
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
import java.io.OutputStream
@SuppressLint("UnrememberedMutableState")
@Composable
fun UserProfile(
fun UserList(
navController: NavController?,
isDarkTheme: MutableState<Boolean>,
dataStoreManager: DataStoreManager,

View File

@ -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.clickable
@ -47,19 +47,19 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.example.myapplication.composeui.Cart
import com.example.myapplication.database.entities.composeui.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.composeui.CartList
import com.example.myapplication.database.AppViewModelProvider
import com.example.myapplication.database.entities.composeui.edit.BikeEdit
import com.example.myapplication.database.entities.composeui.edit.ItemEdit
import com.example.myapplication.datastore.DataStoreManager
import com.example.myapplication.ui.list.BikeList
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
fun Topbar(
@ -189,9 +189,9 @@ fun Navhost(
) {
composable(Screen.BikeList.route) { BikeList(navController, currentUserViewModel = currentUserViewModel) }
composable(Screen.RentList.route) { RentList(navController, currentUserViewModel = currentUserViewModel) }
composable(Screen.Cart.route) { Cart(currentUserViewModel = currentUserViewModel) }
composable(Screen.UserProfile.route) { UserProfile(navController,isDarkTheme, dataStore, currentUserViewModel = currentUserViewModel) }
composable(Screen.Report.route) { ReportPage(navController = navController) }
composable(Screen.Cart.route) { CartList(currentUserViewModel = currentUserViewModel) }
composable(Screen.UserProfile.route) { UserList(navController,isDarkTheme, dataStore, currentUserViewModel = currentUserViewModel) }
composable(Screen.Report.route) { ReportList(navController = navController) }
composable(Screen.LoginScreen.route) { LoginScreen(navController) }
composable(
Screen.BikeEdit.route,

View File

@ -1,4 +1,4 @@
package com.example.myapplication.composeui.navigation
package com.example.myapplication.ui.navigation
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons

View File

@ -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.Column
@ -14,7 +14,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
@Composable
fun ErroreList() {
fun ErroreView() {
Column(
modifier = Modifier
.fillMaxSize()

View File

@ -1,4 +1,4 @@
package com.example.myapplication.database.entities.composeui
package com.example.myapplication.ui.view
import android.content.res.Configuration
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.unit.dp
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 org.threeten.bp.format.DateTimeFormatter

View File

@ -2,9 +2,9 @@
<network-security-config>
<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-config>
</network-security-config>

File diff suppressed because it is too large Load Diff