diff --git a/app/src/main/java/com/tht/tht/HomeActivity.kt b/app/src/main/java/com/tht/tht/HomeActivity.kt index 072d541b..ad249dca 100644 --- a/app/src/main/java/com/tht/tht/HomeActivity.kt +++ b/app/src/main/java/com/tht/tht/HomeActivity.kt @@ -17,7 +17,7 @@ import tht.core.ui.base.BaseActivity import tht.core.ui.base.FragmentNavigator import tht.core.ui.delegate.viewBinding import tht.core.ui.extension.hideSoftInput -import tht.feature.chat.ChatFragment +import tht.feature.chat.chat.fragment.ChatFragment import tht.feature.like.like.LikeFragment import tht.feature.setting.MyPageFragment import tht.feature.tohot.tohot.fragment.ToHotFragment diff --git a/core/navigation/src/main/java/tht/core/navigation/ChatNavigation.kt b/core/navigation/src/main/java/tht/core/navigation/ChatNavigation.kt new file mode 100644 index 00000000..14eae702 --- /dev/null +++ b/core/navigation/src/main/java/tht/core/navigation/ChatNavigation.kt @@ -0,0 +1,10 @@ +package tht.core.navigation + +import androidx.fragment.app.FragmentManager + +interface ChatNavigation { + fun navigateChat( + fragmentManager: FragmentManager, + fragmentContainerResourceId: Int + ) +} diff --git a/feature/chat/src/main/AndroidManifest.xml b/feature/chat/src/main/AndroidManifest.xml index d2c10d3d..6bd6429b 100644 --- a/feature/chat/src/main/AndroidManifest.xml +++ b/feature/chat/src/main/AndroidManifest.xml @@ -1,10 +1,5 @@ - + - - - - \ No newline at end of file + diff --git a/feature/chat/src/main/java/tht/feature/chat/ChatFragment.kt b/feature/chat/src/main/java/tht/feature/chat/chat/fragment/ChatFragment.kt similarity index 79% rename from feature/chat/src/main/java/tht/feature/chat/ChatFragment.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/fragment/ChatFragment.kt index 247cbb03..ff73f2de 100644 --- a/feature/chat/src/main/java/tht/feature/chat/ChatFragment.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/fragment/ChatFragment.kt @@ -1,4 +1,4 @@ -package tht.feature.chat +package tht.feature.chat.chat.fragment import android.os.Bundle import android.view.LayoutInflater @@ -8,8 +8,7 @@ import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment import dagger.hilt.android.AndroidEntryPoint -import tht.feature.chat.screen.ChatScreen -import tht.feature.chat.screen.detail.ChatDetailActivity +import tht.feature.chat.navigation.ChatNavigation @AndroidEntryPoint class ChatFragment : Fragment() { @@ -25,9 +24,7 @@ class ChatFragment : Fragment() { return ComposeView(requireContext()).apply { setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { - ChatScreen { - startActivity(ChatDetailActivity.newIntent(requireContext())) - } + ChatNavigation() } } } diff --git a/feature/chat/src/main/java/tht/feature/chat/screen/detail/screen/ChatDetailScreen.kt b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatDetailScreen.kt similarity index 91% rename from feature/chat/src/main/java/tht/feature/chat/screen/detail/screen/ChatDetailScreen.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatDetailScreen.kt index 0c78dda6..4eaa2c8f 100644 --- a/feature/chat/src/main/java/tht/feature/chat/screen/detail/screen/ChatDetailScreen.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatDetailScreen.kt @@ -1,4 +1,4 @@ -package tht.feature.chat.screen.detail.screen +package tht.feature.chat.chat.screen import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -11,11 +11,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.hilt.navigation.compose.hiltViewModel import com.example.compose_ui.common.viewmodel.collectAsState +import tht.feature.chat.chat.state.ChatDetailState +import tht.feature.chat.chat.viewmodel.ChatDetailViewModel import tht.feature.chat.component.detail.ChatDetailList import tht.feature.chat.component.detail.ChatDetailTopAppBar import tht.feature.chat.component.detail.ChatEditTextContainer -import tht.feature.chat.viewmodel.detail.ChatDetailViewModel -import tht.feature.chat.viewmodel.detail.state.ChatDetailState @Composable internal fun ChatDetailScreen( diff --git a/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatEmptyScreen.kt b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatEmptyScreen.kt new file mode 100644 index 00000000..653e8d7b --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatEmptyScreen.kt @@ -0,0 +1,75 @@ +package tht.feature.chat.chat.screen + +import androidx.compose.foundation.Image +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import com.example.compose_ui.component.button.ThtButton +import com.example.compose_ui.component.text.headline.ThtHeadline4 +import com.example.compose_ui.component.text.headline.ThtHeadline5 +import com.example.compose_ui.component.text.p.ThtP1 +import tht.feature.chat.R + +@Composable +internal fun ChatEmptyScreen( + onClickChangeTitle: () -> Unit +) { + Column( + modifier = Modifier.fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Image( + painter = painterResource(id = R.drawable.ic_empty), + contentDescription = null + ) + Spacer(modifier = Modifier.height(16.dp)) + ThtHeadline4( + text = "아직 매칭된 무디가 없어요", + fontWeight = FontWeight.W600, + color = Color.White + ) + Spacer(modifier = Modifier.height(6.dp)) + ThtP1( + text = "대화가 잘 통하는 무디를 찾아볼까요?", + fontWeight = FontWeight.W400, + color = Color(0xFF8D8D8D) + ) + } + Spacer(modifier = Modifier.height(64.dp)) + ThtButton( + modifier = Modifier + .clip(RoundedCornerShape(16.dp)) + .border(1.dp, Color.White, RoundedCornerShape(16.dp)) + .padding(horizontal = 70.dp), + backgroundColor = Color.Transparent, + contentColor = Color.White, + onClick = onClickChangeTitle, + content = { + ThtHeadline5( + text = "무디들 만나러 가기", + fontWeight = FontWeight.W700, + color = Color.White + ) + } + ) + Spacer(modifier = Modifier.height(56.dp)) + } +} diff --git a/feature/chat/src/main/java/tht/feature/chat/screen/chatlist/ChatListScreen.kt b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatListScreen.kt similarity index 86% rename from feature/chat/src/main/java/tht/feature/chat/screen/chatlist/ChatListScreen.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatListScreen.kt index f34d3fb8..926a743c 100644 --- a/feature/chat/src/main/java/tht/feature/chat/screen/chatlist/ChatListScreen.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatListScreen.kt @@ -1,11 +1,11 @@ -package tht.feature.chat.screen.chatlist +package tht.feature.chat.chat.screen import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import tht.feature.chat.component.LazyColumnChatItem -import tht.feature.chat.viewmodel.state.ChatState +import tht.feature.chat.chat.state.ChatState @Composable internal fun ChatListScreen( diff --git a/feature/chat/src/main/java/tht/feature/chat/screen/ChatScreen.kt b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatScreen.kt similarity index 88% rename from feature/chat/src/main/java/tht/feature/chat/screen/ChatScreen.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatScreen.kt index 0507bc8d..a854b2ee 100644 --- a/feature/chat/src/main/java/tht/feature/chat/screen/ChatScreen.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/screen/ChatScreen.kt @@ -1,4 +1,4 @@ -package tht.feature.chat.screen +package tht.feature.chat.chat.screen import androidx.compose.animation.Crossfade import androidx.compose.animation.core.tween @@ -15,9 +15,8 @@ import androidx.hilt.navigation.compose.hiltViewModel import com.example.compose_ui.R import com.example.compose_ui.common.viewmodel.collectAsState import tht.feature.chat.component.ChatTopAppBar -import tht.feature.chat.screen.chatlist.ChatListScreen -import tht.feature.chat.viewmodel.chatlist.ChatViewModel -import tht.feature.chat.viewmodel.state.ChatState +import tht.feature.chat.chat.viewmodel.ChatViewModel +import tht.feature.chat.chat.state.ChatState @Composable internal fun ChatScreen( @@ -25,7 +24,7 @@ internal fun ChatScreen( navigateChatDetail: () -> Unit = { } ) { LaunchedEffect(key1 = Unit) { - viewModel.getChatList() + viewModel.getFakeChatList() } val state = viewModel.collectAsState().value diff --git a/feature/chat/src/main/java/tht/feature/chat/chat/screen/Extensions.kt b/feature/chat/src/main/java/tht/feature/chat/chat/screen/Extensions.kt new file mode 100644 index 00000000..46566d68 --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/chat/screen/Extensions.kt @@ -0,0 +1,46 @@ +package tht.feature.chat.chat.screen + +import android.os.Build +import androidx.annotation.RequiresApi +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.ui.platform.LocalLifecycleOwner +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver +import androidx.lifecycle.LifecycleOwner +import java.time.Instant +import java.time.LocalDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter + +@Composable +fun OnLifecycleEvent( + onEvent: ( + owner: LifecycleOwner, + event: Lifecycle.Event + ) -> Unit +) { + val eventHandler = rememberUpdatedState(onEvent) + val lifecycleOwner = rememberUpdatedState(LocalLifecycleOwner.current) + + DisposableEffect(lifecycleOwner.value) { + val lifecycle = lifecycleOwner.value.lifecycle + val observer = LifecycleEventObserver { owner, event -> + eventHandler.value(owner, event) + } + + lifecycle.addObserver(observer) + onDispose { + lifecycle.removeObserver(observer) + } + } +} + +@RequiresApi(Build.VERSION_CODES.O) +fun format(milliseconds: Long): String { + return LocalDateTime.ofInstant( + Instant.ofEpochMilli(milliseconds), + ZoneOffset.systemDefault() + ).format(DateTimeFormatter.ISO_DATE) +} diff --git a/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatDetailSideEffect.kt b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatDetailSideEffect.kt new file mode 100644 index 00000000..59807f4c --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatDetailSideEffect.kt @@ -0,0 +1,3 @@ +package tht.feature.chat.chat.state + +sealed class ChatDetailSideEffect 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/chat/state/ChatDetailState.kt similarity index 87% rename from feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/state/ChatDetailState.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/state/ChatDetailState.kt index 6bc2d8e7..b2386357 100644 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/state/ChatDetailState.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatDetailState.kt @@ -1,4 +1,4 @@ -package tht.feature.chat.viewmodel.detail.state +package tht.feature.chat.chat.state import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf diff --git a/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatSideEffect.kt b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatSideEffect.kt new file mode 100644 index 00000000..7c2971c5 --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatSideEffect.kt @@ -0,0 +1,3 @@ +package tht.feature.chat.chat.state + +sealed class ChatSideEffect diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatState.kt b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatState.kt similarity index 89% rename from feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatState.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/state/ChatState.kt index 3f9608bb..9d33a745 100644 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatState.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/state/ChatState.kt @@ -1,4 +1,4 @@ -package tht.feature.chat.viewmodel.state +package tht.feature.chat.chat.state import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt b/feature/chat/src/main/java/tht/feature/chat/chat/viewmodel/ChatDetailViewModel.kt similarity index 82% rename from feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt rename to feature/chat/src/main/java/tht/feature/chat/chat/viewmodel/ChatDetailViewModel.kt index 5921e1af..778c6878 100644 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/ChatDetailViewModel.kt +++ b/feature/chat/src/main/java/tht/feature/chat/chat/viewmodel/ChatDetailViewModel.kt @@ -1,4 +1,4 @@ -package tht.feature.chat.viewmodel.detail +package tht.feature.chat.chat.viewmodel import androidx.lifecycle.ViewModel import com.example.compose_ui.common.viewmodel.Container @@ -10,21 +10,19 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update +import tht.feature.chat.chat.state.ChatDetailSideEffect +import tht.feature.chat.chat.state.ChatDetailState 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 import javax.inject.Inject @HiltViewModel internal class ChatDetailViewModel @Inject constructor() : - ViewModel(), - Container { + ViewModel(), Container { override val store: Store = store( initialState = ChatDetailState.ChatList( isLoading = true, - chatList = skeletonChatList + chatList = persistentListOf() ) ) diff --git a/feature/chat/src/main/java/tht/feature/chat/chat/viewmodel/ChatViewModel.kt b/feature/chat/src/main/java/tht/feature/chat/chat/viewmodel/ChatViewModel.kt new file mode 100644 index 00000000..7e36b9e5 --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/chat/viewmodel/ChatViewModel.kt @@ -0,0 +1,86 @@ +package tht.feature.chat.chat.viewmodel + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +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 com.tht.tht.domain.chat.usecase.GetChatListUseCase +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.toImmutableList +import kotlinx.coroutines.launch +import tht.feature.chat.chat.state.ChatSideEffect +import tht.feature.chat.chat.state.ChatState +import tht.feature.chat.mapper.toModel +import javax.inject.Inject + +@HiltViewModel +internal class ChatViewModel @Inject constructor( + private val getChatListUseCase: GetChatListUseCase +) : ViewModel(), Container { + override val store: Store = + store(initialState = ChatState.ChatList(isLoading = true, chatList = persistentListOf())) + + fun getChatList() { + viewModelScope.launch { + val chatList = getChatListUseCase().getOrNull() ?: listOf() + intent { + reduce { + if (chatList.isEmpty()) { + ChatState.Empty + } else { + ChatState.ChatList( + isLoading = false, + chatList = chatList.map { it.toModel() }.toImmutableList() + ) + } + } + } + } + } + + fun getFakeChatList() { + viewModelScope.launch { + intent { + reduce { + ChatState.ChatList( + isLoading = false, + chatList = listOf( + ChatListModel( + chatRoomIdx = 1L, + partnerName = "최웅재", + partnerProfileUrl = "", + currentMessage = "안녕", + messageTime = "2020.08.08" + ), + ChatListModel( + chatRoomIdx = 2L, + partnerName = "최웅재", + partnerProfileUrl = "", + currentMessage = "안녕", + messageTime = "2020.08.08" + ), + ChatListModel( + chatRoomIdx = 3L, + partnerName = "최웅재", + partnerProfileUrl = "", + currentMessage = "안녕", + messageTime = "2020.08.08" + ), + ChatListModel( + chatRoomIdx = 4L, + partnerName = "최웅재", + partnerProfileUrl = "", + currentMessage = "안녕", + messageTime = "2020.08.08" + ) + ).map { it.toModel() }.toImmutableList() + ) + } + } + } + } +} diff --git a/feature/chat/src/main/java/tht/feature/chat/navigation/ChatDestination.kt b/feature/chat/src/main/java/tht/feature/chat/navigation/ChatDestination.kt new file mode 100644 index 00000000..bc4c368d --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/navigation/ChatDestination.kt @@ -0,0 +1,13 @@ +package tht.feature.chat.navigation + +interface ChatDestination { + val route: String +} + +object Chat : ChatDestination { + override val route: String = "chat" +} + +object ChatDetail : ChatDestination { + override val route: String = "chat-detail" +} diff --git a/feature/chat/src/main/java/tht/feature/chat/navigation/ChatNavigation.kt b/feature/chat/src/main/java/tht/feature/chat/navigation/ChatNavigation.kt new file mode 100644 index 00000000..fb687c67 --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/navigation/ChatNavigation.kt @@ -0,0 +1,39 @@ +package tht.feature.chat.navigation + +import androidx.compose.runtime.Composable +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import tht.feature.chat.chat.screen.ChatDetailScreen +import tht.feature.chat.chat.screen.ChatScreen + +@Composable +fun ChatNavigation() { + val navController = rememberNavController() + NavHost( + navController = navController, + startDestination = Chat.route + ) { + addChatNavGraph(navController) + } +} + +private fun NavGraphBuilder.addChatNavGraph( + navController: NavHostController +) { + composable( + route = Chat.route + ) { + ChatScreen( + navigateChatDetail = { navController.navigate(ChatDetail.route) } + ) + } + + composable( + route = ChatDetail.route + ) { + ChatDetailScreen() + } +} diff --git a/feature/chat/src/main/java/tht/feature/chat/navigation/ChatNavigationImpl.kt b/feature/chat/src/main/java/tht/feature/chat/navigation/ChatNavigationImpl.kt new file mode 100644 index 00000000..cad5a41d --- /dev/null +++ b/feature/chat/src/main/java/tht/feature/chat/navigation/ChatNavigationImpl.kt @@ -0,0 +1,25 @@ +package tht.feature.chat.navigation + +import androidx.fragment.app.FragmentManager +import tht.core.navigation.ChatNavigation +import tht.feature.chat.chat.fragment.ChatFragment +import javax.inject.Inject + +class ChatNavigationImpl @Inject constructor() : ChatNavigation { + override fun navigateChat( + fragmentManager: FragmentManager, + fragmentContainerResourceId: Int + ) { + val foundFragment = fragmentManager.findFragmentByTag(ChatFragment.TAG) + fragmentManager.fragments.forEach { fm -> + fragmentManager.beginTransaction().hide(fm).commitAllowingStateLoss() + } + foundFragment?.let { + fragmentManager.beginTransaction().show(it).commitAllowingStateLoss() + } ?: run { + fragmentManager.beginTransaction() + .add(fragmentContainerResourceId, ChatFragment.newInstance(), ChatFragment.TAG) + .commitAllowingStateLoss() + } + } +} diff --git a/feature/chat/src/main/java/tht/feature/chat/screen/ChatEmptyScreen.kt b/feature/chat/src/main/java/tht/feature/chat/screen/ChatEmptyScreen.kt deleted file mode 100644 index 56d56872..00000000 --- a/feature/chat/src/main/java/tht/feature/chat/screen/ChatEmptyScreen.kt +++ /dev/null @@ -1,73 +0,0 @@ -package tht.feature.chat.screen - -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.example.compose_ui.component.button.ThtButton -import com.example.compose_ui.component.text.headline.ThtHeadline4 -import com.example.compose_ui.component.text.headline.ThtHeadline5 -import com.example.compose_ui.component.text.p.ThtP1 -import tht.feature.chat.R - -@Composable -internal fun ChatEmptyScreen( - onClickChangeTitle: () -> Unit -) { - Column( - modifier = Modifier.fillMaxSize() - ) { - Column( - modifier = Modifier.fillMaxSize(), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center - ) { - Column( - modifier = Modifier.weight(1f), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center - ) { - Image( - painter = painterResource(id = R.drawable.ic_empty), - contentDescription = null - ) - Spacer(modifier = Modifier.height(16.dp)) - ThtHeadline4( - text = "아직 매칭된 무디가 없어요", - fontWeight = FontWeight.W600, - color = Color.White - ) - Spacer(modifier = Modifier.height(6.dp)) - ThtP1( - text = "대화가 잘 통하는 무디를 찾아볼까요?", - fontWeight = FontWeight.W400, - color = Color(0xFF8D8D8D) - ) - } - ThtButton( - backgroundColor = Color(0xFFF9CC2E), - contentColor = Color.Black, - onClick = onClickChangeTitle, - content = { - ThtHeadline5( - modifier = Modifier.padding(horizontal = 96.dp, vertical = 15.dp), - text = "주제 변경하기", - fontWeight = FontWeight.W700, - color = Color.Black - ) - } - ) - Spacer(modifier = Modifier.height(56.dp)) - } - } -} diff --git a/feature/chat/src/main/java/tht/feature/chat/screen/detail/ChatDetailActivity.kt b/feature/chat/src/main/java/tht/feature/chat/screen/detail/ChatDetailActivity.kt deleted file mode 100644 index f1b96dd8..00000000 --- a/feature/chat/src/main/java/tht/feature/chat/screen/detail/ChatDetailActivity.kt +++ /dev/null @@ -1,21 +0,0 @@ -package tht.feature.chat.screen.detail - -import android.content.Context -import android.content.Intent -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import androidx.activity.compose.setContent -import tht.feature.chat.screen.detail.screen.ChatDetailScreen - -class ChatDetailActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - ChatDetailScreen() - } - } - - companion object { - fun newIntent(context: Context) = Intent(context, ChatDetailActivity::class.java) - } -} diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/chatlist/ChatViewModel.kt b/feature/chat/src/main/java/tht/feature/chat/viewmodel/chatlist/ChatViewModel.kt deleted file mode 100644 index cd2dafa7..00000000 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/chatlist/ChatViewModel.kt +++ /dev/null @@ -1,39 +0,0 @@ -package tht.feature.chat.viewmodel.chatlist - -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -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.usecase.GetChatListUseCase -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.collections.immutable.toImmutableList -import kotlinx.coroutines.launch -import tht.feature.chat.mapper.toModel -import tht.feature.chat.viewmodel.sideeffect.ChatSideEffect -import tht.feature.chat.viewmodel.state.ChatState -import tht.feature.chat.viewmodel.state.skeletonChatList -import javax.inject.Inject - -@HiltViewModel -internal class ChatViewModel @Inject constructor( - private val getChatListUseCase: GetChatListUseCase -) : ViewModel(), Container { - override val store: Store = - store(initialState = ChatState.ChatList(isLoading = true, chatList = skeletonChatList)) - - fun getChatList() { - viewModelScope.launch { - val chatList = getChatListUseCase().getOrNull() ?: listOf() - intent { - reduce { - ChatState.ChatList( - isLoading = false, - chatList = chatList.map { it.toModel() }.toImmutableList() - ) - } - } - } - } -} diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/sideeffect/ChatDetailSideEffect.kt b/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/sideeffect/ChatDetailSideEffect.kt deleted file mode 100644 index 72a6e07c..00000000 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/detail/sideeffect/ChatDetailSideEffect.kt +++ /dev/null @@ -1,3 +0,0 @@ -package tht.feature.chat.viewmodel.detail.sideeffect - -sealed class ChatDetailSideEffect diff --git a/feature/chat/src/main/java/tht/feature/chat/viewmodel/sideeffect/ChatSideEffect.kt b/feature/chat/src/main/java/tht/feature/chat/viewmodel/sideeffect/ChatSideEffect.kt deleted file mode 100644 index 4ee1f43a..00000000 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/sideeffect/ChatSideEffect.kt +++ /dev/null @@ -1,3 +0,0 @@ -package tht.feature.chat.viewmodel.sideeffect - -sealed class ChatSideEffect 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 deleted file mode 100644 index d5a4b1b6..00000000 --- a/feature/chat/src/main/java/tht/feature/chat/viewmodel/state/ChatSkeleton.kt +++ /dev/null @@ -1,14 +0,0 @@ -package tht.feature.chat.viewmodel.state - -import kotlinx.collections.immutable.toImmutableList -import tht.feature.chat.model.ChatListUiModel - -internal val skeletonChatList = (1..20).map { - ChatListUiModel( - chatRoomIdx = it.toLong(), - partnerName = it.toString(), - partnerProfileUrl = "", - currentMessage = "", - messageTime = "" - ) -}.toImmutableList() diff --git a/feature/chat/src/main/res/layout/fragment_chat.xml b/feature/chat/src/main/res/layout/fragment_chat.xml index c196542b..8031963f 100644 --- a/feature/chat/src/main/res/layout/fragment_chat.xml +++ b/feature/chat/src/main/res/layout/fragment_chat.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".ChatFragment"> + tools:context=".chat.fragment.ChatFragment">