Merge remote-tracking branch 'origin/master'

This commit is contained in:
senijan 2025-02-19 15:51:41 +03:00
commit a2cf3cfbae
53 changed files with 429 additions and 91 deletions
app
build.gradle.kts
src/main
java/ru/myitschool/work
res/layout

@ -68,6 +68,7 @@ dependencies {
implementation(libs.androidx.camera.mlkit.vision)
implementation(libs.androidx.paging.runtime.ktx)
defaultLibrary()
implementation(libs.hilt.android)
kapt(libs.hilt.android.compiler)
}

@ -0,0 +1,36 @@
package ru.myitschool.work.data.deleteEmployee
import android.content.Context
import io.ktor.client.call.body
import io.ktor.client.request.basicAuth
import io.ktor.client.request.patch
import io.ktor.http.HttpStatusCode
import io.ktor.http.headers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.utils.NetworkModule
class DeleteEmployeeNetworkDataSource(
context: Context
) {
private val client = NetworkModule.httpClient
private val userDataStoreManager = UserDataStoreManager.getInstance(context)
suspend fun deleteEmployee(login: String):Result<Unit> = withContext(Dispatchers.IO){
runCatching {
val username = userDataStoreManager.usernameFlow.first()
val password = userDataStoreManager.passwordFlow.first()
val result = client.patch("${Constants.SERVER_ADDRESS}/api/employee/$login/delete"){
headers{
basicAuth(username, password)
}
}
if (result.status != HttpStatusCode.OK) {
error("Status ${result.status}")
}
result.body()
}
}
}

@ -0,0 +1,9 @@
package ru.myitschool.work.data.deleteEmployee
import ru.myitschool.work.domain.deleteEmployee.DeleteEmployeeRepo
class DeleteEmployeeRepoImpl : DeleteEmployeeRepo {
override suspend fun deleteEmployee(login: String): Result<Unit> {
TODO("Not yet implemented")
}
}

@ -1,4 +1,4 @@
package ru.myitschool.work.data.door
package ru.myitschool.work.data.door.open
import android.content.Context
import io.ktor.client.call.body

@ -1,6 +1,6 @@
package ru.myitschool.work.data.door
package ru.myitschool.work.data.door.open
import ru.myitschool.work.domain.door.DoorRepo
import ru.myitschool.work.domain.door.open.DoorRepo
class DoorRepoImpl(
private val networkDataSource: DoorNetworkDataSource

@ -0,0 +1,40 @@
package ru.myitschool.work.data.employeeList
import android.content.Context
import io.ktor.client.call.body
import io.ktor.client.request.basicAuth
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpStatusCode
import io.ktor.http.headers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.dto.EmployeePagingDTO
import ru.myitschool.work.utils.NetworkModule
class EmployeeListNetworkDataSource(
context: Context
) {
private val client = NetworkModule.httpClient
private val userDataStoreManager = UserDataStoreManager.getInstance(context)
suspend fun getInfo():Result<EmployeePagingDTO> = withContext(Dispatchers.IO){
runCatching {
val username = userDataStoreManager.usernameFlow.first()
val password = userDataStoreManager.passwordFlow.first()
val result = client.get("${Constants.SERVER_ADDRESS}/api/employee/all"){
headers{
basicAuth(username, password)
}
}
if (result.status != HttpStatusCode.OK) {
error("Status ${result.status}")
}
println(result.bodyAsText())
result.body()
}
}
}

@ -0,0 +1,10 @@
package ru.myitschool.work.data.employeeList
import ru.myitschool.work.domain.employeeList.EmployeeListRepo
import ru.myitschool.work.entities.EmployeeEntity
class EmployeeListRepoImpl : EmployeeListRepo {
override suspend fun getList(): Result<List<EmployeeEntity>> {
TODO("Not yet implemented")
}
}

@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.data.dto.EmployeeEntranceListPagingDTO
import ru.myitschool.work.dto.EmployeeEntranceListPagingDTO
import ru.myitschool.work.utils.NetworkModule
class AllEntranceListNetworkDataSource(

@ -1,7 +1,7 @@
package ru.myitschool.work.data.entrance.allEntrances
import ru.myitschool.work.domain.employeeEntrance.allEntrances.AllEntranceListRepo
import ru.myitschool.work.domain.entities.EmployeeEntranceEntity
import ru.myitschool.work.entities.EmployeeEntranceEntity
class AllEntranceListRepoImpl(
private val networkDataSource: AllEntranceListNetworkDataSource

@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.data.dto.EmployeeEntranceListPagingDTO
import ru.myitschool.work.dto.EmployeeEntranceListPagingDTO
import ru.myitschool.work.utils.NetworkModule
class EmployeeEntranceListNetworkDataSource(

@ -1,6 +1,6 @@
package ru.myitschool.work.data.entrance.employeeEntrances
import ru.myitschool.work.domain.entities.EmployeeEntranceEntity
import ru.myitschool.work.entities.EmployeeEntranceEntity
import ru.myitschool.work.domain.employeeEntrance.employeeEntrances.EmployeeEntranceListRepo
class EmployeeEntranceListRepoImpl(

@ -0,0 +1,39 @@
package ru.myitschool.work.data.entrance.lastEntrance
import android.content.Context
import io.ktor.client.call.body
import io.ktor.client.request.basicAuth
import io.ktor.client.request.post
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpStatusCode
import io.ktor.http.headers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.dto.EmployeeEntranceDTO
import ru.myitschool.work.utils.NetworkModule
class LastEntranceNetworkDataSource(
context: Context
) {
private val client = NetworkModule.httpClient
private val userDataStoreManager = UserDataStoreManager.getInstance(context)
suspend fun getLastEntrance():Result<EmployeeEntranceDTO> = withContext(Dispatchers.IO){
runCatching {
val username = userDataStoreManager.usernameFlow.first()
val password = userDataStoreManager.passwordFlow.first()
val result = client.post("${Constants.SERVER_ADDRESS}/api/entrance/last"){
headers{
basicAuth(username, password)
}
}
if (result.status != HttpStatusCode.OK) {
error("Status ${result.status}")
}
println(result.bodyAsText())
result.body()
}
}
}

@ -0,0 +1,19 @@
package ru.myitschool.work.data.entrance.lastEntrance
import ru.myitschool.work.domain.employeeEntrance.lastEntrance.LastEntranceRepo
import ru.myitschool.work.entities.EmployeeEntranceEntity
class LastEntranceRepoImpl(
private val networkDataSource: LastEntranceNetworkDataSource
) : LastEntranceRepo {
override suspend fun getLastEntrance(): Result<EmployeeEntranceEntity> {
return networkDataSource.getLastEntrance().map { dto ->
EmployeeEntranceEntity(
id = dto.id ?: 0,
scanTime = dto.scanTime,
readerName = dto.readerName ?: "",
type = dto.type ?: ""
)
}
}
}

@ -1,22 +0,0 @@
package ru.myitschool.work.data.info
import ru.myitschool.work.domain.entities.UserEntity
import ru.myitschool.work.domain.info.InfoRepo
class InfoRepoImpl(
private val networkDataSource: InfoNetworkDataSource
): InfoRepo {
override suspend fun getInfo(): Result<UserEntity> {
return networkDataSource.getInfo().map { dto->
UserEntity(
id = dto.id ?: 0,
login = dto.login ?: "",
name = dto.name ?: "",
authority = dto.authority ?: "",
photoUrl = dto.photoUrl,
position = dto.position ?: ""
)
}
}
}

@ -1,4 +1,4 @@
package ru.myitschool.work.data.info
package ru.myitschool.work.data.profile
import android.content.Context
import io.ktor.client.call.body
@ -12,16 +12,16 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.data.dto.UserDTO
import ru.myitschool.work.dto.EmployeeDTO
import ru.myitschool.work.utils.NetworkModule
class InfoNetworkDataSource(
class ProfileNetworkDataSource(
context: Context
) {
private val client = NetworkModule.httpClient
private val userDataStoreManager = UserDataStoreManager.getInstance(context)
suspend fun getInfo():Result<UserDTO> = withContext(Dispatchers.IO){
suspend fun getInfo():Result<EmployeeDTO> = withContext(Dispatchers.IO){
runCatching {
val username = userDataStoreManager.usernameFlow.first()
val password = userDataStoreManager.passwordFlow.first()

@ -0,0 +1,23 @@
package ru.myitschool.work.data.profile
import ru.myitschool.work.entities.EmployeeEntity
import ru.myitschool.work.domain.profile.ProfileRepo
class ProfileRepoImpl(
private val networkDataSource: ProfileNetworkDataSource
): ProfileRepo {
override suspend fun getInfo(): Result<EmployeeEntity> {
return networkDataSource.getInfo().map { dto->
EmployeeEntity(
id = dto.id ?: 0,
login = dto.login ?: "",
name = dto.name ?: "Не указано",
authority = dto.authority ?: "EMPLOYEE",
photoUrl = dto.photoUrl,
position = dto.position ?: "Отсутствует",
qrEnabled = dto.qrEnabled ?: false
)
}
}
}

@ -0,0 +1,39 @@
package ru.myitschool.work.data.profile.admin
import android.content.Context
import io.ktor.client.call.body
import io.ktor.client.request.basicAuth
import io.ktor.client.request.post
import io.ktor.client.statement.bodyAsText
import io.ktor.http.HttpStatusCode
import io.ktor.http.headers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.dto.EmployeeDTO
import ru.myitschool.work.utils.NetworkModule
class EmployeeNetworkDataSource(
context: Context
) {
private val client = NetworkModule.httpClient
private val userDataStoreManager = UserDataStoreManager.getInstance(context)
suspend fun getProfile(login : String):Result<EmployeeDTO> = withContext(Dispatchers.IO){
runCatching {
val username = userDataStoreManager.usernameFlow.first()
val password = userDataStoreManager.passwordFlow.first()
val result = client.post("${Constants.SERVER_ADDRESS}/api/employee/$login"){
headers{
basicAuth(username, password)
}
}
if (result.status != HttpStatusCode.OK) {
error("Status ${result.status}")
}
println(result.bodyAsText())
result.body()
}
}
}

@ -0,0 +1,22 @@
package ru.myitschool.work.data.profile.admin
import ru.myitschool.work.entities.EmployeeEntity
import ru.myitschool.work.domain.profile.admin.EmployeeProfileRepo
class EmployeeProfileRepoImpl(
private val networkDataSource: EmployeeNetworkDataSource
) : EmployeeProfileRepo {
override suspend fun getInfo(login : String): Result<EmployeeEntity> {
return networkDataSource.getProfile(login).map { dto ->
EmployeeEntity(
id = dto.id ?: 0,
login = dto.login ?: "",
name = dto.name ?: "Не указано",
authority = dto.authority ?: "EMPLOYEE",
photoUrl = dto.photoUrl,
position = dto.position ?: "Отсутствует",
qrEnabled = dto.qrEnabled ?: false
)
}
}
}

@ -0,0 +1,36 @@
package ru.myitschool.work.data.scannerState
import android.content.Context
import io.ktor.client.call.body
import io.ktor.client.request.basicAuth
import io.ktor.client.request.patch
import io.ktor.http.HttpStatusCode
import io.ktor.http.headers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withContext
import ru.myitschool.work.core.Constants
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.utils.NetworkModule
class ScannerStateNetworkDataSource(
context: Context
) {
private val client = NetworkModule.httpClient
private val userDataStoreManager = UserDataStoreManager.getInstance(context)
suspend fun setScannerState(state: String, login: String):Result<Unit> = withContext(Dispatchers.IO){
runCatching {
val username = userDataStoreManager.usernameFlow.first()
val password = userDataStoreManager.passwordFlow.first()
val result = client.patch("${Constants.SERVER_ADDRESS}/api/employee/$login/$state"){
headers{
basicAuth(username, password)
}
}
if (result.status != HttpStatusCode.OK) {
error("Status ${result.status}")
}
result.body()
}
}
}

@ -0,0 +1,11 @@
package ru.myitschool.work.data.scannerState
import ru.myitschool.work.domain.scannerBlockState.ScannerStateRepo
class ScannerStateRepoImpl(
private val networkDataSource: ScannerStateNetworkDataSource
) : ScannerStateRepo {
override suspend fun changeState(state: String, login: String) : Result<Unit> {
return networkDataSource.setScannerState(state, login)
}
}

@ -0,0 +1,5 @@
package ru.myitschool.work.domain.deleteEmployee
interface DeleteEmployeeRepo {
suspend fun deleteEmployee(login : String): Result<Unit>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.deleteEmployee
class DeleteEmployeeUseCase(
private val repo: DeleteEmployeeRepo
) {
suspend operator fun invoke(login : String) = repo.deleteEmployee(login)
}

@ -1,4 +1,4 @@
package ru.myitschool.work.domain.door
package ru.myitschool.work.domain.door.open
interface DoorRepo {
suspend fun openDoor(code: String) : Result<Unit>

@ -1,4 +1,4 @@
package ru.myitschool.work.domain.door
package ru.myitschool.work.domain.door.open
class OpenDoorUseCase(
private val repo: DoorRepo

@ -1,6 +1,6 @@
package ru.myitschool.work.domain.employeeEntrance.allEntrances
import ru.myitschool.work.domain.entities.EmployeeEntranceEntity
import ru.myitschool.work.entities.EmployeeEntranceEntity
interface AllEntranceListRepo {
suspend fun getList(pageNum : Int, pageSize: Int) : Result<List<EmployeeEntranceEntity>>

@ -1,6 +1,6 @@
package ru.myitschool.work.domain.employeeEntrance.allEntrances
class GetAllEmployeesEntranceList(
class GetAllEmployeesEntranceListUseCase(
private val repo: AllEntranceListRepo
) {
suspend operator fun invoke(pageNum : Int, pageSize: Int) = repo.getList(pageNum, pageSize)

@ -1,6 +1,6 @@
package ru.myitschool.work.domain.employeeEntrance.employeeEntrances
import ru.myitschool.work.domain.entities.EmployeeEntranceEntity
import ru.myitschool.work.entities.EmployeeEntranceEntity
interface EmployeeEntranceListRepo {
suspend fun getList(pageNum : Int, pageSize: Int) : Result<List<EmployeeEntranceEntity>>

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.employeeEntrance.lastEntrance
class GetLastEntranceUseCase(
private val repo : LastEntranceRepo
) {
suspend operator fun invoke() = repo.getLastEntrance()
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.employeeEntrance.lastEntrance
import ru.myitschool.work.entities.EmployeeEntranceEntity
interface LastEntranceRepo {
suspend fun getLastEntrance() : Result<EmployeeEntranceEntity>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.employeeList
import ru.myitschool.work.entities.EmployeeEntity
interface EmployeeListRepo {
suspend fun getList() : Result<List<EmployeeEntity>>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.employeeList
class GetEmployeeListUseCase(
private val repo: EmployeeListRepo
) {
suspend operator fun invoke() = repo.getList()
}

@ -1,9 +0,0 @@
package ru.myitschool.work.domain.entities
import java.util.Date
data class EmployeeEntranceEntity(
val id : Int?,
val scanTime : Date?,
val readerName: String?,
val type: String?
)

@ -1,7 +0,0 @@
package ru.myitschool.work.domain.info
class GetInfoUseCase(
private val repo: InfoRepo
) {
suspend operator fun invoke() = repo.getInfo()
}

@ -1,7 +0,0 @@
package ru.myitschool.work.domain.info
import ru.myitschool.work.domain.entities.UserEntity
interface InfoRepo {
suspend fun getInfo(): Result<UserEntity>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.profile
class GetProfileUseCase(
private val repo: ProfileRepo
) {
suspend operator fun invoke() = repo.getInfo()
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.profile
import ru.myitschool.work.entities.EmployeeEntity
interface ProfileRepo {
suspend fun getInfo(): Result<EmployeeEntity>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.profile.admin
import ru.myitschool.work.entities.EmployeeEntity
interface EmployeeProfileRepo {
suspend fun getInfo(login : String): Result<EmployeeEntity>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.profile.admin
class GetEmployeeProfileUseCase(
private val repo : EmployeeProfileRepo
) {
suspend operator fun invoke(login : String) = repo.getInfo(login)
}

@ -0,0 +1,5 @@
package ru.myitschool.work.domain.scannerBlockState
interface ScannerStateRepo {
suspend fun changeState(state: String, login: String) : Result<Unit>
}

@ -0,0 +1,7 @@
package ru.myitschool.work.domain.scannerBlockState
class SetScannerStateUseCase(
private val repo: ScannerStateRepo
) {
suspend operator fun invoke(state: String, login: String) = repo.changeState(state, login)
}

@ -1,15 +1,16 @@
package ru.myitschool.work.data.dto
package ru.myitschool.work.dto
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class UserDTO(
data class EmployeeDTO(
@SerialName("id") val id: Long?,
@SerialName("login") val login: String?,
@SerialName("name") val name: String?,
@SerialName("authority") val authority : String?,
@SerialName("photoUrl") val photoUrl: String?,
@SerialName("position") val position: String?
@SerialName("position") val position: String?,
@SerialName("qrEnabled") val qrEnabled: Boolean?
)

@ -1,4 +1,4 @@
package ru.myitschool.work.data.dto
package ru.myitschool.work.dto
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@ -1,4 +1,4 @@
package ru.myitschool.work.data.dto
package ru.myitschool.work.dto
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@ -0,0 +1,7 @@
package ru.myitschool.work.dto
import kotlinx.serialization.SerialName
data class EmployeePagingDTO (
@SerialName("content") val content : List<EmployeeDTO>?
)

@ -1,10 +1,11 @@
package ru.myitschool.work.domain.entities
package ru.myitschool.work.entities
data class UserEntity(
data class EmployeeEntity(
val id: Long,
val login: String,
val name: String,
val authority: String,
val photoUrl: String?,
val position: String
val position: String,
val qrEnabled: Boolean
)

@ -0,0 +1,9 @@
package ru.myitschool.work.entities
import java.util.Date
data class EmployeeEntranceEntity(
val id : Int,
val scanTime : Date?,
val readerName: String,
val type: String
)

@ -5,7 +5,7 @@ import android.view.ViewGroup
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.RecyclerView
import ru.myitschool.work.databinding.ItemVisitBinding
import ru.myitschool.work.domain.entities.EmployeeEntranceEntity
import ru.myitschool.work.entities.EmployeeEntranceEntity
import ru.myitschool.work.utils.dateConverter
class EmployeeEntranceListAdapter : PagingDataAdapter<EmployeeEntranceEntity, EmployeeEntranceListAdapter.ViewHolder>(DiffUtil) {

@ -2,7 +2,7 @@ package ru.myitschool.work.ui.main
import androidx.paging.PagingSource
import androidx.paging.PagingState
import ru.myitschool.work.domain.entities.EmployeeEntranceEntity
import ru.myitschool.work.entities.EmployeeEntranceEntity
class EmployeeEntranceListPagingSource(
private val request: suspend(pageNum: Int, pageSize: Int) ->Result<List<EmployeeEntranceEntity>>

@ -15,7 +15,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import ru.myitschool.work.R
import ru.myitschool.work.databinding.FragmentMainBinding
import ru.myitschool.work.domain.entities.UserEntity
import ru.myitschool.work.entities.EmployeeEntity
import ru.myitschool.work.ui.qr.scan.QrScanDestination
import ru.myitschool.work.utils.UserState
import ru.myitschool.work.utils.collectWhenStarted
@ -55,7 +55,7 @@ class MainFragment : Fragment(R.layout.fragment_main) {
binding.refresh.visibility = View.VISIBLE
binding.loading.visibility = View.GONE
binding.error.visibility = View.GONE
showUserData(state.userEntity)
showUserData(state.employeeEntity)
}
}
@ -102,12 +102,12 @@ class MainFragment : Fragment(R.layout.fragment_main) {
}
private fun showUserData(userEntity: UserEntity) {
private fun showUserData(employeeEntity: EmployeeEntity) {
binding.apply {
fullname.text = userEntity.name
println(userEntity.name)
position.text = userEntity.position
Picasso.get().load(userEntity.photoUrl).into(photo)
fullname.text = employeeEntity.name
println(employeeEntity.name)
position.text = employeeEntity.position
Picasso.get().load(employeeEntity.photoUrl).into(photo)
error.visibility = View.GONE
setViewsVisibility(View.VISIBLE)

@ -15,16 +15,16 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import ru.myitschool.work.data.UserDataStoreManager
import ru.myitschool.work.data.info.InfoNetworkDataSource
import ru.myitschool.work.data.info.InfoRepoImpl
import ru.myitschool.work.data.profile.ProfileNetworkDataSource
import ru.myitschool.work.data.profile.ProfileRepoImpl
import ru.myitschool.work.data.entrance.employeeEntrances.EmployeeEntranceListNetworkDataSource
import ru.myitschool.work.data.entrance.employeeEntrances.EmployeeEntranceListRepoImpl
import ru.myitschool.work.domain.info.GetInfoUseCase
import ru.myitschool.work.domain.profile.GetProfileUseCase
import ru.myitschool.work.domain.employeeEntrance.employeeEntrances.GetEmployeeEntranceListUseCase
import ru.myitschool.work.utils.UserState
class MainViewModel(
private val infoUseCase: GetInfoUseCase,
private val infoUseCase: GetProfileUseCase,
private val listUseCase: GetEmployeeEntranceListUseCase,
application: Application
) : AndroidViewModel(application) {
@ -79,8 +79,8 @@ class MainViewModel(
@Suppress("UNCHECKED_CAST")
val Factory: ViewModelProvider.Factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T {
val infoRepoImpl = InfoRepoImpl(
networkDataSource = InfoNetworkDataSource(
val profileRepoImpl = ProfileRepoImpl(
networkDataSource = ProfileNetworkDataSource(
context = extras[ViewModelProvider.AndroidViewModelFactory.APPLICATION_KEY] as Application
)
)
@ -90,7 +90,7 @@ class MainViewModel(
)
)
val infoUseCase = GetInfoUseCase(infoRepoImpl)
val infoUseCase = GetProfileUseCase(profileRepoImpl)
val listUseCase = GetEmployeeEntranceListUseCase(listInfoImpl)
return MainViewModel(

@ -10,9 +10,9 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import ru.myitschool.work.data.door.DoorNetworkDataSource
import ru.myitschool.work.data.door.DoorRepoImpl
import ru.myitschool.work.domain.door.OpenDoorUseCase
import ru.myitschool.work.data.door.open.DoorNetworkDataSource
import ru.myitschool.work.data.door.open.DoorRepoImpl
import ru.myitschool.work.domain.door.open.OpenDoorUseCase
class QrResultViewModel(
private val useCase: OpenDoorUseCase,

@ -1,9 +1,9 @@
package ru.myitschool.work.utils
import ru.myitschool.work.domain.entities.UserEntity
import ru.myitschool.work.entities.EmployeeEntity
sealed class UserState {
object Loading : UserState()
data class Success(val userEntity: UserEntity) : UserState()
data class Success(val employeeEntity: EmployeeEntity) : UserState()
object Error : UserState()
}

@ -27,7 +27,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:contentDescription="@string/close_button"
android:contentDescription="@string/close_btn"
android:src="@drawable/ic_close"
app:elevation="0dp"
app:layout_constraintStart_toStartOf="parent"