feat(report): 캐릭터 댓글 신고 사유를 라디오 버튼으로 변경 및 비활성 시각화
- 댓글 신고 사유 리스트 변경 - 댓글 신고 사유 선택 UI를 RadioGroup/RadioButton으로 전환 - 선택 전 신고 버튼 비활성화 및 alpha 적용으로 시각적 비활성화 처리 - 선택 시 버튼 활성화 및 alpha 복구
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
package kr.co.vividnext.sodalive.chat.character.comment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
@@ -39,33 +42,48 @@ class CharacterCommentReportBottomSheet : BottomSheetDialogFragment() {
|
||||
): View {
|
||||
val view = inflater.inflate(R.layout.dialog_character_comment_report, container, false)
|
||||
val tvTitle = view.findViewById<TextView>(R.id.tv_title)
|
||||
val llList = view.findViewById<LinearLayout>(R.id.ll_reason_list)
|
||||
val rgList = view.findViewById<RadioGroup>(R.id.rg_reason_list)
|
||||
val btnReport = view.findViewById<Button>(R.id.btn_report)
|
||||
val ivClose = view.findViewById<ImageView>(R.id.iv_close)
|
||||
|
||||
tvTitle.text = getString(R.string.report_title)
|
||||
btnReport.isEnabled = false
|
||||
setReportEnabled(btnReport, false)
|
||||
|
||||
val items = reasons ?: DEFAULT_REASONS
|
||||
val textColor = ContextCompat.getColor(requireContext(), R.color.white)
|
||||
|
||||
// 동적 리스트 구성: 단일 선택
|
||||
// RadioButton 동적 생성 및 단일 선택 처리
|
||||
items.forEachIndexed { index, text ->
|
||||
val itemView = inflater.inflate(R.layout.item_report_reason, llList, false)
|
||||
val tvText = itemView.findViewById<TextView>(R.id.tv_reason)
|
||||
val ivCheck = itemView.findViewById<ImageView>(R.id.iv_check)
|
||||
tvText.text = text
|
||||
ivCheck.isVisible = index == selectedIndex
|
||||
itemView.setOnClickListener {
|
||||
selectedIndex = index
|
||||
// 전체를 다시 그릴 정도는 아니므로 자식들만 순회하며 체크 상태 갱신
|
||||
for (i in 0 until llList.childCount) {
|
||||
val child = llList.getChildAt(i)
|
||||
val check = child.findViewById<ImageView>(R.id.iv_check)
|
||||
check?.isVisible = i == selectedIndex
|
||||
}
|
||||
btnReport.isEnabled = true
|
||||
val rb = RadioButton(requireContext()).apply {
|
||||
id = View.generateViewId()
|
||||
tag = index
|
||||
this.text = text
|
||||
// 텍스트 색: 흰색
|
||||
setTextColor(textColor)
|
||||
// 텍스트 크기: 기존 15sp의 1.3배 -> 19.5sp
|
||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f)
|
||||
// 폰트: pretendard_regular
|
||||
try {
|
||||
typeface = ResourcesCompat.getFont(context, R.font.pretendard_regular)
|
||||
} catch (_: Exception) { /* 폰트 미존재 대비 안전 처리 */ }
|
||||
// 항목 간 간격: 기존 paddingVertical 12dp의 1.3배 -> 15.6dp
|
||||
val vPadPx = (14f * resources.displayMetrics.density).toInt()
|
||||
setPadding(paddingLeft, vPadPx, paddingRight, vPadPx)
|
||||
// 버튼 틴트는 시스템 기본 사용, 필요 시 색상 리소스 적용 가능
|
||||
}
|
||||
// 항목 좌우 여백은 유지, 필요 시 LayoutParams로 마진 조정 가능
|
||||
rgList.addView(rb)
|
||||
}
|
||||
|
||||
rgList.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId != -1) {
|
||||
val selected = group.findViewById<RadioButton>(checkedId)
|
||||
selectedIndex = (selected.tag as? Int) ?: -1
|
||||
setReportEnabled(btnReport, true)
|
||||
} else {
|
||||
selectedIndex = -1
|
||||
setReportEnabled(btnReport, false)
|
||||
}
|
||||
llList.addView(itemView)
|
||||
}
|
||||
|
||||
ivClose.setOnClickListener { dismiss() }
|
||||
@@ -80,11 +98,22 @@ class CharacterCommentReportBottomSheet : BottomSheetDialogFragment() {
|
||||
return view
|
||||
}
|
||||
|
||||
private fun setReportEnabled(button: Button, enabled: Boolean) {
|
||||
button.isEnabled = enabled
|
||||
button.alpha = if (enabled) 1.0f else 0.4f
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ARG_REASONS = "arg_reasons"
|
||||
|
||||
private val DEFAULT_REASONS = arrayListOf(
|
||||
"스팸/광고", "욕설/비하", "음란물/불건전", "개인정보 노출", "기타"
|
||||
"원치 않는 상업성 콘텐츠 또는 스팸",
|
||||
"아동 학대",
|
||||
"증오시 표현 또는 노골적인 폭력",
|
||||
"테러 조장",
|
||||
"희롱 또는 괴롭힘",
|
||||
"자살 또는 자해",
|
||||
"잘못된 정보"
|
||||
)
|
||||
|
||||
fun newInstance(reasons: ArrayList<String>? = null): CharacterCommentReportBottomSheet {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/ic_circle_x_white" />
|
||||
android:src="@drawable/ic_close_white" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
@@ -36,8 +36,8 @@
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="#78909C" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_reason_list"
|
||||
<RadioGroup
|
||||
android:id="@+id/rg_reason_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
@@ -50,6 +50,8 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:backgroundTint="@color/color_3bb9f1"
|
||||
android:enabled="false"
|
||||
android:fontFamily="@font/pretendard_bold"
|
||||
android:text="@string/report_button"
|
||||
android:textColor="@color/white" />
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
Reference in New Issue
Block a user