Skip to content

Commit

Permalink
[FEAT] 미션 제안 신고하기 기능 구현 (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
915dbfl committed Mar 8, 2024
1 parent 3e62841 commit 2e89fa8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.lgtm.android.mission_suggestion.ui.detail

import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Toast
import androidx.activity.viewModels
import androidx.compose.runtime.Composable
import com.lgtm.android.common_ui.base.BaseComposeActivity
Expand All @@ -21,7 +25,8 @@ class SuggestionDetailActivity: BaseComposeActivity(){
override fun Content() {
LGTMTheme {
SuggestionDetailScreen(
onBackButtonClick = ::setBackButtonClick
onBackButtonClick = ::setBackButtonClick,
onReportSuggestionClick = ::setReportSuggestionClick
)
}
}
Expand All @@ -38,6 +43,20 @@ class SuggestionDetailActivity: BaseComposeActivity(){
finish()
}

private fun setReportSuggestionClick() {
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
putExtra(Intent.EXTRA_SUBJECT, "[LGTM] 미션 제안 불편사항 신고")
putExtra(Intent.EXTRA_TEXT, suggestionDetailViewModel.getReportMessage())
}
try {
startActivity(intent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(this, "메일을 보낼 수 없습니다", Toast.LENGTH_SHORT).show()
}
}

companion object {
const val SUGGESTION_ID = "suggestion_id"
private const val defaultValue = -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.lgtm.android.common_ui.model.SuggestionUI
import com.lgtm.android.common_ui.model.mapper.toUiModel
import com.lgtm.android.common_ui.util.UiState
import com.lgtm.domain.entity.response.SuggestionLikeVO
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.SuggestionRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -19,7 +20,8 @@ import javax.inject.Inject

@HiltViewModel
class SuggestionDetailViewModel @Inject constructor(
private val suggestionRepository: SuggestionRepository
private val suggestionRepository: SuggestionRepository,
private val authRepository: AuthRepository
): BaseViewModel() {

/* 미션 제안 상세 내용 */
Expand Down Expand Up @@ -96,4 +98,40 @@ class SuggestionDetailViewModel @Inject constructor(
}
}
}

/* 미션 제안 신고 기능 */
fun getReportMessage() =
"안녕하세요 고객님, LGTM 서비스 이용에 불편을 드려 죄송합니다. 보내주신 내용은 빠른 시일 내로 운영팀에서 처리하겠습니다.\n" +
"처리 결과는 발신된 이메일 주소로 전달될 예정입니다. 감사합니다.\n\n" +
"[신고 유형을 선택해주세요]\n" +
"1. 성적, 폭력적 또는 혐오스러운 내용\n" +
"2. 욕설 혹은 유해한 내용\n" +
"3. 기타 부적절한 내용\n" +
"4. 기타 서비스 이용 불편사항\n" +
"응답 : \n" +
"\n\n\n" +
"[신고 내용]\n" +
"불편을 겪으신 내용을 적어주세요. 필요시 사진을 첨부해주셔도 좋습니다.\n" +
"응답 : \n" +
"\n\n\n" +
"-------------------------------------------------\n" +
"아래 내용은 운영진에게 전달되는 정보니 수정하지 말아주세요:)\n\n" +
"[신고 정보]\n" +
"1. 신고자 ID : ${getUserId()}\n" +
"2. 미션 제안 제목 : ${getMissionTitle()}\n" +
"3. 미션 제안 본문 : ${getMissionDescription()} \n"

private fun getUserId() = authRepository.getMemberId()

private fun getMissionTitle(): String {
detailState.value.apply {
return if (this is UiState.Success) this.data.title else ""
}
}

private fun getMissionDescription(): String {
detailState.value.apply {
return if (this is UiState.Success) this.data.description else ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import kotlinx.coroutines.launch
@Composable
fun SuggestionDetailScreen(
viewModel: SuggestionDetailViewModel = hiltViewModel(),
onBackButtonClick: () -> Unit
onBackButtonClick: () -> Unit,
onReportSuggestionClick: () -> Unit
) {
val suggestionDetailState by viewModel.detailState.collectAsStateWithLifecycle()
val likeSuggestionState by viewModel.likeSuggestionState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -72,7 +73,7 @@ fun SuggestionDetailScreen(
bottomSheetState.show()
}
},
onReportSuggestion = { /* TODO: 신고 진행 */ },
onReportSuggestion = onReportSuggestionClick,
onBackButtonClick = onBackButtonClick,
)
SuggestionLikeSection(
Expand Down

0 comments on commit 2e89fa8

Please sign in to comment.