Курсовая: Готова и сдана
This commit is contained in:
parent
40ca46846e
commit
cf8e779058
@ -112,7 +112,7 @@ interface ServerService {
|
|||||||
): User
|
): User
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val BASE_URL = "http://192.168.0.103:8000/"
|
private const val BASE_URL = "http://192.168.43.115:8000/"
|
||||||
|
|
||||||
private var _token: String = ""
|
private var _token: String = ""
|
||||||
|
|
||||||
|
@ -161,8 +161,7 @@ private fun Post(viewModel: PostsViewModel, navController: NavHostController, po
|
|||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxHeight(0.3f)
|
.heightIn(min=250.dp, max = 300.dp)
|
||||||
.heightIn(max = 250.dp)
|
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.background(Color.White)
|
.background(Color.White)
|
||||||
.clickable {
|
.clickable {
|
||||||
|
@ -203,6 +203,12 @@ fun Post(viewModel: TopPostsViewModel, navController: NavHostController, post: P
|
|||||||
val likes = remember { mutableIntStateOf(post.likes) }
|
val likes = remember { mutableIntStateOf(post.likes) }
|
||||||
val isLiked = remember { mutableStateOf(false) }
|
val isLiked = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
viewModel.getLikes(post.id!!).collect {
|
||||||
|
likes.intValue = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
viewModel.isLiked(sharedPref, post.id!!).collect {
|
viewModel.isLiked(sharedPref, post.id!!).collect {
|
||||||
isLiked.value = it
|
isLiked.value = it
|
||||||
|
@ -35,6 +35,8 @@ class TopPostsViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLikes(postId: Int) = likeRepository.countByPost(postId)
|
||||||
|
|
||||||
fun likePost(sharedPref: PreferencesManager, postId: Int) {
|
fun likePost(sharedPref: PreferencesManager, postId: Int) {
|
||||||
val userId = sharedPref.getData("userId", "-1").toInt()
|
val userId = sharedPref.getData("userId", "-1").toInt()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user