Skip to content
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

[FIX/#160] 카드 후면 및 유저 리뷰 수정 #164

Merged
merged 6 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ class TeumMessagingService : FirebaseMessagingService() {
}
if (alertMessage.type == END_MEETING) {
alertMessage.meetingId = message.data["meetingId"]?.toLong()
// Timber.tag("teum-alerts").d("data: ${message.data}")
// Timber.tag("teum-alerts").d("participants string: ${message.data["participants"]?.split(",").toString()}")
// Timber.tag("teum-alerts").d("participants size: ${message.data["participants"]?.split(",")?.size}")
alertMessage.participants = message.data["participants"]?.split(",")?.map { it.toInt() }
val userId = userRepository.getUserInfo()?.id?.toInt()
if (alertMessage.participants?.contains(userId) == true)
if (alertMessage.participants?.contains(userId) == true && alertMessage.participants?.size!! > 2)
sendNotificationAlarm(alertMessage)
}
else if (alertMessage.title.isNotEmpty()) sendNotificationAlarm(alertMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class ReviewFriendDetailFragment :
private fun initClick() {
val friendDetail = ReviewFriend(id, characterId, name, job)
binding.btnReview.setOnSingleClickListener {
viewModel.addSelectDetailFriendList(friendDetail)
if (viewModel.currentFriendIndex < viewModel.selectFriendList.size) {
viewModel.addSelectDetailFriendList(friendDetail)
(requireActivity() as? ReviewActivity)?.nextFriendDetailFragment()
} else {
viewModel.postRegisterReview()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.teumteum.domain.entity.ReviewFriend
import com.teumteum.domain.repository.GroupRepository
import com.teumteum.domain.repository.UserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -12,13 +13,14 @@ import kotlinx.coroutines.launch

@HiltViewModel
class ReviewViewModel @Inject constructor(
private val repository: GroupRepository
private val repository: GroupRepository,
private val userRepository: UserRepository
) : ViewModel() {
private var _selectFriendList = listOf<ReviewFriend>()
val selectFriendList get() = _selectFriendList

private var _selectDetailFriendList = mutableListOf<ReviewFriend>()
val selectDetailFriendList get() = _selectFriendList
val selectDetailFriendList get() = _selectDetailFriendList

var meetingId: Long? = null

Expand All @@ -37,12 +39,19 @@ class ReviewViewModel @Inject constructor(
_selectDetailFriendList.add(selectFriendDetail)
}

private fun filterReviewFriendList(list: List<ReviewFriend>): List<ReviewFriend> {
val friendList = list.toMutableList()
val myUserId = userRepository.getUserInfo()?.id
friendList.removeAll { it.id == myUserId }
return friendList
}

fun getReviewFriendList() {
meetingId?.let { id ->
viewModelScope.launch {
repository.getReviewFriendList(id)
.onSuccess {
_moimFriendList.value = it
.onSuccess { list ->
_moimFriendList.value = filterReviewFriendList(list)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.teumteum.teumteum.util.SignupUtils.CHARACTER_CARD_LIST_BACK
import com.teumteum.teumteum.util.SignupUtils.STATUS_STUDENT
import com.teumteum.teumteum.util.SignupUtils.STATUS_TRAINEE
import com.teumteum.teumteum.util.SignupUtils.STATUS_WORKER
import com.teumteum.teumteum.util.custom.view.model.BackCard
import com.teumteum.teumteum.util.custom.view.model.FrontCard
import com.teumteum.teumteum.util.custom.view.model.Interest
import dagger.hilt.android.AndroidEntryPoint
Expand Down Expand Up @@ -60,9 +61,10 @@ class CardCompleteFragment
for (i in interestSelf.value) {
interests.add(Interest(i))
}

val bc = BackCard(goalContent = goalText.value, characterResId = CHARACTER_CARD_LIST_BACK[characterId.value])
binding.cardviewBack.getInstance(bc)
binding.cardviewBack.apply {
tvGoalContent.text = goalText.value
CHARACTER_CARD_LIST_BACK[characterId.value]?.let { ivCharacter.setImageResource(it) }
submitInterestList(interests)
isModify = false
setIsModifyDetail(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ class CardFixFragment
for (i in interestSelf.value) {
interests.add(Interest(i))
}

val bc = BackCard(goalContent = goalText.value, characterResId = SignupUtils.CHARACTER_CARD_LIST_BACK[characterId.value])
binding.cardviewBack.getInstance(bc)
binding.cardviewBack.apply {
setIsModifyDetail(true)
tvGoalContent.text = goalText.value
SignupUtils.CHARACTER_CARD_LIST_BACK[characterId.value]?.let { ivCharacter.setImageResource(it) }
submitInterestList(interests)
isModify = false
setIsModifyDetail(true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class GetNameFragment
}
else {
(activity as SignUpActivity).disableNextButton()
binding.tvCaption.visibility = View.VISIBLE
if (userName.isNotBlank()) binding.tvCaption.visibility = View.VISIBLE
else binding.tvCaption.visibility = View.INVISIBLE
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/teumteum/teumteum/util/ResMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ object ResMapper {
}
}

fun getColorByBackCardCharacterDrawble(context: Context, characterResId: Int): Int {
return when (characterResId) {
R.drawable.ic_card_back_ghost -> getColorByCharacterId(context, 0)
R.drawable.ic_card_back_star -> getColorByCharacterId(context, 1)
R.drawable.ic_card_back_bear -> getColorByCharacterId(context, 2)
R.drawable.ic_card_back_raccon -> getColorByCharacterId(context, 3)
R.drawable.ic_card_back_cat -> getColorByCharacterId(context, 4)
R.drawable.ic_card_back_rabbit -> getColorByCharacterId(context, 5)
R.drawable.ic_card_back_fox -> getColorByCharacterId(context, 6)
R.drawable.ic_card_back_water -> getColorByCharacterId(context, 7)
R.drawable.ic_card_back_penguin -> getColorByCharacterId(context, 8)
R.drawable.ic_card_back_dog -> getColorByCharacterId(context, 9)
R.drawable.ic_card_back_mouse -> getColorByCharacterId(context, 10)
R.drawable.ic_card_back_panda -> getColorByCharacterId(context, 11)
else -> getColorByCharacterId(context, 0)
}
}

fun getColorByCharacterId(context: Context, characterId: Int): Int {
return when (characterId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.google.android.flexbox.FlexWrap
import com.google.android.flexbox.FlexboxLayoutManager
import com.google.android.flexbox.JustifyContent
import com.teumteum.teumteum.R
import com.teumteum.teumteum.util.ResMapper
import com.teumteum.teumteum.util.callback.OnCurrentListChangedListener
import com.teumteum.teumteum.util.custom.itemdecoration.FlexboxItemDecoration
import com.teumteum.teumteum.util.custom.view.adapter.InterestAdapter
Expand Down Expand Up @@ -163,7 +164,10 @@ class BackCardView : CardView, OnCurrentListChangedListener<Interest> {
private fun setUpViews() {
tvGoalTitle.text = backCard.goalTitle
tvGoalContent.text = backCard.goalContent
backCard.characterResId?.let { ivCharacter.setImageResource(it) }
backCard.characterResId?.let {
ivCharacter.setImageResource(it)
tvGoalTitle.setTextColor(ResMapper.getColorByBackCardCharacterDrawble(context, it))
}
ivFloat.setImageResource(backCard.floatResId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.teumteum.data.datasource.remote
import com.teumteum.data.model.request.RequestReviewFriend
import com.teumteum.data.model.response.ResponseGroup
import com.teumteum.data.model.response.ResponseMeeting
import com.teumteum.data.model.response.ResponseReviewFriends
import com.teumteum.data.model.response.ResponseReviewFriend
import com.teumteum.data.service.GroupService
import okhttp3.MultipartBody
import okhttp3.RequestBody
Expand Down Expand Up @@ -85,7 +85,7 @@ class RemoteGroupDataSource @Inject constructor(

suspend fun getReviewFriendList(
meetingId: Long
): ResponseReviewFriends {
): List<ResponseReviewFriend> {
return service.getReviewFriendList(meetingId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class GroupRepositoryImpl @Inject constructor(

override suspend fun getReviewFriendList(meetingId: Long): Result<List<ReviewFriend>> {
return runCatching {
dataSource.getReviewFriendList(meetingId).participants.map { it.toReviewFriend() }
dataSource.getReviewFriendList(meetingId).map { it.toReviewFriend() }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package com.teumteum.data.service
import com.teumteum.data.model.request.RequestReviewFriend
import com.teumteum.data.model.response.ResponseGroup
import com.teumteum.data.model.response.ResponseMeeting
import com.teumteum.data.model.response.ResponseReviewFriends
import com.teumteum.domain.entity.Meeting
import com.teumteum.data.model.response.ResponseReviewFriend
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.Response
Expand Down Expand Up @@ -85,7 +84,7 @@ interface GroupService {
@GET("meetings/{meetingId}/participants")
suspend fun getReviewFriendList(
@Path("meetingId") meetingId: Long
): ResponseReviewFriends
): List<ResponseReviewFriend>

@POST("users/reviews")
suspend fun postRegisterReview(
Expand Down
Loading