Skip to content

Commit

Permalink
feat: TOP-62 코드 리뷰 반영(UiModel) 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
taewooyo committed Sep 15, 2023
1 parent 1f9afca commit c15da0e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import com.example.compose_ui.component.text.p.ThtP1
import com.example.compose_ui.component.text.subtitle.ThtSubtitle2
import com.example.compose_ui.extensions.noRippleClickable
import com.tht.tht.domain.chat.model.ChatListModel
import tht.feature.chat.model.ChatListUiModel

@Composable
internal fun ChatItem(
item: ChatListModel,
item: ChatListUiModel,
isLoading: Boolean,
onClickItem: () -> Unit,
) {
Expand Down Expand Up @@ -74,7 +75,7 @@ internal fun ChatItem(
@Preview(showBackground = true, backgroundColor = 0xFF000000)
internal fun ChatItemPreivew() {
ChatItem(
item = ChatListModel(
item = ChatListUiModel(
chatRoomIdx = 1L,
partnerProfileUrl = "",
partnerName = "스티치",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import androidx.compose.ui.tooling.preview.Preview
import com.tht.tht.domain.chat.model.ChatListModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import tht.feature.chat.model.ChatListUiModel

@Composable
internal fun LazyColumnChatItem(
items: ImmutableList<ChatListModel>,
items: ImmutableList<ChatListUiModel>,
isLoading: Boolean,
onClickItem: () -> Unit,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import com.example.compose_ui.component.spacer.Spacer
import com.example.compose_ui.component.text.caption.ThtCaption2
import com.example.compose_ui.component.text.p.ThtP1
import com.example.compose_ui.component.text.p.ThtP2
import com.tht.tht.domain.chat.model.ChatListModel
import kotlinx.collections.immutable.ImmutableList
import tht.feature.chat.model.ChatListUiModel

@Composable
fun ChatDetailList(items: ImmutableList<ChatListModel>) {
fun ChatDetailList(items: ImmutableList<ChatListUiModel>) {
LazyColumn(
modifier = Modifier
.fillMaxSize()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tht.feature.chat.mapper

import com.tht.tht.domain.chat.model.ChatListModel
import tht.feature.chat.model.ChatListUiModel


fun ChatListModel.toModel() = ChatListUiModel(
chatRoomIdx = chatRoomIdx,
partnerName = partnerName,
partnerProfileUrl = partnerProfileUrl,
currentMessage = currentMessage,
messageTime = messageTime,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tht.feature.chat.model

data class ChatListUiModel(
val chatRoomIdx: Long,
val partnerName: String,
val partnerProfileUrl: String,
val currentMessage: String,
val messageTime: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import com.example.compose_ui.common.viewmodel.Container
import com.example.compose_ui.common.viewmodel.Store
import com.example.compose_ui.common.viewmodel.intent
import com.example.compose_ui.common.viewmodel.store
import com.tht.tht.domain.chat.model.ChatListModel
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import tht.feature.chat.model.ChatListUiModel
import tht.feature.chat.viewmodel.detail.sideeffect.ChatDetailSideEffect
import tht.feature.chat.viewmodel.detail.state.ChatDetailState
import tht.feature.chat.viewmodel.state.skeletonChatList
Expand All @@ -36,7 +36,7 @@ internal class ChatDetailViewModel @Inject constructor() :
ChatDetailState.ChatList(
isLoading = false,
chatList = persistentListOf(
ChatListModel(
ChatListUiModel(
chatRoomIdx = 1L,
partnerName = "하하",
partnerProfileUrl = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package tht.feature.chat.viewmodel.detail.state

import com.tht.tht.domain.chat.model.ChatListModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import tht.feature.chat.model.ChatListUiModel

sealed class ChatDetailState {
data class ChatList(
val isLoading: Boolean,
val chatList: ImmutableList<ChatListModel> = persistentListOf(),
val chatList: ImmutableList<ChatListUiModel> = persistentListOf(),
) : ChatDetailState()
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tht.feature.chat.viewmodel.state

import com.tht.tht.domain.chat.model.ChatListModel
import kotlinx.collections.immutable.toImmutableList
import tht.feature.chat.model.ChatListUiModel

internal val skeletonChatList = (1..20).map {
ChatListModel(
ChatListUiModel(
chatRoomIdx = it.toLong(),
partnerName = it.toString(),
partnerProfileUrl = "",
Expand Down

0 comments on commit c15da0e

Please sign in to comment.