Skip to content

Commit

Permalink
Merge 3ff32b8 into 948f11e
Browse files Browse the repository at this point in the history
  • Loading branch information
915dbfl authored Apr 1, 2024
2 parents 948f11e + 3ff32b8 commit ec13f6e
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.lgtm.domain.server_drive_ui.SduiViewType

class SduiAdapter(
private val onMissionClickListener: (SduiContent) -> Unit,
private val onRecommendationClickListener: () -> Unit
private val onRecommendationClickListener: (SduiContent) -> Unit
) : ListAdapter<SduiItemVO, SduiBaseHolder>(
ItemDiffCallback<SduiItemVO>(onContentsTheSame = { old, new -> old == new },
onItemsTheSame = { old, new -> old.content == new.content })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ fun SuggestionVO.toUiModel(): SuggestionUI {
)
}

fun SuggestionUI.toVOModel(): SuggestionVO {
return SuggestionVO(
viewType = viewType,
title = title,
description = description,
suggestionId = suggestionId,
date = "$date $time",
likeNum = likeNum,
isLiked = isLiked,
isMyPost = isMyPost
)
}

fun NotificationVO.toUiModel(): NotificationUI {
return NotificationUI(
title = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import com.lgtm.domain.server_drive_ui.SectionSubItemVO
class SduiSubItemViewHolder(
private val binding: ItemSduiSubItemBinding
) : SduiBaseHolder(binding) {
private lateinit var navigateToRecommendationDashboard: () -> Unit
private lateinit var navigateToRecommendationDashboard: (SduiContent) -> Unit

override fun bind(theme: SduiTheme, viewContent: SduiContent) {
binding.data = viewContent as SectionSubItemVO
binding.theme = theme
binding.btnMissionRecommend.setOnThrottleClickListener {
// todo 추후 appUrl을 활용한 화면 전환 처리
navigateToRecommendationDashboard()
navigateToRecommendationDashboard(viewContent)
}
}

fun setNavigateToRecommendationDashboard(navigateToRecommendationDashboard: () -> Unit) {
fun setNavigateToRecommendationDashboard(navigateToRecommendationDashboard: (SduiContent) -> Unit) {
this.navigateToRecommendationDashboard = navigateToRecommendationDashboard
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import com.lgtm.android.main.databinding.FragmentHomeBinding
import com.lgtm.domain.constants.Role
import com.lgtm.domain.logging.FirstMissionClickScheme
import com.lgtm.domain.logging.HomeMissionClickScheme
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import com.lgtm.domain.server_drive_ui.SduiContent
import com.lgtm.domain.server_drive_ui.SectionItemVO
import com.lgtm.domain.server_drive_ui.SectionSubItemVO
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.AndroidEntryPoint
import kotlin.properties.Delegates
Expand Down Expand Up @@ -84,8 +86,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
moveToMissionDetail((sduiContent as SectionItemVO).missionId)
}

private fun onClickRecommendation() {
private fun onClickRecommendation(sduiContent: SduiContent) {
moveToRecommendationDashboard()
logMissionSuggestionClick(sduiContent)
}

private fun logFirstMissionClick(sduiContent: SduiContent) {
Expand Down Expand Up @@ -144,4 +147,18 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(R.layout.fragment_home) {
}
}

private fun logMissionSuggestionClick(sduiContent: SduiContent) {
val role = homeViewModel.getUserRole()
val missionSuggestionClickScheme = SwmCommonLoggingScheme.Builder()
.setEventLogName("suggestionClick")
.setScreenName(this.javaClass)
.setLogData(mapOf(
"memberType" to role.role,
"suggestionTitle" to homeViewModel.getMissionSuggestionTitle(),
"suggestionDescription" to (sduiContent as SectionSubItemVO).text
))
.build()
homeViewModel.shotMissionSuggestionClickLogging(missionSuggestionClickScheme)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.lgtm.android.common_ui.base.BaseViewModel
import com.lgtm.domain.constants.Role
import com.lgtm.domain.constants.UNKNOWN
import com.lgtm.domain.entity.response.SduiItemVO
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.LoggingRepository
import com.lgtm.domain.repository.NotificationRepository
import com.lgtm.domain.server_drive_ui.SectionSubItemVO
import com.lgtm.domain.server_drive_ui.SectionTitleVO
import com.lgtm.domain.usecase.MissionUseCase
import com.swm.logging.android.SWMLogging
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
Expand All @@ -23,7 +26,8 @@ import javax.inject.Inject
class HomeViewModel @Inject constructor(
private val useCase: MissionUseCase,
private val notificationRepository: NotificationRepository,
authRepository: AuthRepository,
private val loggingRepository: LoggingRepository,
authRepository: AuthRepository
) : BaseViewModel() {

private val role = authRepository.getMemberType()
Expand Down Expand Up @@ -61,12 +65,36 @@ class HomeViewModel @Inject constructor(
}

fun shotHomeMissionClickLogging(swmLoggingScheme: SWMLoggingScheme) {
SWMLogging.logEvent(swmLoggingScheme)
loggingRepository.shotSwmLogging(swmLoggingScheme)
}

fun getUserRole() = role

fun shotFirstMissionClickLogging(swmLoggingScheme: SWMLoggingScheme) {
SWMLogging.logEvent(swmLoggingScheme)
loggingRepository.shotSwmLogging(swmLoggingScheme)
}

fun shotMissionSuggestionClickLogging(swmLoggingScheme: SWMLoggingScheme) {
loggingRepository.shotSwmLogging(swmLoggingScheme)
}

fun getMissionSuggestionTitle(): String {
val idx = getMissionSuggestionTitleIdx()
return idx?.let {
(_sduiList.value?.get(it)?.content as? SectionTitleVO)?.title ?: UNKNOWN
} ?: UNKNOWN
}

private fun getMissionSuggestionTitleIdx(): Int? {
var titleIdx: Int? = null
_sduiList.value?.let {
for(i in it.indices) {
if (it[i].content is SectionSubItemVO) {
titleIdx = i-1
break
}
}
}
return titleIdx
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.lgtm.android.common_ui.base.BaseComposeActivity
import com.lgtm.android.common_ui.theme.LGTMTheme
import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.SuggestionDashboardScreen
import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract.SuggestionDashboardUiEffect
import com.lgtm.domain.logging.SwmCommonLoggingScheme
import com.lgtm.domain.mission_suggestion.SuggestionContent
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -61,9 +63,22 @@ class SuggestionDashboardActivity : BaseComposeActivity() {
effect.suggestionId
)
}

is SuggestionDashboardUiEffect.ShotSuggestionClickLogging -> {
val scheme = getHomeSuggestionItemClickLoggingScheme(effect.suggestionContent)
suggestionDashboardViewModel.shotSwmLogging(scheme)
}
}
}
}
}
}

private fun getHomeSuggestionItemClickLoggingScheme(suggestionContent: SuggestionContent): SwmCommonLoggingScheme {
return SwmCommonLoggingScheme.Builder()
.setEventLogName("suggestionItemClick")
.setScreenName(this.javaClass)
.setLogData(mapOf("suggestionItem" to suggestionContent))
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.google.firebase.ktx.Firebase
import com.lgtm.android.common_ui.base.BaseViewModel
import com.lgtm.android.common_ui.model.SuggestionUI
import com.lgtm.android.common_ui.model.mapper.toUiModel
import com.lgtm.android.common_ui.model.mapper.toVOModel
import com.lgtm.android.common_ui.util.UiState
import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract.SuggestionDashboardInputs
import com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract.SuggestionDashboardOutputs
Expand All @@ -17,8 +18,10 @@ import com.lgtm.domain.mission_suggestion.SuggestionContent
import com.lgtm.domain.mission_suggestion.SuggestionVO
import com.lgtm.domain.mission_suggestion.SuggestionViewType
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.LoggingRepository
import com.lgtm.domain.repository.SuggestionRepository
import com.lgtm.domain.usecase.SuggestionUseCase
import com.swm.logging.android.logging_scheme.SWMLoggingScheme
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -31,6 +34,7 @@ import javax.inject.Inject
class SuggestionDashboardViewModel @Inject constructor(
private val suggestionUseCase: SuggestionUseCase,
private val suggestionRepository: SuggestionRepository,
private val loggingRepository: LoggingRepository,
authRepository: AuthRepository
): BaseViewModel(), SuggestionDashboardInputs, SuggestionDashboardOutputs {

Expand Down Expand Up @@ -115,9 +119,11 @@ class SuggestionDashboardViewModel @Inject constructor(
}
}

override fun moveToSuggestionDetail(suggestionId: Int) {
override fun moveToSuggestionDetail(suggestionId: Int, suggestionUI: SuggestionUI) {
val suggestionContent = suggestionUI.toVOModel()
viewModelScope.launch(lgtmErrorHandler) {
_suggestionDashboardUiEffect.emit(SuggestionDashboardUiEffect.SuggestionDetail(suggestionId))
_suggestionDashboardUiEffect.emit(SuggestionDashboardUiEffect.ShotSuggestionClickLogging(suggestionContent))
}
}

Expand All @@ -127,4 +133,7 @@ class SuggestionDashboardViewModel @Inject constructor(
}
}

fun shotSwmLogging(swmLoggingScheme: SWMLoggingScheme) {
loggingRepository.shotSwmLogging(swmLoggingScheme)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fun SuggestionHeader(
fun SuggestionList(
modifier: Modifier = Modifier,
suggestionList: List<SuggestionContent>,
onSuggestionClick: (Int) -> Unit,
onSuggestionClick: (Int, SuggestionUI) -> Unit,
onSuggestionLike: (Int, Int) -> Unit,
onSuggestionCancelLike: (Int, Int) -> Unit
) {
Expand All @@ -181,7 +181,7 @@ fun SuggestionList(
fun getSuggestionViewByType(
index: Int,
suggestionContent: SuggestionContent,
onSuggestionClick: (Int) -> Unit,
onSuggestionClick: (Int, SuggestionUI) -> Unit,
onSuggestionLike: (Int, Int) -> Unit,
onSuggestionCancelLike: (Int, Int) -> Unit
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract

import com.lgtm.android.common_ui.model.SuggestionUI

interface SuggestionDashboardInputs {
fun likeSuggestion(index: Int, suggestionId: Int)
fun cancelLikeSuggestion(index: Int, suggestionId: Int)
fun moveToCreateSuggestion()
fun moveToSuggestionDetail(suggestionId: Int)
fun moveToSuggestionDetail(suggestionId: Int, suggestionUI: SuggestionUI)
fun goBack()
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.lgtm.android.mission_suggestion.ui.dashboard.presentation.contract

import com.lgtm.domain.mission_suggestion.SuggestionContent

sealed class SuggestionDashboardUiEffect {
object GoBack: SuggestionDashboardUiEffect()
object CreateSuggestion: SuggestionDashboardUiEffect()
data class SuggestionDetail(val suggestionId: Int): SuggestionDashboardUiEffect()
data class ShotSuggestionClickLogging(val suggestionContent: SuggestionContent): SuggestionDashboardUiEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.lgtm.android.common_ui.util.throttleClickable
fun SuggestionContent(
index: Int,
suggestionUI: SuggestionUI,
onSuggestionClick: (Int) -> Unit,
onSuggestionClick: (Int, SuggestionUI) -> Unit,
onSuggestionLike: (Int, Int) -> Unit,
onSuggestionCancelLike: (Int, Int) -> Unit
) {
Expand All @@ -47,7 +47,7 @@ fun SuggestionContent(
)
.throttleClickable(
enabled = true,
onClick = { onSuggestionClick(suggestionUI.suggestionId) }
onClick = { onSuggestionClick(suggestionUI.suggestionId, suggestionUI) }
)
) {
Text(
Expand Down

0 comments on commit ec13f6e

Please sign in to comment.