From c15da0e5b11d3ea7ea24134cc660d8ecae79338b Mon Sep 17 00:00:00 2001 From: bn-tw2020 Date: Fri, 15 Sep 2023 21:47:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20TOP-62=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81(UiModel)=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/tht/feature/chat/component/ChatItem.kt | 5 +++-- .../feature/chat/component/LazyColumnChatItem.kt | 3 ++- .../feature/chat/component/detail/ChatDetailList.kt | 4 ++-- .../tht/feature/chat/mapper/ChatListModelMapper.kt | 13 +++++++++++++ .../java/tht/feature/chat/model/ChatListUiModel.kt | 9 +++++++++ .../chat/viewmodel/detail/ChatDetailViewModel.kt | 4 ++-- .../chat/viewmodel/detail/state/ChatDetailState.kt | 4 ++-- .../feature/chat/viewmodel/state/ChatSkeleton.kt | 4 ++-- 8 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 feature/chat/src/main/java/tht/feature/chat/mapper/ChatListModelMapper.kt create mode 100644 feature/chat/src/main/java/tht/feature/chat/model/ChatListUiModel.kt diff --git a/feature/chat/src/main/java/tht/feature/chat/component/ChatItem.kt b/feature/chat/src/main/java/tht/feature/chat/component/ChatItem.kt index 9aa95fbe..8b9f1f60 100644 --- a/feature/chat/src/main/java/tht/feature/chat/component/ChatItem.kt +++ b/feature/chat/src/main/java/tht/feature/chat/component/ChatItem.kt @@ -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, ) { @@ -74,7 +75,7 @@ internal fun ChatItem( @Preview(showBackground = true, backgroundColor = 0xFF000000) internal fun ChatItemPreivew() { ChatItem( - item = ChatListModel( + item = ChatListUiModel( chatRoomIdx = 1L, partnerProfileUrl = "", partnerName = "스티치", diff --git a/feature/chat/src/main/java/tht/feature/chat/component/LazyColumnChatItem.kt b/feature/chat/src/main/java/tht/feature/chat/component/LazyColumnChatItem.kt index dca3a84a..863f5431 100644 --- a/feature/chat/src/main/java/tht/feature/chat/component/LazyColumnChatItem.kt +++ b/feature/chat/src/main/java/tht/feature/chat/component/LazyColumnChatItem.kt @@ -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, + items: ImmutableList, isLoading: Boolean, onClickItem: () -> Unit, ) { diff --git a/feature/chat/src/main/java/tht/feature/chat/component/detail/ChatDetailList.kt b/feature/chat/src/main/java/tht/feature/chat/component/detail/ChatDetailList.kt index 041f2d73..c58a2986 100644 --- a/feature/chat/src/main/java/tht/feature/chat/component/detail/ChatDetailList.kt +++ b/feature/chat/src/main/java/tht/feature/chat/component/detail/ChatDetailList.kt @@ -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) { +fun ChatDetailList(items: ImmutableList) { LazyColumn( modifier = Modifier .fillMaxSize() diff --git a/feature/chat/src/main/java/tht/feature/chat/mapper/ChatListModelMapper.kt b/feature/chat/src/main/java/tht/feature/chat/mapper/ChatListModelMapper.kt new file mode 100644 index 00000000..409d66ff --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/mapper/ChatListModelMapper.kt @@ -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, +) \ No newline at end of file diff --git a/feature/chat/src/main/java/tht/feature/chat/model/ChatListUiModel.kt b/feature/chat/src/main/java/tht/feature/chat/model/ChatListUiModel.kt new file mode 100644 index 00000000..b8de6ced --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/model/ChatListUiModel.kt @@ -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, +) \ No newline at end of file diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt b/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt index 547d9d9c..08838f87 100644 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt +++ b/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt @@ -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 @@ -36,7 +36,7 @@ internal class ChatDetailViewModel @Inject constructor() : ChatDetailState.ChatList( isLoading = false, chatList = persistentListOf( - ChatListModel( + ChatListUiModel( chatRoomIdx = 1L, partnerName = "하하", partnerProfileUrl = "", diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/state/ChatDetailState.kt b/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/state/ChatDetailState.kt index b38267a9..8d2bfed2 100644 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/state/ChatDetailState.kt +++ b/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/state/ChatDetailState.kt @@ -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 = persistentListOf(), + val chatList: ImmutableList = persistentListOf(), ) : ChatDetailState() } diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatSkeleton.kt b/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatSkeleton.kt index 129409fb..d5a4b1b6 100644 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatSkeleton.kt +++ b/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatSkeleton.kt @@ -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 = "",