-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature/#105] : 대댓글 UI, API #122
Changes from all commits
73cad21
b60d1b2
05fa397
e8849ff
c008967
0d32c51
15a20ea
195119f
d2254ae
7ff9b68
fb046b2
56b5ed3
387b67c
4b7a441
2f0a3c5
7220f26
cce8e52
539c85a
883afa8
5c8be04
72903b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,13 @@ package com.teamwable.data.repositoryimpl | |
import androidx.paging.Pager | ||
import androidx.paging.PagingConfig | ||
import androidx.paging.PagingData | ||
import androidx.paging.flatMap | ||
import androidx.paging.map | ||
import com.teamwable.data.mapper.toData.toPostCommentDto | ||
import com.teamwable.data.mapper.toData.toPostCommentLikeDto | ||
import com.teamwable.data.mapper.toData.toPostGhostDto | ||
import com.teamwable.data.mapper.toModel.toComment | ||
import com.teamwable.data.mapper.toModel.toComments | ||
import com.teamwable.data.repository.CommentRepository | ||
import com.teamwable.model.Comment | ||
import com.teamwable.model.Ghost | ||
|
@@ -28,7 +30,7 @@ internal class DefaultCommentRepository @Inject constructor( | |
getNextCursor = { comments -> comments.lastOrNull()?.commentId }, | ||
) | ||
}.flow.map { pagingData -> | ||
pagingData.map { it.toComment() } | ||
pagingData.flatMap { it.toComments() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 : flatMap 이런 것도 잇군요? 내장 코드 활용 넘 잘하는 ㄷㄷ |
||
} | ||
} | ||
|
||
|
@@ -50,9 +52,8 @@ internal class DefaultCommentRepository @Inject constructor( | |
return it.handleThrowable() | ||
} | ||
|
||
override suspend fun postComment(contentId: Long, commentText: String): Result<Unit> = runCatching { | ||
val request = Pair(commentText, "comment").toPostCommentDto() | ||
apiService.postComment(contentId, request) | ||
override suspend fun postComment(contentId: Long, commentInfo: Triple<String, Long, Long>): Result<Unit> = runCatching { | ||
apiService.postComment(contentId, commentInfo.toPostCommentDto()) | ||
Unit | ||
}.onFailure { | ||
return it.handleThrowable() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ import retrofit2.http.Path | |
import retrofit2.http.Query | ||
|
||
interface CommentService { | ||
@GET("api/v2/content/{contentId}/comments") | ||
@GET("api/v3/content/{contentId}/comments") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 v3생기면 추가하기로 한거 아니였나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어떤걸 추가하기로 했죠??! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 앗 이거 저희 쪽에서 v3로 새로 함수 만들어서 쓴다고 착각했네요 근데 지금 로그아웃 하고 로그인이 안되서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아하!! 로그인 api v2로 업하고 체크를 못했네요 서버랑 이야기 해볼게요! |
||
suspend fun getHomeDetailComments( | ||
@Path(value = "contentId") contentId: Long, | ||
@Query(value = "cursor") cursor: Long = -1, | ||
|
@@ -31,7 +31,7 @@ interface CommentService { | |
@Path(value = "commentId") commentId: Long, | ||
): BaseUnitResponse<Unit> | ||
|
||
@POST("api/v1/content/{contentId}/comment") | ||
@POST("api/v3/content/{contentId}/comment") | ||
suspend fun postComment( | ||
@Path(value = "contentId") contentId: Long, | ||
@Body request: RequestPostCommentDto, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.teamwable.ui.shareAdapter | ||
|
||
import android.graphics.Color | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.teamwable.model.Comment | ||
import com.teamwable.ui.databinding.ItemChildCommentBinding | ||
import com.teamwable.ui.extensions.load | ||
import com.teamwable.ui.extensions.visible | ||
|
||
class ChildCommentViewHolder private constructor( | ||
private val binding: ItemChildCommentBinding, | ||
commentClickListener: CommentClickListener, | ||
) : RecyclerView.ViewHolder(binding.root), LikeableViewHolder { | ||
private lateinit var item: Comment | ||
override val likeBtn = binding.btnChildCommentLike | ||
override val likeCountTv = binding.tvChildCommentLikeCount | ||
|
||
init { | ||
setupClickListener(itemView, binding.tvChildCommentContent) { commentClickListener.onItemClick(item.feedId ?: return@setupClickListener) } | ||
setupClickListener(binding.btnChildCommentGhost) { commentClickListener.onGhostBtnClick(item.postAuthorId, item.commentId) } | ||
setupClickListener(binding.btnChildCommentLike) { commentClickListener.onLikeBtnClick(this, item) } | ||
setupClickListener(binding.ivChildCommentProfileImg, binding.tvChildCommentNickname) { commentClickListener.onPostAuthorProfileClick(item.postAuthorId) } | ||
setupClickListener(binding.btnChildCommentMore) { commentClickListener.onKebabBtnClick(item) } | ||
} | ||
|
||
private fun setupClickListener(vararg views: View, action: () -> Unit) { | ||
views.forEach { view -> | ||
view.setOnClickListener { | ||
if (this::item.isInitialized) action() | ||
} | ||
} | ||
} | ||
|
||
fun bind(comment: Comment?) { | ||
item = comment ?: return | ||
with(binding) { | ||
ivChildCommentProfileImg.load(comment.postAuthorProfile) | ||
tvChildCommentNickname.text = comment.postAuthorNickname | ||
tvChildCommentGhostLevel.text = comment.postAuthorGhost | ||
tvChildCommentUploadTime.text = comment.uploadTime | ||
tvChildCommentContent.text = comment.content | ||
btnChildCommentLike.isChecked = comment.isLiked | ||
tvChildCommentLikeCount.text = comment.likedNumber | ||
tvTeamTag.teamName = comment.postAuthorTeamTag | ||
btnChildCommentGhost.isEnabled = !comment.isPostAuthorGhost | ||
viewChildCommentTransparentBg.setBackgroundColor(Color.parseColor(comment.ghostColor)) | ||
btnChildCommentGhost.visible(!comment.isAuth) | ||
spacerChildComment.visible(!comment.isAuth) | ||
setBlindVisible(comment.isBlind) | ||
} | ||
} | ||
|
||
private fun setBlindVisible(isBlind: Boolean) = with(binding) { | ||
tvChildCommentContent.visible(!isBlind) | ||
tvChildCommentBlind.visible(isBlind) | ||
} | ||
|
||
companion object { | ||
fun from(parent: ViewGroup, commentClickListener: CommentClickListener): ChildCommentViewHolder = | ||
ChildCommentViewHolder( | ||
ItemChildCommentBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false, | ||
), | ||
commentClickListener, | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
package com.teamwable.ui.shareAdapter | ||
|
||
import android.widget.CheckBox | ||
import android.widget.TextView | ||
import com.teamwable.model.Comment | ||
|
||
interface CommentClickListener { | ||
fun onGhostBtnClick(postAuthorId: Long, commentId: Long) | ||
|
||
fun onLikeBtnClick(viewHolder: CommentViewHolder, comment: Comment) | ||
fun onLikeBtnClick(viewHolder: LikeableViewHolder, comment: Comment) | ||
|
||
fun onPostAuthorProfileClick(id: Long) | ||
|
||
fun onKebabBtnClick(comment: Comment) | ||
|
||
fun onItemClick(feedId: Long) | ||
|
||
fun onChildCommentClick(comment: Comment) | ||
} | ||
|
||
interface LikeableViewHolder { | ||
val likeBtn: CheckBox | ||
val likeCountTv: TextView | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.teamwable.ui.type | ||
|
||
enum class CommentType(val id: Int) { | ||
PARENT(0), | ||
CHILD(1), | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<size android:width="2dp" /> | ||
<solid android:color="@color/purple_50" /> | ||
<corners android:radius="8dp" /> | ||
</shape> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 :
세븐틴까지 가주세요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zzzzzzzzㅋㅋㅋㅋㅋㅋㅋㅋㅋ