응원글 - 수정 기능 추가

This commit is contained in:
klaus 2023-09-07 16:35:19 +09:00
parent b6359f9b8d
commit e13eb3c404
5 changed files with 128 additions and 28 deletions

View File

@ -390,13 +390,21 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
)
}
},
modifyReply = { cheersId, content, isActive ->
modifyReply = { cheersId, content ->
hideKeyboard {
viewModel.modifyCheers(
cheersId = cheersId,
creatorId = userId,
cheersContent = content
)
}
},
modifyCheers = { cheersId, content ->
hideKeyboard {
viewModel.modifyCheers(
cheersId = cheersId,
creatorId = userId,
cheersContent = content,
isActive = isActive
)
}
},

View File

@ -17,7 +17,8 @@ import kr.co.vividnext.sodalive.extensions.dpToPx
class UserProfileCheersAdapter(
private val userId: Long,
private val enterReply: (Long, String) -> Unit,
private val modifyReply: (Long, String?, Boolean?) -> Unit,
private val modifyReply: (Long, String?) -> Unit,
private val modifyCheers: (Long, String) -> Unit,
private val onClickReport: (Long) -> Unit,
private val onClickDelete: (Long) -> Unit
) : RecyclerView.Adapter<UserProfileCheersAdapter.ViewHolder>() {
@ -43,14 +44,33 @@ class UserProfileCheersAdapter(
binding.tvNickname.text = cheers.nickname
binding.tvDate.text = cheers.date
binding.ivMenu.setOnClickListener {
showOptionMenu(
context,
binding.ivMenu,
cheersId = cheers.cheersId,
memberId = cheers.memberId,
creatorId = userId
)
if (
cheers.memberId == SharedPreferenceManager.userId ||
userId == SharedPreferenceManager.userId
) {
binding.etContentModify.setText(cheers.content)
binding.ivMenu.visibility = View.VISIBLE
binding.ivMenu.setOnClickListener {
showOptionMenu(
context,
binding.ivMenu,
cheersId = cheers.cheersId,
memberId = cheers.memberId,
creatorId = userId,
onClickModify = {
binding.rlContentModify.visibility = View.VISIBLE
binding.tvContent.visibility = View.GONE
}
)
}
binding.tvModify.setOnClickListener {
binding.rlContentModify.visibility = View.GONE
binding.tvContent.visibility = View.VISIBLE
modifyCheers(cheers.cheersId, binding.etContentModify.text.toString())
}
} else {
binding.ivMenu.visibility = View.GONE
}
if (cheers.replyList.isNotEmpty()) {
@ -66,7 +86,7 @@ class UserProfileCheersAdapter(
binding.rlCheerReply.visibility = View.VISIBLE
binding.tvSend.setOnClickListener {
val content = binding.etCheerReply.text.toString()
modifyReply(reply.cheersId, content, null)
modifyReply(reply.cheersId, content)
}
}
} else {
@ -114,15 +134,15 @@ class UserProfileCheersAdapter(
v: View,
cheersId: Long,
memberId: Long,
creatorId: Long
creatorId: Long,
onClickModify: () -> Unit
) {
val popup = PopupMenu(context, v)
val inflater = popup.menuInflater
if (
memberId == SharedPreferenceManager.userId ||
creatorId == SharedPreferenceManager.userId
) {
if (memberId == SharedPreferenceManager.userId) {
inflater.inflate(R.menu.review_option_menu3, popup.menu)
} else if (creatorId == SharedPreferenceManager.userId) {
inflater.inflate(R.menu.review_option_menu2, popup.menu)
} else {
inflater.inflate(R.menu.review_option_menu, popup.menu)
@ -134,6 +154,10 @@ class UserProfileCheersAdapter(
onClickReport(cheersId)
}
R.id.menu_review_modify -> {
onClickModify()
}
R.id.menu_review_delete -> {
onClickDelete(cheersId)
}

View File

@ -80,13 +80,21 @@ class UserProfileFantalkAllViewActivity : BaseActivity<ActivityUserProfileFantal
)
}
},
modifyReply = { cheersId, content, isActive ->
modifyReply = { cheersId, content ->
hideKeyboard {
viewModel.modifyCheers(
cheersId = cheersId,
creatorId = userId,
cheersContent = content
)
}
},
modifyCheers = { cheersId, content ->
hideKeyboard {
viewModel.modifyCheers(
cheersId = cheersId,
creatorId = userId,
cheersContent = content,
isActive = isActive
)
}
},

View File

@ -52,18 +52,63 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_profile" />
<TextView
android:id="@+id/tv_content"
<FrameLayout
android:id="@+id/fl_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6.7dp"
android:fontFamily="@font/gmarket_sans_medium"
android:textColor="@color/color_777777"
android:textSize="12sp"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_profile"
app:layout_constraintTop_toBottomOf="@+id/tv_date"
tools:text="내용 읽어보니까 결혼해도 될것 같은데요. 원래 서로 맞춰가며 사는거죠! 응원합니다." />
app:layout_constraintTop_toBottomOf="@+id/tv_date">
<TextView
android:id="@+id/tv_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6.7dp"
android:fontFamily="@font/gmarket_sans_medium"
android:textColor="@color/color_777777"
android:textSize="12sp"
tools:text="내용 읽어보니까 결혼해도 될것 같은데요. 원래 서로 맞춰가며 사는거죠! 응원합니다." />
<RelativeLayout
android:id="@+id/rl_content_modify"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:visibility="gone">
<EditText
android:id="@+id/et_content_modify"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginEnd="13.3dp"
android:layout_toStartOf="@+id/tv_modify"
android:background="@drawable/bg_round_corner_10_339970ff_9970ff"
android:importantForAutofill="no"
android:inputType="text"
android:paddingHorizontal="13.3dp"
android:paddingVertical="13dp"
android:textColor="@color/color_eeeeee"
android:textColorHint="@color/color_eeeeee"
android:textCursorDrawable="@drawable/edit_text_cursor"
android:textSize="13.3sp"
android:theme="@style/EditTextStyle"
tools:ignore="LabelFor" />
<TextView
android:id="@+id/tv_modify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@drawable/bg_round_corner_6_7_9970ff"
android:fontFamily="@font/gmarket_sans_bold"
android:padding="13dp"
android:text="수정"
android:textColor="@color/white" />
</RelativeLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/fl_reply"
@ -72,7 +117,7 @@
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_profile"
app:layout_constraintTop_toBottomOf="@+id/tv_content">
app:layout_constraintTop_toBottomOf="@+id/fl_content">
<LinearLayout
android:id="@+id/ll_cheer_reply"
@ -89,6 +134,7 @@
android:background="@drawable/bg_round_corner_16_7_4c9970ff"
android:fontFamily="@font/gmarket_sans_medium"
android:paddingHorizontal="13.3dp"
android:paddingVertical="6.7dp"
android:textColor="@color/white"
tools:text="항상 응원해주셔서 감사합니다." />

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_review_modify"
android:title="수정"
app:showAsAction="ifRoom" />
<item
android:id="@+id/menu_review_delete"
android:title="삭제"
app:showAsAction="ifRoom" />
</menu>