Change visibility button for admins
This commit is contained in:
parent
9ea2a7720f
commit
1dd4848782
@ -14,9 +14,11 @@ class UserInfoMapper @Inject constructor() {
|
||||
fullname = model.fullname ?: error("fullname is null"),
|
||||
imageUrl = model.imageUrl ?: error("imageUrl is null"),
|
||||
position = model.position ?: error("position is null"),
|
||||
lastEntryMillis = model.lastEntry?.let { date ->
|
||||
lastEntryMillis = model.lastEntry.let { date ->
|
||||
simpleDateFormat.parse(date)?.time ?: error("parse lastEntry error")
|
||||
} ?: error("lastEntry is null")
|
||||
} ?: error("lastEntry is null"),
|
||||
role = model.role,
|
||||
blocked = model.blocked
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package ru.myitschool.work.domain.profile.entities
|
||||
|
||||
import ru.myitschool.work.data.dto.Role
|
||||
|
||||
class UserInfoEntity(
|
||||
val fullname: String,
|
||||
val imageUrl: String,
|
||||
val position: String,
|
||||
val role: Role,
|
||||
val blocked: Boolean,
|
||||
val lastEntryMillis: Long,
|
||||
)
|
@ -63,11 +63,13 @@ class ProfileFragment : Fragment(R.layout.fragment_profile) {
|
||||
binding.lastEntry.text = state.lastEntry
|
||||
binding.fullname.text = state.fullname
|
||||
if (state.admin){
|
||||
//TODO Приделать админские штучки
|
||||
binding.admin.visibility = View.VISIBLE
|
||||
}else{
|
||||
} else {
|
||||
binding.admin.visibility = View.GONE
|
||||
}
|
||||
if (state.blocked) {
|
||||
// TODO: СДЕЛАТЬ ФОН КРАСНЫМ
|
||||
}
|
||||
Picasso.get()
|
||||
.load(state.imageUrl)
|
||||
.error(R.drawable.ic_no_img)
|
||||
|
@ -12,6 +12,7 @@ import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import ru.myitschool.work.R
|
||||
import ru.myitschool.work.data.dto.Role
|
||||
import ru.myitschool.work.domain.auth.LogoutUseCase
|
||||
import ru.myitschool.work.domain.profile.GetUserInfoUseCase
|
||||
import ru.myitschool.work.utils.MutablePublishFlow
|
||||
@ -72,7 +73,8 @@ class ProfileViewModel @Inject constructor(
|
||||
imageUrl = value.imageUrl,
|
||||
position = value.position,
|
||||
lastEntry = simpleDateFormat.format(Date(value.lastEntryMillis)),
|
||||
admin = true
|
||||
admin = value.role == Role.ADMIN,
|
||||
blocked = value.blocked
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -100,6 +102,7 @@ class ProfileViewModel @Inject constructor(
|
||||
val position: String,
|
||||
val lastEntry: String,
|
||||
val admin: Boolean,
|
||||
val blocked: Boolean
|
||||
) : State
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user