diff --git a/buildSrc/src/main/java/dependencies/Dep.kt b/buildSrc/src/main/java/dependencies/Dep.kt index 2b9a7cb42..932229db9 100644 --- a/buildSrc/src/main/java/dependencies/Dep.kt +++ b/buildSrc/src/main/java/dependencies/Dep.kt @@ -4,7 +4,8 @@ object Dep { object AndroidX { const val appCompat = "androidx.appcompat:appcompat:1.6.1" const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.4" - const val constraintLayoutCompose = "androidx.constraintlayout:constraintlayout-compose:1.0.1" + const val constraintLayoutCompose = + "androidx.constraintlayout:constraintlayout-compose:1.0.1" object Activity { const val ktx = "androidx.activity:activity-ktx:1.2.3" @@ -21,6 +22,7 @@ object Dep { const val viewModel = "androidx.lifecycle:lifecycle-viewmodel-ktx:$version" const val savedState = "androidx.lifecycle:lifecycle-viewmodel-savedstate:$version" const val runtime = "androidx.lifecycle:lifecycle-runtime-ktx:$version" + const val runtimeCompose = "androidx.lifecycle:lifecycle-runtime-compose:$version" const val process = "androidx.lifecycle:lifecycle-process:$version" const val livedata = "androidx.lifecycle:lifecycle-livedata-ktx:$version" const val compiler = "androidx.lifecycle:lifecycle-compiler:$version" @@ -43,6 +45,11 @@ object Dep { object Core { const val core = "androidx.core:core-ktx:1.7.0" } + + object Hilt { + const val hiltNavigation = "androidx.hilt:hilt-navigation-compose:1.0.0" + } + } object Google { @@ -123,7 +130,8 @@ object Dep { private const val version = "4.13.2" const val glide = "com.github.bumptech.glide:glide:$version" const val compiler = "com.github.bumptech.glide:compiler:$version" - const val recyclerviewIntegration = "com.github.bumptech.glide:recyclerview-integration:$version" + const val recyclerviewIntegration = + "com.github.bumptech.glide:recyclerview-integration:$version" const val okHttpIntegration = "com.github.bumptech.glide:okhttp3-integration:$version" } @@ -154,6 +162,12 @@ object Dep { const val uiTooling = "androidx.compose.ui:ui-tooling:$version" const val uiTestManifest = "androidx.compose.ui:ui-test-manifest:$version" } + + object Navigation { + private const val navigationVersion = "2.6.0" + const val navigationCompose = + "androidx.navigation:navigation-compose:$navigationVersion" + } } object Javax { diff --git a/presentation/build.gradle b/presentation/build.gradle index 6f53456cf..cff2d3f69 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -56,11 +56,12 @@ dependencies { // lifecycle implementation Dep.AndroidX.Lifecycle.viewModel implementation Dep.AndroidX.Lifecycle.savedState - implementation Dep.AndroidX.Lifecycle.compose + implementation Dep.AndroidX.Lifecycle.runtimeCompose kapt Dep.AndroidX.Lifecycle.compiler // ViewModel utilities for Compose - implementation Dep.AndroidX.Lifecycle.Compose.viewModel + implementation Dep.AndroidX.Lifecycle.Compose.viewModel // 추후 제거 필요 + implementation Dep.AndroidX.Hilt.hiltNavigation // glide implementation Dep.Glide.glide @@ -71,7 +72,6 @@ dependencies { // hilt implementation Dep.Dagger.Hilt.hilt - implementation Dep.Dagger.Hilt.Compose.navigation kapt Dep.Dagger.Hilt.compiler // navigation @@ -91,6 +91,7 @@ dependencies { implementation Dep.Compose.preview implementation Dep.Compose.material implementation Dep.AndroidX.Activity.compose + implementation Dep.Compose.Navigation.navigationCompose androidTestImplementation Dep.Compose.Test.ui debugImplementation Dep.Compose.Debug.uiTooling debugImplementation Dep.Compose.Debug.uiTestManifest diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index f745f8cfe..364c57f32 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -3,22 +3,24 @@ + android:name=".navigation.MainActivity" + android:exported="true" + android:windowSoftInputMode="adjustResize" > + + + + + - - - - + + KeyLinkNavHost( + appState = appState, + modifier = Modifier.padding(innerPadding), + onShowSnackbar = { message, action -> + snackbarHostState.showSnackbar( + message = message, + actionLabel = action, + duration = SnackbarDuration.Short + ) == SnackbarResult.ActionPerformed + } + ) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/KeyLinkAppState.kt b/presentation/src/main/java/com/mashup/presentation/KeyLinkAppState.kt new file mode 100644 index 000000000..8ea0d62e9 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/KeyLinkAppState.kt @@ -0,0 +1,77 @@ +package com.mashup.presentation + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Stable +import androidx.compose.runtime.remember +import androidx.navigation.NavDestination +import androidx.navigation.NavGraph.Companion.findStartDestination +import androidx.navigation.NavHostController +import androidx.navigation.compose.currentBackStackEntryAsState +import androidx.navigation.compose.rememberNavController +import androidx.navigation.navOptions +import com.mashup.presentation.feature.chat.navigation.navigateToChat +import com.mashup.presentation.feature.home.navigation.navigateToHome +import com.mashup.presentation.feature.signal.navigation.navigateToSignal +import com.mashup.presentation.navigation.KeyLinkNavigationRoute +import com.mashup.presentation.navigation.TopLevelDestination + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ + +@Composable +fun rememberKeyLinkAppState( + navController: NavHostController = rememberNavController() +): KeyLinkAppState { + return remember(navController) { + KeyLinkAppState(navController) + } +} + +/** + * KeyLinkAppState에는 전반적인 어플리케이션 자체의 상태가 포함됩니다. + * 1. Navigation Destination + * 2. Multiple BackStack + * 3. BottomNavigation Visibility + * 4. NetworkMonitor(isOffline / isOnline) + * 5. ... + */ +@Stable +class KeyLinkAppState( + val navController: NavHostController +) { + val currentDestination: NavDestination? + @Composable get() = navController.currentBackStackEntryAsState().value?.destination + + val topLevelDestinations: List = TopLevelDestination.values().toList() + + @Composable + fun isBottomBarVisible(): Boolean { + return when (currentDestination?.route) { + KeyLinkNavigationRoute.HomeGraph.HomeRoute.route, + KeyLinkNavigationRoute.ChatGraph.ChatRoute.route -> true + else -> false + } + } + + /** + * Home, Chat Route로 다시 돌아와야 하는 경우 호출하는 메서드 + * singleTop으로 동작 및 backstack 유지 + */ + fun navigateToTopLevelDestination(topLevelDestination: TopLevelDestination) { + val topLevelNavOptions = navOptions { + popUpTo(id = navController.graph.findStartDestination().id) { + saveState = true + } + launchSingleTop = true + restoreState = true + } + when (topLevelDestination) { + TopLevelDestination.HOME -> navController.navigateToHome(topLevelNavOptions) + TopLevelDestination.SIGNAL -> navController.navigateToSignal(topLevelNavOptions) + TopLevelDestination.CHAT -> navController.navigateToChat(topLevelNavOptions) + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/chat/ChatFragment.kt b/presentation/src/main/java/com/mashup/presentation/chat/ChatFragment.kt deleted file mode 100644 index 02f53ea7f..000000000 --- a/presentation/src/main/java/com/mashup/presentation/chat/ChatFragment.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.mashup.presentation.chat - -import com.mashup.presentation.R -import com.mashup.presentation.chat.compose.ChatScreen -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigate -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentChatBinding -import dagger.hilt.android.AndroidEntryPoint - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/27 - */ -@AndroidEntryPoint -class ChatFragment : BaseFragment(R.layout.fragment_chat) { - override fun initViews() { - binding.composeView.setThemeContent { - ChatScreen( - navigateToSendSignal = { navigate(R.id.action_chat_to_send_signal) }, - navigateToChatDetail = { navigate(R.id.action_chat_to_chatDetail) } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/ChatDetailFragment.kt b/presentation/src/main/java/com/mashup/presentation/detail/chat/ChatDetailFragment.kt deleted file mode 100644 index 3057b4b8a..000000000 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/ChatDetailFragment.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.mashup.presentation.detail.chat - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigate -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentChatDetailBinding -import com.mashup.presentation.detail.chat.compose.ChatDetailScreen - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/28 - */ -class ChatDetailFragment : BaseFragment(R.layout.fragment_chat_detail) { - override fun initViews() { - binding.composeView.setThemeContent { - ChatDetailScreen( - onUpButtonClick = { navigateUp() }, - onNavigateToMessageDetail = { navigate(R.id.action_chatDetail_to_messageDetail) } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/detail/message/MessageDetailFragment.kt b/presentation/src/main/java/com/mashup/presentation/detail/message/MessageDetailFragment.kt deleted file mode 100644 index d4503b903..000000000 --- a/presentation/src/main/java/com/mashup/presentation/detail/message/MessageDetailFragment.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.mashup.presentation.detail.message - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentMessageDetailBinding -import com.mashup.presentation.detail.message.compose.MessageDetailScreen - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/07/03 - */ -class MessageDetailFragment : - BaseFragment(R.layout.fragment_message_detail) { - - override fun initViews() { - binding.composeView.setThemeContent { - MessageDetailScreen( - onUpButtonClick = { navigateUp() }, - onMenuClick = { /* 신고하기 */ }, - onSendReplyClick = { /* 답장하기 */ } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/feature/chat/ChatViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/chat/ChatViewModel.kt new file mode 100644 index 000000000..17aa571bf --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/chat/ChatViewModel.kt @@ -0,0 +1,14 @@ +package com.mashup.presentation.feature.chat + +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/09 + */ +@HiltViewModel +class ChatViewModel @Inject constructor() : ViewModel() { +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/chat/compose/ChatListScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/chat/compose/ChatListScreen.kt similarity index 98% rename from presentation/src/main/java/com/mashup/presentation/chat/compose/ChatListScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/chat/compose/ChatListScreen.kt index 017c61b70..d57f97272 100644 --- a/presentation/src/main/java/com/mashup/presentation/chat/compose/ChatListScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/chat/compose/ChatListScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.chat.compose +package com.mashup.presentation.feature.chat.compose import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -21,7 +21,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.mashup.presentation.R -import com.mashup.presentation.chat.model.Message +import com.mashup.presentation.feature.chat.model.Message import com.mashup.presentation.ui.theme.* /** diff --git a/presentation/src/main/java/com/mashup/presentation/chat/compose/ChatScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/chat/compose/ChatScreen.kt similarity index 67% rename from presentation/src/main/java/com/mashup/presentation/chat/compose/ChatScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/chat/compose/ChatScreen.kt index 4c8be9f29..92a8d18be 100644 --- a/presentation/src/main/java/com/mashup/presentation/chat/compose/ChatScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/chat/compose/ChatScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.chat.compose +package com.mashup.presentation.feature.chat.compose import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column @@ -13,7 +13,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R +import com.mashup.presentation.feature.chat.ChatViewModel import com.mashup.presentation.ui.theme.* /** @@ -21,13 +23,28 @@ import com.mashup.presentation.ui.theme.* * @author jaesung * @created 2023/06/27 */ +@Composable +fun ChatRoute( + onEmptyScreenButtonClick: () -> Unit, + onChatClick: () -> Unit, + modifier: Modifier = Modifier, + viewModel: ChatViewModel = hiltViewModel() +) { + ChatScreen( + modifier = modifier, + onEmptyScreenButtonClick = onEmptyScreenButtonClick, + onChatClick = onChatClick + ) +} + @Composable fun ChatScreen( - navigateToSendSignal: () -> Unit = {}, - navigateToChatDetail: () -> Unit = {} + onEmptyScreenButtonClick: () -> Unit, + onChatClick: () -> Unit, + modifier: Modifier = Modifier ) { Scaffold( - modifier = Modifier, + modifier = modifier, backgroundColor = Black, topBar = { Column { @@ -51,8 +68,8 @@ fun ChatScreen( ) { paddingValues -> ChatContent( isConnected = true, - navigateToSendSignal = { navigateToSendSignal() }, - navigateToChatDetail = { navigateToChatDetail() }, + onEmptyScreenButtonClick = onEmptyScreenButtonClick, + onChatClick = onChatClick, modifier = Modifier.padding(paddingValues) ) } @@ -61,18 +78,18 @@ fun ChatScreen( @Composable fun ChatContent( isConnected: Boolean, - navigateToSendSignal: () -> Unit, - navigateToChatDetail: () -> Unit, + onEmptyScreenButtonClick: () -> Unit, + onChatClick: () -> Unit, modifier: Modifier = Modifier ) { if (!isConnected) { EmptyChatScreen( - onButtonClick = { navigateToSendSignal() }, + onButtonClick = onEmptyScreenButtonClick, modifier = modifier.fillMaxSize(), ) } else { ChatListScreen( - onMessageClick = { navigateToChatDetail() }, + onMessageClick = onChatClick, modifier = modifier .fillMaxSize() .padding(top = 8.dp) @@ -84,7 +101,10 @@ fun ChatContent( @Composable private fun ChatScreenPreview() { SsamDTheme(darkTheme = true) { - ChatScreen() + ChatScreen( + onEmptyScreenButtonClick = {}, + onChatClick = {} + ) } } diff --git a/presentation/src/main/java/com/mashup/presentation/chat/compose/EmptyChatScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/chat/compose/EmptyChatScreen.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/chat/compose/EmptyChatScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/chat/compose/EmptyChatScreen.kt index bf9a04787..15a4dfc76 100644 --- a/presentation/src/main/java/com/mashup/presentation/chat/compose/EmptyChatScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/chat/compose/EmptyChatScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.chat.compose +package com.mashup.presentation.feature.chat.compose import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement diff --git a/presentation/src/main/java/com/mashup/presentation/chat/model/ChatUiState.kt b/presentation/src/main/java/com/mashup/presentation/feature/chat/model/ChatUiState.kt similarity index 84% rename from presentation/src/main/java/com/mashup/presentation/chat/model/ChatUiState.kt rename to presentation/src/main/java/com/mashup/presentation/feature/chat/model/ChatUiState.kt index d60783c56..80135a9ec 100644 --- a/presentation/src/main/java/com/mashup/presentation/chat/model/ChatUiState.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/chat/model/ChatUiState.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.chat.model +package com.mashup.presentation.feature.chat.model import androidx.compose.runtime.Stable diff --git a/presentation/src/main/java/com/mashup/presentation/feature/chat/navigation/ChatNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/chat/navigation/ChatNavigation.kt new file mode 100644 index 000000000..82c849dea --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/chat/navigation/ChatNavigation.kt @@ -0,0 +1,67 @@ +package com.mashup.presentation.feature.chat.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import androidx.navigation.navigation +import com.mashup.presentation.feature.chat.compose.ChatRoute +import com.mashup.presentation.feature.detail.chat.compose.ChatDetailRoute +import com.mashup.presentation.feature.detail.message.compose.MessageDetailRoute +import com.mashup.presentation.feature.report.ReportRoute +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +fun NavController.navigateToChat(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.ChatGraph.route, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.chatGraph( + nestedGraphs: NavGraphBuilder.() -> Unit = {}, + onBackClick: () -> Unit, + onChatClick: () -> Unit, + onMessageClick: () -> Unit, + onReportIconClick: () -> Unit, + onReplyButtonClick: () -> Unit +) { + navigation( + route = KeyLinkNavigationRoute.ChatGraph.route, + startDestination = KeyLinkNavigationRoute.ChatGraph.ChatRoute.route + ) { + composable(route = KeyLinkNavigationRoute.ChatGraph.ChatRoute.route) { + ChatRoute( + onEmptyScreenButtonClick = {}, + onChatClick = onChatClick + ) + } + + composable(route = KeyLinkNavigationRoute.ChatGraph.ChatDetailRoute.route) { + ChatDetailRoute( + onBackClick = onBackClick, + onMessageClick = onMessageClick + ) + } + + composable(route = KeyLinkNavigationRoute.ChatGraph.MessageDetailRoute.route) { + MessageDetailRoute( + onBackClick = onBackClick, + onReportIconClick = onReportIconClick, + onReplyButtonClick = onReplyButtonClick + ) + } + + composable(route = KeyLinkNavigationRoute.ChatGraph.ReportRoute.route) { + ReportRoute( + onBackClick = onBackClick + ) + } + nestedGraphs() // 채팅 없을 경우 SignalGraph 연결 + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/Chat.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/Chat.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/compose/Chat.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/Chat.kt index e47e8591c..d43117a9a 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/Chat.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/Chat.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.chat.compose +package com.mashup.presentation.feature.detail.chat.compose import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background @@ -21,8 +21,8 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import com.mashup.presentation.detail.chat.model.MessageBackgroundColor -import com.mashup.presentation.detail.chat.model.MessageUiModel +import com.mashup.presentation.feature.detail.chat.model.MessageBackgroundColor +import com.mashup.presentation.feature.detail.chat.model.MessageUiModel import com.mashup.presentation.ui.theme.* /** diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/ChatDetailScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/ChatDetailScreen.kt similarity index 78% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/compose/ChatDetailScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/ChatDetailScreen.kt index 6caf80c6d..654126114 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/ChatDetailScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/ChatDetailScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.chat.compose +package com.mashup.presentation.feature.detail.chat.compose import androidx.compose.foundation.layout.* import androidx.compose.material.Icon @@ -10,8 +10,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R -import com.mashup.presentation.detail.chat.model.ChatDetailUiModel +import com.mashup.presentation.feature.chat.ChatViewModel +import com.mashup.presentation.feature.detail.chat.model.ChatDetailUiModel import com.mashup.presentation.ui.common.KeyLinkToolbar import com.mashup.presentation.ui.theme.Black import com.mashup.presentation.ui.theme.SsamDTheme @@ -23,21 +25,32 @@ import com.mashup.presentation.ui.theme.White * @created 2023/06/28 */ @Composable -fun ChatDetailScreen( +fun ChatDetailRoute( + onBackClick: () -> Unit, + onMessageClick: () -> Unit, modifier: Modifier = Modifier, - onUpButtonClick: () -> Unit = {}, - onNavigateToMessageDetail: () -> Unit = {} + viewModel: ChatViewModel = hiltViewModel() +) { + + ChatDetailScreen( + modifier = modifier, + onBackClick = onBackClick, + onMessageClick = onMessageClick, + ) +} + +@Composable +fun ChatDetailScreen( + onBackClick: () -> Unit, + onMessageClick: () -> Unit, + modifier: Modifier = Modifier ) { - /** - * val viewModel: ~ by hiltViewModel() - * collectAsState~ - */ Scaffold( modifier = modifier, backgroundColor = Black, topBar = { KeyLinkToolbar( - onClickBack = { onUpButtonClick() }, + onClickBack = onBackClick, menuAction = { IconButton(onClick = { /* */ }) { Icon( @@ -53,7 +66,7 @@ fun ChatDetailScreen( ChatDetailContent( modifier = Modifier.padding(paddingValues), chatDetailState = ProvideChatDetailState, - onChatItemClick = { onNavigateToMessageDetail() } + onChatItemClick = onMessageClick ) } } @@ -95,7 +108,7 @@ fun ChatDetailContent( @Composable private fun ChatDetailScreenPreview() { SsamDTheme { - ChatDetailScreen() + ChatDetailScreen(onBackClick = {}, onMessageClick = {}) } } diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/ChatDetailUiState.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/ChatDetailUiState.kt similarity index 92% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/compose/ChatDetailUiState.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/ChatDetailUiState.kt index c0200396f..5620f497a 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/ChatDetailUiState.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/ChatDetailUiState.kt @@ -1,8 +1,8 @@ -package com.mashup.presentation.detail.chat.compose +package com.mashup.presentation.feature.detail.chat.compose -import com.mashup.presentation.detail.chat.model.ChatDetailUiModel -import com.mashup.presentation.detail.chat.model.MessageBackgroundColor -import com.mashup.presentation.detail.chat.model.MessageUiModel +import com.mashup.presentation.feature.detail.chat.model.ChatDetailUiModel +import com.mashup.presentation.feature.detail.chat.model.MessageBackgroundColor +import com.mashup.presentation.feature.detail.chat.model.MessageUiModel /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/MatchedKeywords.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/MatchedKeywords.kt similarity index 95% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/compose/MatchedKeywords.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/MatchedKeywords.kt index f182da3aa..a61147b94 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/MatchedKeywords.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/MatchedKeywords.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.chat.compose +package com.mashup.presentation.feature.detail.chat.compose import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.padding diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/OtherUserInfo.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/OtherUserInfo.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/compose/OtherUserInfo.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/OtherUserInfo.kt index 1a76763e7..9aa21a176 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/compose/OtherUserInfo.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/compose/OtherUserInfo.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.chat.compose +package com.mashup.presentation.feature.detail.chat.compose import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/model/ChatDetailUiModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/model/ChatDetailUiModel.kt similarity index 80% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/model/ChatDetailUiModel.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/model/ChatDetailUiModel.kt index 006c5f384..6830c6187 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/model/ChatDetailUiModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/model/ChatDetailUiModel.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.chat.model +package com.mashup.presentation.feature.detail.chat.model /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/detail/chat/model/MessageUiModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/model/MessageUiModel.kt similarity index 92% rename from presentation/src/main/java/com/mashup/presentation/detail/chat/model/MessageUiModel.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/chat/model/MessageUiModel.kt index 4461579de..4a16e38f9 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/chat/model/MessageUiModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/model/MessageUiModel.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.chat.model +package com.mashup.presentation.feature.detail.chat.model import androidx.compose.ui.graphics.Color import com.mashup.presentation.ui.theme.* diff --git a/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/navigation/ChatDetailNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/navigation/ChatDetailNavigation.kt new file mode 100644 index 000000000..5ecc0c37b --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/chat/navigation/ChatDetailNavigation.kt @@ -0,0 +1,18 @@ +package com.mashup.presentation.feature.detail.chat.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavOptions +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/09 + */ + +fun NavController.navigateToChatDetail(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.ChatGraph.ChatDetailRoute.route, + navOptions = navOptions + ) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MatchedKeywordContainer.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MatchedKeywordContainer.kt similarity index 97% rename from presentation/src/main/java/com/mashup/presentation/detail/message/compose/MatchedKeywordContainer.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MatchedKeywordContainer.kt index 747230367..6b54ccc01 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MatchedKeywordContainer.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MatchedKeywordContainer.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.message.compose +package com.mashup.presentation.feature.detail.message.compose import androidx.compose.foundation.layout.* import androidx.compose.material.Icon diff --git a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageDetailContainer.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageDetailContainer.kt similarity index 95% rename from presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageDetailContainer.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageDetailContainer.kt index 75cee01ce..fc5d2a444 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageDetailContainer.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageDetailContainer.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.message.compose +package com.mashup.presentation.feature.detail.message.compose import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding diff --git a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageDetailScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageDetailScreen.kt similarity index 71% rename from presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageDetailScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageDetailScreen.kt index ee6812754..1735c5950 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageDetailScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageDetailScreen.kt @@ -1,15 +1,12 @@ -package com.mashup.presentation.detail.message.compose +package com.mashup.presentation.feature.detail.message.compose import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material.Icon import androidx.compose.material.Scaffold -import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -17,22 +14,43 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R +import com.mashup.presentation.feature.chat.ChatViewModel import com.mashup.presentation.ui.common.KeyLinkRoundButton import com.mashup.presentation.ui.common.KeyLinkToolbar -import com.mashup.presentation.ui.theme.* +import com.mashup.presentation.ui.theme.Black +import com.mashup.presentation.ui.theme.SsamDTheme +import com.mashup.presentation.ui.theme.White /** * Ssam_D_Android * @author jaesung * @created 2023/07/03 */ +@Composable +fun MessageDetailRoute( + onBackClick: () -> Unit, + onReportIconClick: () -> Unit, + onReplyButtonClick: () -> Unit, + modifier: Modifier = Modifier, + viewModel: ChatViewModel = hiltViewModel() +) { + + MessageDetailScreen( + modifier = modifier, + onBackClick = onBackClick, + onReportIconClick = onReportIconClick, + onReplyButtonClick = onReplyButtonClick, + ) +} + @Composable fun MessageDetailScreen( + onBackClick: () -> Unit, + onReportIconClick: () -> Unit, + onReplyButtonClick: () -> Unit, modifier: Modifier = Modifier, - onUpButtonClick: () -> Unit = {}, - onMenuClick: () -> Unit = {}, - onSendReplyClick: () -> Unit = {} ) { val matchedKeywords = listOf("매쉬업", "일상", "디자인", "IT", "취준", "일상", "디자인", "IT", "취준") @@ -41,15 +59,13 @@ fun MessageDetailScreen( backgroundColor = Black, topBar = { KeyLinkToolbar( - onClickBack = { - onUpButtonClick() - }, + onClickBack = onBackClick, menuAction = { Icon( modifier = Modifier .padding(end = 20.dp) .clickable { - onMenuClick() + onReportIconClick() }, painter = painterResource(id = R.drawable.ic_declare_24), tint = White, @@ -85,9 +101,7 @@ fun MessageDetailScreen( KeyLinkRoundButton( modifier = Modifier.padding(top = 48.dp, bottom = 42.dp), text = stringResource(R.string.button_send_reply), - onClick = { - onSendReplyClick() - } + onClick = onReplyButtonClick ) } } @@ -97,6 +111,10 @@ fun MessageDetailScreen( @Composable private fun MessageScreenPreview() { SsamDTheme { - MessageDetailScreen() + MessageDetailScreen( + onBackClick = {}, + onReportIconClick = {}, + onReplyButtonClick = {}, + ) } } \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageInfo.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageInfo.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageInfo.kt rename to presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageInfo.kt index 30384c8e1..8efcec0d0 100644 --- a/presentation/src/main/java/com/mashup/presentation/detail/message/compose/MessageInfo.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/compose/MessageInfo.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.detail.message.compose +package com.mashup.presentation.feature.detail.message.compose import androidx.compose.foundation.background import androidx.compose.foundation.layout.* diff --git a/presentation/src/main/java/com/mashup/presentation/feature/detail/message/navigation/MessageDetailNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/navigation/MessageDetailNavigation.kt new file mode 100644 index 000000000..4eeaae17c --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/detail/message/navigation/MessageDetailNavigation.kt @@ -0,0 +1,17 @@ +package com.mashup.presentation.feature.detail.message.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavOptions +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/09 + */ +fun NavController.navigateToMessageDetail(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.ChatGraph.MessageDetailRoute.route, + navOptions = navOptions + ) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/guide/GuideScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/guide/GuideScreen.kt similarity index 88% rename from presentation/src/main/java/com/mashup/presentation/home/guide/GuideScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/guide/GuideScreen.kt index f32a227cc..bb7bcdf07 100644 --- a/presentation/src/main/java/com/mashup/presentation/home/guide/GuideScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/guide/GuideScreen.kt @@ -1,11 +1,8 @@ -package com.mashup.presentation.home.guide +package com.mashup.presentation.feature.guide -import androidx.compose.foundation.Image -import androidx.compose.foundation.background +import androidx.compose.foundation.* import androidx.compose.foundation.layout.* -import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.verticalScroll import androidx.compose.material.Scaffold import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -23,15 +20,30 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.mashup.presentation.R -import com.mashup.presentation.home.guide.model.Alien +import com.mashup.presentation.feature.guide.model.Alien import com.mashup.presentation.ui.common.KeyLinkButton import com.mashup.presentation.ui.common.KeyLinkToolbar import com.mashup.presentation.ui.theme.* +import timber.log.Timber @Composable -fun PlanetGuideScreen( +fun GuideRoute( + onBackClick: () -> Unit, + onButtonClick: () -> Unit, + modifier: Modifier = Modifier, +) { + GuideScreen( + modifier = modifier, + onBackClick = onBackClick, + onButtonClick = onButtonClick + ) +} + +@Composable +fun GuideScreen( + onBackClick: () -> Unit, + onButtonClick: () -> Unit, modifier: Modifier = Modifier, - onBackPressed: () -> Unit = {} ) { Scaffold { Image( @@ -47,7 +59,7 @@ fun PlanetGuideScreen( ) { KeyLinkToolbar( backgroundColor = Color.Transparent, - onClickBack = { onBackPressed() } + onClickBack = onBackClick ) Column( modifier = modifier @@ -59,7 +71,9 @@ fun PlanetGuideScreen( Spacer(modifier = Modifier.height(72.dp)) Aliens() Spacer(modifier = Modifier.height(48.dp)) - PlanetGuideFooter() + PlanetGuideFooter( + onButtonClick = onButtonClick + ) } } @@ -173,7 +187,9 @@ fun AlienCard(alien: Alien) { } @Composable -fun PlanetGuideFooter() { +fun PlanetGuideFooter( + onButtonClick: () -> Unit, +) { Column( modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, @@ -193,6 +209,7 @@ fun PlanetGuideFooter() { }) KeyLinkButton( modifier = Modifier.fillMaxWidth(), + onClick = onButtonClick, text = stringResource(id = R.string.button_send_signal) ) } @@ -200,6 +217,6 @@ fun PlanetGuideFooter() { @Preview @Composable -fun PreviewGuideScreen() { - PlanetGuideScreen() +fun GuideScreenPreview() { + GuideScreen(onBackClick = {}, onButtonClick = {}) } diff --git a/presentation/src/main/java/com/mashup/presentation/home/guide/model/Alien.kt b/presentation/src/main/java/com/mashup/presentation/feature/guide/model/Alien.kt similarity index 97% rename from presentation/src/main/java/com/mashup/presentation/home/guide/model/Alien.kt rename to presentation/src/main/java/com/mashup/presentation/feature/guide/model/Alien.kt index 64f3dbad1..b051d4cbd 100644 --- a/presentation/src/main/java/com/mashup/presentation/home/guide/model/Alien.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/guide/model/Alien.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.home.guide.model +package com.mashup.presentation.feature.guide.model import androidx.annotation.DrawableRes import com.mashup.presentation.R diff --git a/presentation/src/main/java/com/mashup/presentation/feature/guide/navigation/GuideNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/guide/navigation/GuideNavigation.kt new file mode 100644 index 000000000..26df8cddb --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/guide/navigation/GuideNavigation.kt @@ -0,0 +1,17 @@ +package com.mashup.presentation.feature.guide.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavOptions +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/10 + */ +fun NavController.navigateToGuideRoute(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.HomeGraph.GuideRoute.route, + navOptions = navOptions + ) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/HomeScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/home/HomeScreen.kt similarity index 90% rename from presentation/src/main/java/com/mashup/presentation/home/HomeScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/home/HomeScreen.kt index 0a715359e..d02fa50f6 100644 --- a/presentation/src/main/java/com/mashup/presentation/home/HomeScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/home/HomeScreen.kt @@ -1,42 +1,54 @@ -package com.mashup.presentation.home +package com.mashup.presentation.feature.home -import androidx.compose.animation.* -import androidx.compose.foundation.* +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.expandVertically +import androidx.compose.animation.shrinkVertically +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.LazyRow -import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Text import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.* -import androidx.compose.ui.geometry.CornerRadius -import androidx.compose.ui.geometry.RoundRect -import androidx.compose.ui.graphics.* -import androidx.compose.ui.graphics.drawscope.drawIntoCanvas +import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R import com.mashup.presentation.common.extension.drawColoredShadow import com.mashup.presentation.common.extension.pxToDp -import com.mashup.presentation.home.model.SignalUiModel +import com.mashup.presentation.feature.home.model.SignalUiModel import com.mashup.presentation.ui.common.KeyLinkRoundButton import com.mashup.presentation.ui.theme.* -import java.util.concurrent.TimeUnit + +@Composable +fun HomeRoute( + onSubscribeKeywordClick: () -> Unit, + onGuideClick: () -> Unit, + modifier: Modifier = Modifier, + homeViewModel: HomeViewModel = hiltViewModel() +) { + HomeScreen( + navigateToSubscribeKeyword = onSubscribeKeywordClick, + navigateToGuide = onGuideClick, + modifier = modifier, + ) +} @Composable fun HomeScreen( - navigateToSubscribeKeyword: () -> Unit = {}, - navigateToGuide: () -> Unit = {} + navigateToSubscribeKeyword: () -> Unit, + navigateToGuide: () -> Unit, + modifier: Modifier = Modifier ) { val signals = emptyList() val scrollState = rememberLazyListState() @@ -324,5 +336,8 @@ private fun SignalCardKeywordsChip(keyword: String) { @Preview @Composable fun PreviewHomeScreen() { - HomeScreen() + HomeScreen( + navigateToSubscribeKeyword = {}, + navigateToGuide = {} + ) } \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/feature/home/HomeViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/home/HomeViewModel.kt new file mode 100644 index 000000000..430b99382 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/home/HomeViewModel.kt @@ -0,0 +1,14 @@ +package com.mashup.presentation.feature.home + +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/07 + */ +@HiltViewModel +class HomeViewModel @Inject constructor() : ViewModel() { +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/model/SignalUiModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/home/model/SignalUiModel.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/home/model/SignalUiModel.kt rename to presentation/src/main/java/com/mashup/presentation/feature/home/model/SignalUiModel.kt index fdbd1c6e9..24d7666d4 100644 --- a/presentation/src/main/java/com/mashup/presentation/home/model/SignalUiModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/home/model/SignalUiModel.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.home.model +package com.mashup.presentation.feature.home.model import java.util.concurrent.TimeUnit diff --git a/presentation/src/main/java/com/mashup/presentation/feature/home/navigation/HomeNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/home/navigation/HomeNavigation.kt new file mode 100644 index 000000000..143ff1a0b --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/home/navigation/HomeNavigation.kt @@ -0,0 +1,62 @@ +package com.mashup.presentation.feature.home.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import androidx.navigation.compose.navigation +import com.mashup.presentation.feature.home.HomeRoute +import com.mashup.presentation.feature.guide.GuideRoute +import com.mashup.presentation.feature.signal.navigation.navigateToSignal +import com.mashup.presentation.feature.subscribe.SubscribeRoute +import com.mashup.presentation.navigation.KeyLinkNavigationRoute +import timber.log.Timber + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +fun NavController.navigateToHome(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.HomeGraph.route, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.homeGraph( + navController: NavController, + onSubscribeKeywordClick: () -> Unit, + onGuideClick: () -> Unit, + onBackClick: () -> Unit, + nestedGraphs: NavGraphBuilder.() -> Unit, +) { + navigation( + route = KeyLinkNavigationRoute.HomeGraph.route, + startDestination = KeyLinkNavigationRoute.HomeGraph.HomeRoute.route, + ) { + composable(route = KeyLinkNavigationRoute.HomeGraph.HomeRoute.route) { + HomeRoute( + onSubscribeKeywordClick = onSubscribeKeywordClick, + onGuideClick = onGuideClick, + ) + } + composable(route = KeyLinkNavigationRoute.HomeGraph.GuideRoute.route) { + GuideRoute( + onBackClick = onBackClick, + onButtonClick = navController::navigateToSignal + ) + } + composable(route = KeyLinkNavigationRoute.HomeGraph.SubscribeKeywordRoute.route) { + SubscribeRoute( + onBackClick = onBackClick, + onSaveButtonClick = onBackClick + ) + } + composable(route = KeyLinkNavigationRoute.HomeGraph.ProfileRoute.route) { + // ProfileRoute + } + nestedGraphs() + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/login/LoginActivity.kt b/presentation/src/main/java/com/mashup/presentation/feature/login/LoginActivity.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/login/LoginActivity.kt rename to presentation/src/main/java/com/mashup/presentation/feature/login/LoginActivity.kt index 5f9a5ad49..b6c65f06d 100644 --- a/presentation/src/main/java/com/mashup/presentation/login/LoginActivity.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/login/LoginActivity.kt @@ -1,16 +1,16 @@ -package com.mashup.presentation.login +package com.mashup.presentation.feature.login import android.content.Intent -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Toast import androidx.activity.viewModels -import com.mashup.presentation.common.extension.setThemeContent +import androidx.appcompat.app.AppCompatActivity import androidx.core.view.WindowCompat import com.kakao.sdk.common.model.ClientError import com.kakao.sdk.common.model.ClientErrorCause import com.kakao.sdk.user.UserApiClient -import com.mashup.presentation.onboarding.OnBoardingActivity +import com.mashup.presentation.common.extension.setThemeContent +import com.mashup.presentation.feature.onboarding.OnBoardingActivity import dagger.hilt.android.AndroidEntryPoint import timber.log.Timber diff --git a/presentation/src/main/java/com/mashup/presentation/login/LoginScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/login/LoginScreen.kt similarity index 99% rename from presentation/src/main/java/com/mashup/presentation/login/LoginScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/login/LoginScreen.kt index cd6303775..59309b0d1 100644 --- a/presentation/src/main/java/com/mashup/presentation/login/LoginScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/login/LoginScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.login +package com.mashup.presentation.feature.login import androidx.activity.compose.BackHandler import androidx.compose.foundation.ExperimentalFoundationApi diff --git a/presentation/src/main/java/com/mashup/presentation/login/LoginViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/login/LoginViewModel.kt similarity index 97% rename from presentation/src/main/java/com/mashup/presentation/login/LoginViewModel.kt rename to presentation/src/main/java/com/mashup/presentation/feature/login/LoginViewModel.kt index f36350854..c54eaff67 100644 --- a/presentation/src/main/java/com/mashup/presentation/login/LoginViewModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/login/LoginViewModel.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.login +package com.mashup.presentation.feature.login import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/OpenSourceFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/OpenSourceFragment.kt similarity index 87% rename from presentation/src/main/java/com/mashup/presentation/mypage/OpenSourceFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/OpenSourceFragment.kt index 43a7bee13..d82ac2607 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/OpenSourceFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/OpenSourceFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage +package com.mashup.presentation.feature.mypage import com.mashup.presentation.R import com.mashup.presentation.common.base.BaseFragment diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/PrivacyPolicyFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/PrivacyPolicyFragment.kt similarity index 95% rename from presentation/src/main/java/com/mashup/presentation/mypage/PrivacyPolicyFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/PrivacyPolicyFragment.kt index b265a65f1..cc9df04cf 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/PrivacyPolicyFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/PrivacyPolicyFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage +package com.mashup.presentation.feature.mypage import android.annotation.SuppressLint import android.webkit.WebViewClient diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/SendSignalListFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/SendSignalListFragment.kt similarity index 88% rename from presentation/src/main/java/com/mashup/presentation/mypage/SendSignalListFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/SendSignalListFragment.kt index cabd5c428..84391d819 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/SendSignalListFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/SendSignalListFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage +package com.mashup.presentation.feature.mypage import com.mashup.presentation.R import com.mashup.presentation.common.base.BaseFragment diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/TermsOfServiceFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/TermsOfServiceFragment.kt similarity index 95% rename from presentation/src/main/java/com/mashup/presentation/mypage/TermsOfServiceFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/TermsOfServiceFragment.kt index 95411b3ff..d5dde916b 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/TermsOfServiceFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/TermsOfServiceFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage +package com.mashup.presentation.feature.mypage import android.annotation.SuppressLint import android.webkit.WebViewClient diff --git a/presentation/src/main/java/com/mashup/presentation/feature/mypage/navigation/ProfileNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/navigation/ProfileNavigation.kt new file mode 100644 index 000000000..15e99f10b --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/navigation/ProfileNavigation.kt @@ -0,0 +1,17 @@ +package com.mashup.presentation.feature.mypage.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavOptions +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/10 + */ +fun NavController.navigateToProfileRoute(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.HomeGraph.ProfileRoute.route, + navOptions = navOptions + ) +} diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/Options.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/Options.kt similarity index 98% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/Options.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/Options.kt index 9877c1652..2d1f2dd45 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/Options.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/Options.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage.profile +package com.mashup.presentation.feature.mypage.profile import android.content.Context import android.content.pm.PackageManager diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileAdapter.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileAdapter.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileAdapter.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileAdapter.kt index 7ac3ffdfb..24cf0060d 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileAdapter.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileAdapter.kt @@ -1,9 +1,9 @@ -package com.mashup.presentation.mypage.profile +package com.mashup.presentation.feature.mypage.profile import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.mashup.presentation.R -import com.mashup.presentation.mypage.profile.holder.* +import com.mashup.presentation.feature.mypage.profile.holder.* /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileFragment.kt similarity index 96% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileFragment.kt index f520edec5..c29dc6f76 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage.profile +package com.mashup.presentation.feature.mypage.profile import androidx.fragment.app.viewModels import com.mashup.presentation.R diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileItemDecoration.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileItemDecoration.kt similarity index 94% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileItemDecoration.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileItemDecoration.kt index 649753f0d..edc08fa99 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileItemDecoration.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileItemDecoration.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage.profile +package com.mashup.presentation.feature.mypage.profile import android.graphics.Rect import android.view.View diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileViewModel.kt similarity index 86% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileViewModel.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileViewModel.kt index 0d0467ed2..38962898c 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileViewModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileViewModel.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage.profile +package com.mashup.presentation.feature.mypage.profile import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileViewType.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileViewType.kt similarity index 95% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileViewType.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileViewType.kt index af92948f9..ca87b0ec9 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/ProfileViewType.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/ProfileViewType.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage.profile +package com.mashup.presentation.feature.mypage.profile import android.graphics.drawable.Drawable import androidx.annotation.StyleRes diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/AppVersionViewHolder.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/AppVersionViewHolder.kt similarity index 87% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/AppVersionViewHolder.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/AppVersionViewHolder.kt index b5be1cb3a..cc870e6af 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/AppVersionViewHolder.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/AppVersionViewHolder.kt @@ -1,10 +1,10 @@ -package com.mashup.presentation.mypage.profile.holder +package com.mashup.presentation.feature.mypage.profile.holder import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.mashup.presentation.databinding.ItemProfileAppVersionContentBinding -import com.mashup.presentation.mypage.profile.ProfileViewType +import com.mashup.presentation.feature.mypage.profile.ProfileViewType /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/HeaderViewHolder.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/HeaderViewHolder.kt similarity index 87% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/HeaderViewHolder.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/HeaderViewHolder.kt index 78f7d7515..9de3b3411 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/HeaderViewHolder.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/HeaderViewHolder.kt @@ -1,10 +1,10 @@ -package com.mashup.presentation.mypage.profile.holder +package com.mashup.presentation.feature.mypage.profile.holder import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.mashup.presentation.databinding.ItemProfileHeaderBinding -import com.mashup.presentation.mypage.profile.ProfileViewType +import com.mashup.presentation.feature.mypage.profile.ProfileViewType /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/LogoutViewHolder.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/LogoutViewHolder.kt similarity index 94% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/LogoutViewHolder.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/LogoutViewHolder.kt index b08a84979..95f4e01a1 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/LogoutViewHolder.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/LogoutViewHolder.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.mypage.profile.holder +package com.mashup.presentation.feature.mypage.profile.holder import android.view.LayoutInflater import android.view.ViewGroup diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/NavigationContentViewHolder.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/NavigationContentViewHolder.kt similarity index 90% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/NavigationContentViewHolder.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/NavigationContentViewHolder.kt index 566992c65..7adc1c1e9 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/NavigationContentViewHolder.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/NavigationContentViewHolder.kt @@ -1,10 +1,10 @@ -package com.mashup.presentation.mypage.profile.holder +package com.mashup.presentation.feature.mypage.profile.holder import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.mashup.presentation.databinding.ItemProfileNavigationContentBinding -import com.mashup.presentation.mypage.profile.ProfileViewType +import com.mashup.presentation.feature.mypage.profile.ProfileViewType /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/NotificationViewHolder.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/NotificationViewHolder.kt similarity index 91% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/NotificationViewHolder.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/NotificationViewHolder.kt index 4f479bef3..15e86c669 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/NotificationViewHolder.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/NotificationViewHolder.kt @@ -1,10 +1,10 @@ -package com.mashup.presentation.mypage.profile.holder +package com.mashup.presentation.feature.mypage.profile.holder import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.mashup.presentation.databinding.ItemProfileNotificationBinding -import com.mashup.presentation.mypage.profile.ProfileViewType +import com.mashup.presentation.feature.mypage.profile.ProfileViewType /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/UserInfoViewHolder.kt b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/UserInfoViewHolder.kt similarity index 87% rename from presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/UserInfoViewHolder.kt rename to presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/UserInfoViewHolder.kt index fe31a7d3d..497c7bc72 100644 --- a/presentation/src/main/java/com/mashup/presentation/mypage/profile/holder/UserInfoViewHolder.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/mypage/profile/holder/UserInfoViewHolder.kt @@ -1,10 +1,10 @@ -package com.mashup.presentation.mypage.profile.holder +package com.mashup.presentation.feature.mypage.profile.holder import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.mashup.presentation.databinding.ItemProfileUserInfoBinding -import com.mashup.presentation.mypage.profile.ProfileViewType +import com.mashup.presentation.feature.mypage.profile.ProfileViewType /** * Ssam_D_Android diff --git a/presentation/src/main/java/com/mashup/presentation/onboarding/NotificationPermissionGuideFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt similarity index 94% rename from presentation/src/main/java/com/mashup/presentation/onboarding/NotificationPermissionGuideFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt index 942748e4f..0955ca544 100644 --- a/presentation/src/main/java/com/mashup/presentation/onboarding/NotificationPermissionGuideFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionGuideFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.onboarding +package com.mashup.presentation.feature.onboarding import android.Manifest import android.content.Intent @@ -12,10 +12,9 @@ import androidx.core.content.ContextCompat import com.mashup.presentation.R import com.mashup.presentation.common.base.BaseFragment import com.mashup.presentation.common.extension.makeSnackBar -import com.mashup.presentation.databinding.FragmentNotificationPermissionGuideBinding -import com.mashup.presentation.ui.common.KeyLinkMintText import com.mashup.presentation.common.extension.setThemeContent import com.mashup.presentation.databinding.FragmentNotificationPermissionGuideComposeBinding +import com.mashup.presentation.onboarding.NotificationPermissionScreen import dagger.hilt.android.AndroidEntryPoint /** diff --git a/presentation/src/main/java/com/mashup/presentation/onboarding/NotificationPermissionScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionScreen.kt similarity index 100% rename from presentation/src/main/java/com/mashup/presentation/onboarding/NotificationPermissionScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/onboarding/NotificationPermissionScreen.kt diff --git a/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingActivity.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingActivity.kt new file mode 100644 index 000000000..071e053dd --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingActivity.kt @@ -0,0 +1,9 @@ +package com.mashup.presentation.feature.onboarding + +import com.mashup.presentation.R +import com.mashup.presentation.common.base.BaseActivity +import com.mashup.presentation.databinding.ActivityOnboardingBinding +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class OnBoardingActivity : BaseActivity(R.layout.activity_onboarding) \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingFragment.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingFragment.kt similarity index 93% rename from presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingFragment.kt rename to presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingFragment.kt index 96db377d8..51201d428 100644 --- a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingFragment.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingFragment.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.onboarding +package com.mashup.presentation.feature.onboarding import com.mashup.presentation.R import com.mashup.presentation.common.base.BaseFragment diff --git a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingScreen.kt similarity index 99% rename from presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingScreen.kt index c09d5aaed..4d72ddced 100644 --- a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.onboarding +package com.mashup.presentation.feature.onboarding import androidx.compose.foundation.* import androidx.compose.foundation.layout.* diff --git a/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt new file mode 100644 index 000000000..97bb52483 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/onboarding/OnBoardingViewModel.kt @@ -0,0 +1,61 @@ +package com.mashup.presentation.feature.onboarding + + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.mashup.domain.usecase.SaveOnboardingKeywordsUseCase +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class OnBoardingViewModel @Inject constructor( + private val saveOnboardingKeywordsUseCase: SaveOnboardingKeywordsUseCase +) : ViewModel() { + val uiState: MutableStateFlow = MutableStateFlow(UiState.Editing(emptyList())) + + fun saveKeywords(keywords: List) { + viewModelScope.launch { + uiState.emit(UiState.Loading) + saveOnboardingKeywordsUseCase.execute(keywords) + .onSuccess { + uiState.emit(UiState.SaveSuccess) + } + .onFailure { + it.message?.let { + uiState.emit(UiState.SaveFailed(it)) + } + } + } + } + + fun addKeyword(keyword: String) { + if (uiState.value is UiState.Editing) { + val keywords = (uiState.value as UiState.Editing).keywords.toMutableList() + + keywords.add(keyword) + viewModelScope.launch { + uiState.emit(UiState.Editing(keywords.toList())) + } + } + } + + fun removeKeyword(index: Int) { + if (uiState.value is UiState.Editing) { + val keywords = (uiState.value as UiState.Editing).keywords.toMutableList() + + keywords.removeAt(index) + viewModelScope.launch { + uiState.emit(UiState.Editing(keywords.toList())) + } + } + } + + sealed class UiState { + object Loading : UiState() + object SaveSuccess : UiState() + data class SaveFailed(val message: String) : UiState() + data class Editing(val keywords: List) : UiState() + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/report/ReportScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/report/ReportScreen.kt similarity index 88% rename from presentation/src/main/java/com/mashup/presentation/report/ReportScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/report/ReportScreen.kt index 0310dfb36..bfceaf8af 100644 --- a/presentation/src/main/java/com/mashup/presentation/report/ReportScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/report/ReportScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.report +package com.mashup.presentation.feature.report import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* @@ -25,15 +25,29 @@ import com.mashup.presentation.ui.theme.* * @author jaesung * @created 2023/07/01 */ +@Composable +fun ReportRoute( + onBackClick: () -> Unit, + modifier: Modifier = Modifier, +) { + ReportScreen( + modifier = modifier, + onBackClick = onBackClick + ) +} + @Composable fun ReportScreen( + onBackClick: () -> Unit, modifier: Modifier = Modifier ) { Scaffold( modifier = modifier, backgroundColor = Black, topBar = { - KeyLinkToolbar() + KeyLinkToolbar( + onClickBack = onBackClick + ) } ) { paddingValues -> Column( @@ -112,6 +126,6 @@ fun ReportHeader( @Composable private fun ReportScreenPreview() { SsamDTheme { - ReportScreen() + ReportScreen(onBackClick = {}) } } diff --git a/presentation/src/main/java/com/mashup/presentation/feature/report/navigation/ReportNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/report/navigation/ReportNavigation.kt new file mode 100644 index 000000000..555515fd4 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/report/navigation/ReportNavigation.kt @@ -0,0 +1,17 @@ +package com.mashup.presentation.feature.report.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavOptions +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/10 + */ +fun NavController.navigateToReport(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.ChatGraph.ReportRoute.route, + navOptions = navOptions + ) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/feature/signal/SignalViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/signal/SignalViewModel.kt new file mode 100644 index 000000000..d18d4856e --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/signal/SignalViewModel.kt @@ -0,0 +1,14 @@ +package com.mashup.presentation.feature.signal + +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/09 + */ +@HiltViewModel +class SignalViewModel @Inject constructor() : ViewModel() { +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/signal/compose/ShimmerScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/ShimmerScreen.kt similarity index 98% rename from presentation/src/main/java/com/mashup/presentation/signal/compose/ShimmerScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/signal/compose/ShimmerScreen.kt index a48826347..96d809acc 100644 --- a/presentation/src/main/java/com/mashup/presentation/signal/compose/ShimmerScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/ShimmerScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.signal.compose +package com.mashup.presentation.feature.signal.compose import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape diff --git a/presentation/src/main/java/com/mashup/presentation/signal/compose/SignalCompleteScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalCompleteScreen.kt similarity index 88% rename from presentation/src/main/java/com/mashup/presentation/signal/compose/SignalCompleteScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalCompleteScreen.kt index 4c3d1c01e..83b411b05 100644 --- a/presentation/src/main/java/com/mashup/presentation/signal/compose/SignalCompleteScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalCompleteScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.signal.compose +package com.mashup.presentation.feature.signal.compose import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.* @@ -28,9 +28,19 @@ import com.mashup.presentation.ui.theme.SsamDTheme * @created 2023/06/24 */ @Composable +fun SignalCompleteRoute( + onCloseClick: () -> Unit, + modifier: Modifier = Modifier +) { + SignalCompleteScreen( + modifier = modifier, + onCloseClick = onCloseClick + ) +} +@Composable fun SignalCompleteScreen( + onCloseClick: () -> Unit, modifier: Modifier = Modifier, - finishActivity: () -> Unit = {}, ) { val lottieComposition by rememberLottieComposition( spec = LottieCompositionSpec.RawRes(R.raw.lottie_signal_success) @@ -41,7 +51,7 @@ fun SignalCompleteScreen( ) BackHandler(true) { - finishActivity() + onCloseClick() } Column(modifier = modifier.fillMaxSize()) { @@ -59,7 +69,7 @@ fun SignalCompleteScreen( backgroundColor = Gray02, contentColor = Gray06, enable = true, - onClick = { finishActivity() } + onClick = onCloseClick ) } } @@ -107,6 +117,8 @@ private fun SignalCompleteContent( @Composable fun SignalCompleteScreenPreview() { SsamDTheme { - SignalCompleteScreen() + SignalCompleteScreen( + onCloseClick = {} + ) } } \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/signal/compose/SignalContentScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalContentScreen.kt similarity index 83% rename from presentation/src/main/java/com/mashup/presentation/signal/compose/SignalContentScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalContentScreen.kt index abfc172b8..693fdb0f1 100644 --- a/presentation/src/main/java/com/mashup/presentation/signal/compose/SignalContentScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalContentScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.signal.compose +package com.mashup.presentation.feature.signal.compose import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -19,7 +19,9 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R +import com.mashup.presentation.feature.signal.SignalViewModel import com.mashup.presentation.ui.common.KeyLinkButton import com.mashup.presentation.ui.common.KeyLinkContentLengthDialog import com.mashup.presentation.ui.common.KeyLinkTextField @@ -33,10 +35,23 @@ import com.mashup.presentation.ui.theme.White * @created 2023/06/20 */ @Composable +fun SignalContentRoute( + onBackClick: () -> Unit, + onNextClick: () -> Unit, + modifier: Modifier = Modifier, + viewModel: SignalViewModel = hiltViewModel() +) { + SignalContentScreen( + modifier = modifier, + onBackClick = onBackClick, + onNextClick = onNextClick + ) +} +@Composable fun SignalContentScreen( modifier: Modifier = Modifier, - navigateToSignalKeyword: () -> Unit = {}, - navigateUp: () -> Unit = {} + onNextClick: () -> Unit = {}, + onBackClick: () -> Unit = {} ) { var dialogState by rememberSaveable { mutableStateOf(false) } @@ -52,11 +67,11 @@ fun SignalContentScreen( ) ) }, - onClickBack = navigateUp + onClickBack = onBackClick ) SignalContent( modifier = modifier, - onNavigate = navigateToSignalKeyword, + onNextClick = onNextClick, onLengthOver = { dialogState = true } ) @@ -72,7 +87,7 @@ fun SignalContentScreen( @Composable fun SignalContent( modifier: Modifier = Modifier, - onNavigate: () -> Unit, + onNextClick: () -> Unit, onLengthOver: () -> Unit, ) { var text by rememberSaveable { mutableStateOf("") } @@ -104,7 +119,7 @@ fun SignalContent( .padding(vertical = 12.dp, horizontal = 20.dp) .padding(bottom = 48.dp), text = stringResource(id = R.string.next), - onClick = { onNavigate() }, + onClick = onNextClick, enable = text.isNotEmpty() ) } diff --git a/presentation/src/main/java/com/mashup/presentation/signal/compose/SignalKeywordScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalKeywordScreen.kt similarity index 83% rename from presentation/src/main/java/com/mashup/presentation/signal/compose/SignalKeywordScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalKeywordScreen.kt index 5f766aafb..ec7504c22 100644 --- a/presentation/src/main/java/com/mashup/presentation/signal/compose/SignalKeywordScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/signal/compose/SignalKeywordScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.signal.compose +package com.mashup.presentation.feature.signal.compose import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.* @@ -13,7 +13,9 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R +import com.mashup.presentation.feature.signal.SignalViewModel import com.mashup.presentation.ui.common.* import com.mashup.presentation.ui.theme.Gray06 import com.mashup.presentation.ui.theme.SsamDTheme @@ -24,12 +26,29 @@ import com.mashup.presentation.ui.theme.White * @author jaesung * @created 2023/06/21 */ +@Composable +fun SignalKeywordRoute( + onBackClick: () -> Unit, + onSendClick: () -> Unit, + modifier: Modifier = Modifier, + viewModel: SignalViewModel = hiltViewModel() +) { + + SignalKeywordScreen( + modifier = modifier, + isLoading = false, + onDialogBackClick = onBackClick, + onSendClick = onSendClick + ) + +} + @Composable fun SignalKeywordScreen( isLoading: Boolean, + onDialogBackClick: () -> Unit, + onSendClick: () -> Unit, modifier: Modifier = Modifier, - navigateUp: () -> Unit = {}, - navigateToComplete: () -> Unit = {} ) { val keywords = remember { mutableStateListOf() } var showGoBackDialog by remember { mutableStateOf(false) } @@ -67,14 +86,14 @@ fun SignalKeywordScreen( .padding(bottom = 48.dp, start = 20.dp, end = 20.dp), text = stringResource(R.string.button_send_signal), enable = !(isLoading || keywords.isEmpty()), - onClick = { navigateToComplete() } + onClick = onSendClick ) } if (showGoBackDialog) { KeyLinkGoBackDialog( onDismissRequest = { }, - onGoBackClick = { navigateUp() }, + onGoBackClick = onDialogBackClick, onCloseClick = { showGoBackDialog = false } ) } @@ -160,7 +179,11 @@ fun SignalKeyword( @Composable fun SignalKeywordLoadingScreenPreview() { SsamDTheme { - SignalKeywordScreen(isLoading = true) + SignalKeywordScreen( + isLoading = true, + onDialogBackClick = {}, + onSendClick = {}, + ) } } @@ -168,6 +191,10 @@ fun SignalKeywordLoadingScreenPreview() { @Composable fun SignalKeywordScreenPreview() { SsamDTheme { - SignalKeywordScreen(isLoading = false) + SignalKeywordScreen( + isLoading = false, + onDialogBackClick = {}, + onSendClick = {}, + ) } } \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/feature/signal/navigation/SignalNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/signal/navigation/SignalNavigation.kt new file mode 100644 index 000000000..d91bfd405 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/signal/navigation/SignalNavigation.kt @@ -0,0 +1,74 @@ +package com.mashup.presentation.feature.signal.navigation + +import androidx.navigation.* +import androidx.navigation.compose.composable +import com.mashup.presentation.feature.home.navigation.navigateToHome +import com.mashup.presentation.feature.signal.compose.SignalCompleteRoute +import com.mashup.presentation.feature.signal.compose.SignalContentRoute +import com.mashup.presentation.feature.signal.compose.SignalKeywordRoute +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +fun NavController.navigateToSignal(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.SignalGraph.route, + navOptions = navOptions + ) +} + +fun NavController.navigateToSignalKeyword(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.SignalGraph.SignalKeywordRoute.route, + navOptions = navOptions + ) +} + +fun NavController.navigateToSignalComplete(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.SignalGraph.SignalCompleteRoute.route, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.signalGraph( + navController: NavController, + onBackClick: () -> Unit, +) { + navigation( + route = KeyLinkNavigationRoute.SignalGraph.route, + startDestination = KeyLinkNavigationRoute.SignalGraph.SignalContentRoute.route + ) { + composable(route = KeyLinkNavigationRoute.SignalGraph.SignalContentRoute.route) { + SignalContentRoute( + onBackClick = onBackClick, + onNextClick = navController::navigateToSignalKeyword + ) + } + + composable(route = KeyLinkNavigationRoute.SignalGraph.SignalKeywordRoute.route) { + SignalKeywordRoute( + onBackClick = onBackClick, + onSendClick = navController::navigateToSignalComplete + ) + } + + composable(route = KeyLinkNavigationRoute.SignalGraph.SignalCompleteRoute.route) { + SignalCompleteRoute( + onCloseClick = { + navController.navigateToHome( + navOptions { + popUpTo(KeyLinkNavigationRoute.SignalGraph.SignalContentRoute.route) { + inclusive = true + } + launchSingleTop = true + } + ) + } + ) + } + } +} diff --git a/presentation/src/main/java/com/mashup/presentation/home/SubscribeKeywordScreen.kt b/presentation/src/main/java/com/mashup/presentation/feature/subscribe/SubscribeKeywordScreen.kt similarity index 84% rename from presentation/src/main/java/com/mashup/presentation/home/SubscribeKeywordScreen.kt rename to presentation/src/main/java/com/mashup/presentation/feature/subscribe/SubscribeKeywordScreen.kt index 352921bd0..f17718c40 100644 --- a/presentation/src/main/java/com/mashup/presentation/home/SubscribeKeywordScreen.kt +++ b/presentation/src/main/java/com/mashup/presentation/feature/subscribe/SubscribeKeywordScreen.kt @@ -1,4 +1,4 @@ -package com.mashup.presentation.home +package com.mashup.presentation.feature.subscribe import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState @@ -10,6 +10,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.hilt.navigation.compose.hiltViewModel import com.mashup.presentation.R import com.mashup.presentation.ui.common.* import com.mashup.presentation.ui.theme.* @@ -20,16 +21,30 @@ import com.mashup.presentation.ui.theme.* * @created 2023/06/25 */ @Composable +fun SubscribeRoute( + onBackClick: () -> Unit, + onSaveButtonClick: () -> Unit, + modifier: Modifier = Modifier, + viewModel: SubscribeViewModel = hiltViewModel() +) { + + SubscribeKeywordScreen( + modifier = modifier, + onBackClick = onBackClick, + onSaveButtonClick = onSaveButtonClick + ) +} +@Composable fun SubscribeKeywordScreen( modifier: Modifier = Modifier, - navigateUp: () -> Unit = {}, - navigateToHome: () -> Unit = {} + onBackClick: () -> Unit = {}, + onSaveButtonClick: () -> Unit = {} ) { val keywords = remember { mutableStateListOf() } Column(modifier = Modifier.fillMaxSize()) { KeyLinkToolbar( - onClickBack = { navigateUp() } + onClickBack = onBackClick ) SubscribeKeywordContent( modifier = Modifier.weight(1f), @@ -47,7 +62,7 @@ fun SubscribeKeywordScreen( .fillMaxWidth() .padding(bottom = 12.dp, start = 20.dp, end = 20.dp), enable = !keywords.isEmpty(), - onClick = { navigateToHome() } + onClick = onSaveButtonClick ) } } diff --git a/presentation/src/main/java/com/mashup/presentation/feature/subscribe/SubscribeViewModel.kt b/presentation/src/main/java/com/mashup/presentation/feature/subscribe/SubscribeViewModel.kt new file mode 100644 index 000000000..feac1809c --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/subscribe/SubscribeViewModel.kt @@ -0,0 +1,14 @@ +package com.mashup.presentation.feature.subscribe + +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/09 + */ +@HiltViewModel +class SubscribeViewModel @Inject constructor() : ViewModel() { +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/feature/subscribe/navigation/SubscribeNavigation.kt b/presentation/src/main/java/com/mashup/presentation/feature/subscribe/navigation/SubscribeNavigation.kt new file mode 100644 index 000000000..30f563cbc --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/feature/subscribe/navigation/SubscribeNavigation.kt @@ -0,0 +1,17 @@ +package com.mashup.presentation.feature.subscribe.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavOptions +import com.mashup.presentation.navigation.KeyLinkNavigationRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/10 + */ +fun NavController.navigateToSubscribeKeywordRoute(navOptions: NavOptions? = null) { + navigate( + route = KeyLinkNavigationRoute.HomeGraph.SubscribeKeywordRoute.route, + navOptions = navOptions + ) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/ConnectedSignalFragment.kt b/presentation/src/main/java/com/mashup/presentation/home/ConnectedSignalFragment.kt deleted file mode 100644 index 3fb7ed3f1..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/ConnectedSignalFragment.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.mashup.presentation.home - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.databinding.FragmentConnectedSignalBinding - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/03 - */ -class ConnectedSignalFragment : - BaseFragment(R.layout.fragment_connected_signal) { -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/HomeActivity.kt b/presentation/src/main/java/com/mashup/presentation/home/HomeActivity.kt deleted file mode 100644 index e9753da09..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/HomeActivity.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.mashup.presentation.home - -import android.view.LayoutInflater -import android.view.View -import androidx.navigation.fragment.NavHostFragment -import androidx.navigation.ui.setupWithNavController -import com.google.android.material.bottomnavigation.BottomNavigationItemView -import com.google.android.material.bottomnavigation.BottomNavigationMenuView -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseActivity -import com.mashup.presentation.common.extension.addBadge -import com.mashup.presentation.common.extension.removeBadge -import com.mashup.presentation.databinding.ActivityHomeBinding -import dagger.hilt.android.AndroidEntryPoint - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/03 - */ -@AndroidEntryPoint -class HomeActivity : BaseActivity(R.layout.activity_home) { - private val navHostFragment by lazy { - supportFragmentManager.findFragmentById(binding.fcvHome.id) as NavHostFragment - } - private val navController by lazy { navHostFragment.navController } - - override fun initViews() { - initBottomNavigationView() - initDestinationChangeListener() - } - - private fun initBottomNavigationView() { - binding.bnvHome.setupWithNavController(navController) - addSignalIconItemView() - binding.bnvHome.addBadge(this, 1000) - } - - private fun initDestinationChangeListener() { - navController.addOnDestinationChangedListener { _, destination, _ -> - binding.bnvHome.visibility = when (destination.id) { - /* 디자인 명세에 따라 수정 */ - R.id.homeFragment -> View.VISIBLE - R.id.chatFragment -> { - binding.bnvHome.removeBadge() - View.VISIBLE - } - else -> View.GONE - } - } - } - - private fun addSignalIconItemView() { - val navigationMenuView = binding.bnvHome.getChildAt(0) as BottomNavigationMenuView - val navigationItemView = navigationMenuView.getChildAt(1) as BottomNavigationItemView - val signalItemView = LayoutInflater.from(this) - .inflate(R.layout.menu_bottom_navigation_signal, binding.bnvHome, false) - navigationItemView.addView(signalItemView) - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/HomeFragment.kt b/presentation/src/main/java/com/mashup/presentation/home/HomeFragment.kt deleted file mode 100644 index e3bd91353..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/HomeFragment.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mashup.presentation.home - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigate -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentHomeBinding - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/04 - */ -class HomeFragment : BaseFragment(R.layout.fragment_home) { - - override fun initViews() { - binding.composeView.setThemeContent { - HomeScreen( - navigateToSubscribeKeyword = { navigate(R.id.action_home_to_subscribeKeyword)}, - navigateToGuide = {navigate(R.id.action_homeFragment_to_guideFragment)} - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/NotificationListFragment.kt b/presentation/src/main/java/com/mashup/presentation/home/NotificationListFragment.kt deleted file mode 100644 index 76d1cf310..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/NotificationListFragment.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.mashup.presentation.home - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.databinding.FragmentNotificationListBinding - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/03 - */ -class NotificationListFragment : BaseFragment(R.layout.fragment_notification_list) { -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/ReceivedSignalFragment.kt b/presentation/src/main/java/com/mashup/presentation/home/ReceivedSignalFragment.kt deleted file mode 100644 index bb0575ee2..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/ReceivedSignalFragment.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.mashup.presentation.home - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.databinding.FragmentReceivedSignalBinding - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/03 - */ -class ReceivedSignalFragment : - BaseFragment(R.layout.fragment_received_signal) { -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/SubscribeKeywordFragment.kt b/presentation/src/main/java/com/mashup/presentation/home/SubscribeKeywordFragment.kt deleted file mode 100644 index fd3989f07..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/SubscribeKeywordFragment.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.mashup.presentation.home - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentSubscribeKeywordBinding - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/25 - */ -class SubscribeKeywordFragment : - BaseFragment(R.layout.fragment_subscribe_keyword) { - - override fun initViews() { - binding.composeView.setThemeContent { - SubscribeKeywordScreen( - navigateUp = { navigateUp() }, - navigateToHome = { navigateUp() } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/home/guide/GuideFragment.kt b/presentation/src/main/java/com/mashup/presentation/home/guide/GuideFragment.kt deleted file mode 100644 index 430ee7a92..000000000 --- a/presentation/src/main/java/com/mashup/presentation/home/guide/GuideFragment.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.mashup.presentation.home.guide - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentGuideBinding - -class GuideFragment : BaseFragment(R.layout.fragment_guide) { - override fun initViews() { - binding.composeView.setThemeContent { - PlanetGuideScreen( - onBackPressed = { navigateUp() } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/navigation/KeyLinkNavHost.kt b/presentation/src/main/java/com/mashup/presentation/navigation/KeyLinkNavHost.kt new file mode 100644 index 000000000..a377a1c9c --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/navigation/KeyLinkNavHost.kt @@ -0,0 +1,58 @@ +package com.mashup.presentation.navigation + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.navigation.compose.NavHost +import com.mashup.presentation.KeyLinkAppState +import com.mashup.presentation.feature.chat.navigation.chatGraph +import com.mashup.presentation.feature.detail.chat.navigation.navigateToChatDetail +import com.mashup.presentation.feature.detail.message.navigation.navigateToMessageDetail +import com.mashup.presentation.feature.guide.navigation.navigateToGuideRoute +import com.mashup.presentation.feature.home.navigation.homeGraph +import com.mashup.presentation.feature.report.navigation.navigateToReport +import com.mashup.presentation.feature.signal.navigation.signalGraph +import com.mashup.presentation.feature.subscribe.navigation.navigateToSubscribeKeywordRoute + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +@Composable +fun KeyLinkNavHost( + appState: KeyLinkAppState, + onShowSnackbar: suspend (String, String?) -> Boolean, + modifier: Modifier = Modifier, + startDestination: String = KeyLinkNavigationRoute.HomeGraph.route +) { + val navController = appState.navController + NavHost( + navController = navController, + startDestination = startDestination, + modifier = modifier + ) { + homeGraph( + navController = navController, + onSubscribeKeywordClick = navController::navigateToSubscribeKeywordRoute, + onGuideClick = navController::navigateToGuideRoute, + onBackClick = navController::navigateUp, + nestedGraphs = { + signalGraph( + navController = navController, + onBackClick = navController::navigateUp + ) + } + ) + signalGraph( + navController = navController, + onBackClick = navController::navigateUp, + ) + chatGraph( + onBackClick = navController::navigateUp, + onChatClick = navController::navigateToChatDetail, + onMessageClick = navController::navigateToMessageDetail, + onReportIconClick = navController::navigateToReport, + onReplyButtonClick = {}, + ) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/navigation/KeyLinkNavigationRoute.kt b/presentation/src/main/java/com/mashup/presentation/navigation/KeyLinkNavigationRoute.kt new file mode 100644 index 000000000..ab6e5f805 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/navigation/KeyLinkNavigationRoute.kt @@ -0,0 +1,27 @@ +package com.mashup.presentation.navigation + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +sealed class KeyLinkNavigationRoute(val route: String) { + object HomeGraph : KeyLinkNavigationRoute(homeGraphPattern) { + object HomeRoute : KeyLinkNavigationRoute(homeRoute) + object SubscribeKeywordRoute : KeyLinkNavigationRoute(subscribeKeywordRoute) + object GuideRoute : KeyLinkNavigationRoute(guideRoute) + object ProfileRoute : KeyLinkNavigationRoute(profileRoute) + } + object SignalGraph : KeyLinkNavigationRoute(signalGraphPattern) { + object SignalContentRoute : KeyLinkNavigationRoute(signalContentRoute) + object SignalKeywordRoute : KeyLinkNavigationRoute(signalKeywordRoute) + object SignalCompleteRoute : KeyLinkNavigationRoute(signalCompleteRoute) + } + + object ChatGraph : KeyLinkNavigationRoute(chatGraphPattern) { + object ChatRoute : KeyLinkNavigationRoute(chatRoute) + object ChatDetailRoute : KeyLinkNavigationRoute(chatDetailRoute) + object MessageDetailRoute : KeyLinkNavigationRoute(messageDetailRoute) + object ReportRoute : KeyLinkNavigationRoute(reportRoute) + } +} diff --git a/presentation/src/main/java/com/mashup/presentation/navigation/MainActivity.kt b/presentation/src/main/java/com/mashup/presentation/navigation/MainActivity.kt new file mode 100644 index 000000000..0e55a5909 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/navigation/MainActivity.kt @@ -0,0 +1,64 @@ +package com.mashup.presentation.navigation + +import android.os.Bundle +import androidx.activity.ComponentActivity +import com.mashup.presentation.KeyLinkApp +import com.mashup.presentation.common.extension.setThemeContent +import dagger.hilt.android.AndroidEntryPoint + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/06/03 + */ +@AndroidEntryPoint +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setThemeContent { + KeyLinkApp() + } + } +} + + +//class HomeActivity : BaseActivity(R.layout.activity_home) { +// private val navHostFragment by lazy { +// supportFragmentManager.findFragmentById(binding.fcvHome.id) as NavHostFragment +// } +// private val navController by lazy { navHostFragment.navController } +// +// override fun initViews() { +// initBottomNavigationView() +// initDestinationChangeListener() +// } +// +// private fun initBottomNavigationView() { +// binding.bnvHome.setupWithNavController(navController) +// addSignalIconItemView() +// binding.bnvHome.addBadge(this, 1000) +// } +// +// private fun initDestinationChangeListener() { +// navController.addOnDestinationChangedListener { _, destination, _ -> +// binding.bnvHome.visibility = when (destination.id) { +// /* 디자인 명세에 따라 수정 */ +// R.id.homeFragment -> View.VISIBLE +// R.id.chatFragment -> { +// binding.bnvHome.removeBadge() +// View.VISIBLE +// } +// else -> View.GONE +// } +// } +// } +// +// private fun addSignalIconItemView() { +// val navigationMenuView = binding.bnvHome.getChildAt(0) as BottomNavigationMenuView +// val navigationItemView = navigationMenuView.getChildAt(1) as BottomNavigationItemView +// val signalItemView = LayoutInflater.from(this) +// .inflate(R.layout.menu_bottom_navigation_signal, binding.bnvHome, false) +// navigationItemView.addView(signalItemView) +// } +//} diff --git a/presentation/src/main/java/com/mashup/presentation/navigation/RouteConst.kt b/presentation/src/main/java/com/mashup/presentation/navigation/RouteConst.kt new file mode 100644 index 000000000..c912a9e67 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/navigation/RouteConst.kt @@ -0,0 +1,24 @@ +package com.mashup.presentation.navigation + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ + +const val homeGraphPattern = "home_graph" +const val homeRoute = "home_graph/home" +const val guideRoute = "home_graph/guide" +const val profileRoute = "home_graph/profile" +const val subscribeKeywordRoute = "home_graph/subscribe_keyword" + +const val signalGraphPattern = "signal_graph" +const val signalContentRoute = "signal_graph/content" +const val signalKeywordRoute = "signal_graph/keyword" +const val signalCompleteRoute = "signal_graph/complete" + +const val chatGraphPattern = "chat_graph" +const val chatRoute = "chat_graph/chat" +const val chatDetailRoute = "chat_graph/chat_detail" +const val messageDetailRoute = "chat_graph/message_detail" +const val reportRoute = "chat_graph/report" diff --git a/presentation/src/main/java/com/mashup/presentation/navigation/TopLevelDestination.kt b/presentation/src/main/java/com/mashup/presentation/navigation/TopLevelDestination.kt new file mode 100644 index 000000000..c775e6532 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/navigation/TopLevelDestination.kt @@ -0,0 +1,34 @@ +package com.mashup.presentation.navigation + +import com.mashup.presentation.R + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +enum class TopLevelDestination( + val selectedIconId: Int, + val unselectedIconId: Int, + val iconTextId: Int, + val textLabelId: Int +) { + HOME( + selectedIconId = R.drawable.ic_home_fill_32, + unselectedIconId = R.drawable.ic_home_fill_32, + iconTextId = R.string.navigation_home, + textLabelId = R.string.navigation_home, + ), + SIGNAL( + selectedIconId = R.drawable.ic_signal_fill_32, + unselectedIconId = R.drawable.ic_signal_fill_32, + iconTextId = R.string.navigation_signal, + textLabelId = R.string.navigation_signal, + ), + CHAT( + selectedIconId = R.drawable.ic_chat_fill_32, + unselectedIconId = R.drawable.ic_chat_fill_32, + iconTextId = R.string.navigation_chat, + textLabelId = R.string.navigation_chat, + ), +} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingActivity.kt b/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingActivity.kt deleted file mode 100644 index ce434a7c9..000000000 --- a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingActivity.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.mashup.presentation.onboarding - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseActivity -import com.mashup.presentation.databinding.ActivitySignalBinding -import dagger.hilt.android.AndroidEntryPoint - -@AndroidEntryPoint -class OnBoardingActivity : BaseActivity(R.layout.activity_onboarding) \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingViewModel.kt b/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingViewModel.kt index 053674f6c..e69de29bb 100644 --- a/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingViewModel.kt +++ b/presentation/src/main/java/com/mashup/presentation/onboarding/OnBoardingViewModel.kt @@ -1,63 +0,0 @@ -package com.mashup.presentation.onboarding - - -import androidx.compose.runtime.mutableStateListOf -import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import com.mashup.domain.usecase.SaveOnboardingKeywordsUseCase -import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.launch -import javax.inject.Inject - -@HiltViewModel -class OnBoardingViewModel @Inject constructor( - private val saveOnboardingKeywordsUseCase: SaveOnboardingKeywordsUseCase -) : ViewModel() { - val uiState: MutableStateFlow = MutableStateFlow(UiState.Editing(emptyList())) - - fun saveKeywords(keywords: List) { - viewModelScope.launch { - uiState.emit(UiState.Loading) - saveOnboardingKeywordsUseCase.execute(keywords) - .onSuccess { - uiState.emit(UiState.SaveSuccess) - } - .onFailure { - it.message?.let { - uiState.emit(UiState.SaveFailed(it)) - } - } - } - } - - fun addKeyword(keyword: String) { - if (uiState.value is UiState.Editing) { - val keywords = (uiState.value as UiState.Editing).keywords.toMutableList() - - keywords.add(keyword) - viewModelScope.launch { - uiState.emit(UiState.Editing(keywords.toList())) - } - } - } - - fun removeKeyword(index: Int) { - if (uiState.value is UiState.Editing) { - val keywords = (uiState.value as UiState.Editing).keywords.toMutableList() - - keywords.removeAt(index) - viewModelScope.launch { - uiState.emit(UiState.Editing(keywords.toList())) - } - } - } - - sealed class UiState { - object Loading : UiState() - object SaveSuccess : UiState() - data class SaveFailed(val message: String) : UiState() - - data class Editing(val keywords: List) : UiState() - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/signal/SignalCompleteFragment.kt b/presentation/src/main/java/com/mashup/presentation/signal/SignalCompleteFragment.kt deleted file mode 100644 index d292d0d57..000000000 --- a/presentation/src/main/java/com/mashup/presentation/signal/SignalCompleteFragment.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.mashup.presentation.signal - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigate -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentSignalCompleteBinding -import com.mashup.presentation.signal.compose.SignalCompleteScreen -import dagger.hilt.android.AndroidEntryPoint - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/03 - */ -@AndroidEntryPoint -class SignalCompleteFragment : - BaseFragment(R.layout.fragment_signal_complete) { - - override fun initViews() { - binding.composeView.setThemeContent { - SignalCompleteScreen( - finishActivity = { - navigate(actionId = R.id.action_signalComplete_to_home) - } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/signal/SignalContentFragment.kt b/presentation/src/main/java/com/mashup/presentation/signal/SignalContentFragment.kt deleted file mode 100644 index 10701d3f5..000000000 --- a/presentation/src/main/java/com/mashup/presentation/signal/SignalContentFragment.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.mashup.presentation.signal - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigate -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentSignalContentBinding -import com.mashup.presentation.signal.compose.SignalContentScreen -import dagger.hilt.android.AndroidEntryPoint - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/03 - */ -@AndroidEntryPoint -class SignalContentFragment : - BaseFragment(R.layout.fragment_signal_content) { - - override fun initViews() { - binding.composeView.setThemeContent { - SignalContentScreen( - navigateToSignalKeyword = { navigate(R.id.action_signalContent_to_signalKeyword) }, - navigateUp = { navigateUp() } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/signal/SignalKeywordFragment.kt b/presentation/src/main/java/com/mashup/presentation/signal/SignalKeywordFragment.kt deleted file mode 100644 index 1810afc63..000000000 --- a/presentation/src/main/java/com/mashup/presentation/signal/SignalKeywordFragment.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.mashup.presentation.signal - -import com.mashup.presentation.R -import com.mashup.presentation.common.base.BaseFragment -import com.mashup.presentation.common.extension.navigate -import com.mashup.presentation.common.extension.navigateUp -import com.mashup.presentation.common.extension.setThemeContent -import com.mashup.presentation.databinding.FragmentSignalKeywordBinding -import com.mashup.presentation.signal.compose.SignalKeywordScreen - -/** - * Ssam_D_Android - * @author jaesung - * @created 2023/06/15 - */ -class SignalKeywordFragment : - BaseFragment(R.layout.fragment_signal_keyword) { - - override fun initViews() { - binding.composeView.setThemeContent { - SignalKeywordScreen( - isLoading = false, - navigateUp = { navigateUp() }, - navigateToComplete = { navigate(R.id.action_signalKeyword_to_signalComplete) } - ) - } - } -} \ No newline at end of file diff --git a/presentation/src/main/java/com/mashup/presentation/ui/common/KeyLinkNavigationBar.kt b/presentation/src/main/java/com/mashup/presentation/ui/common/KeyLinkNavigationBar.kt new file mode 100644 index 000000000..8c44ab517 --- /dev/null +++ b/presentation/src/main/java/com/mashup/presentation/ui/common/KeyLinkNavigationBar.kt @@ -0,0 +1,162 @@ +package com.mashup.presentation.ui.common + +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.selection.selectableGroup +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.* +import androidx.compose.runtime.* +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.navigation.NavDestination +import androidx.navigation.NavDestination.Companion.hierarchy +import com.mashup.presentation.ui.theme.* +import com.mashup.presentation.R +import com.mashup.presentation.navigation.TopLevelDestination + +/** + * Ssam_D_Android + * @author jaesung + * @created 2023/07/04 + */ +@Composable +fun KeyLinkBottomBar( + destinations: List, + onNavigateToDestination: (TopLevelDestination) -> Unit, + currentDestination: NavDestination?, + modifier: Modifier = Modifier +) { + KeyLinkNavigationBar(modifier = modifier) { + destinations.forEach { destination -> + + val selected = currentDestination?.hierarchy?.any { + it.route?.contains(destination.name, true) ?: false + } ?: false + + KeyLinkNavigationBarItem( + selected = selected, + onClick = { onNavigateToDestination(destination) }, + icon = { + Icon( + painter = painterResource(id = destination.unselectedIconId), + contentDescription = stringResource(id = destination.iconTextId) + ) + }, + selectedIcon = { + Icon( + painter = painterResource(id = destination.selectedIconId), + contentDescription = stringResource(id = destination.iconTextId) + ) + }, + label = { + Text(text = stringResource(id = destination.textLabelId)) + }, + modifier = modifier, + ) + } + } +} + +@Composable +fun KeyLinkNavigationBar( + modifier: Modifier = Modifier, + content: @Composable RowScope.() -> Unit +) { + Surface( + color = Gray01, + shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), + elevation = BottomNavigationDefaults.Elevation, + modifier = modifier + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .height(76.dp) + .selectableGroup(), + horizontalArrangement = Arrangement.SpaceBetween, + content = content + ) + } +} + +@Composable +fun RowScope.KeyLinkNavigationBarItem( + selected: Boolean, + onClick: () -> Unit, + label: @Composable () -> Unit, + icon: @Composable () -> Unit, + selectedIcon: @Composable () -> Unit, + modifier: Modifier = Modifier, + alwaysShowLabel: Boolean = true, + enabled: Boolean = true +) { + BottomNavigationItem( + selected = selected, + onClick = onClick, + icon = if (selected) selectedIcon else icon, + label = label, + enabled = enabled, + modifier = modifier, + alwaysShowLabel = alwaysShowLabel, + selectedContentColor = White, + unselectedContentColor = Gray04, + ) +} + +@Preview(showBackground = true) +@Composable +fun KeyLinkNavigationBarPreview() { + var selectedItem by rememberSaveable { mutableStateOf(0) } + val items = listOf("홈", "보내기", "연결됨") + val icons = listOf( + painterResource(id = R.drawable.ic_home_fill_32), + painterResource(id = R.drawable.ic_signal_fill_32), + painterResource(id = R.drawable.ic_chat_fill_32) + ) + + val selectedIcons = listOf( + painterResource(id = R.drawable.ic_home_fill_32), + painterResource(id = R.drawable.ic_signal_fill_32), + painterResource(id = R.drawable.ic_chat_fill_32) + ) + SsamDTheme { + Surface(color = Black) { + KeyLinkNavigationBar { + items.forEachIndexed { index, item -> + KeyLinkNavigationBarItem( + selected = selectedItem == index, + onClick = { selectedItem = index }, + icon = { + BadgedBox(badge = { + Badge { + Text(text = "8") + } + }) { + Icon( + painter = icons[index], + contentDescription = "" + ) + } + + }, + selectedIcon = { + Icon( + painter = selectedIcons[index], + contentDescription = "" + ) + }, + label = { + Text( + text = item, + style = Caption2 + ) + } + ) + } + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/res/drawable/ic_signal_fill_32.xml b/presentation/src/main/res/drawable/ic_signal_fill_32.xml new file mode 100644 index 000000000..9d9b15379 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_signal_fill_32.xml @@ -0,0 +1,10 @@ + + + diff --git a/presentation/src/main/res/layout/activity_home.xml b/presentation/src/main/res/layout/activity_home.xml deleted file mode 100644 index f79473919..000000000 --- a/presentation/src/main/res/layout/activity_home.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_signal.xml b/presentation/src/main/res/layout/activity_signal.xml deleted file mode 100644 index c9edcbf2b..000000000 --- a/presentation/src/main/res/layout/activity_signal.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_chat.xml b/presentation/src/main/res/layout/fragment_chat.xml deleted file mode 100644 index c3f7aadb6..000000000 --- a/presentation/src/main/res/layout/fragment_chat.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_chat_detail.xml b/presentation/src/main/res/layout/fragment_chat_detail.xml deleted file mode 100644 index a1b07f828..000000000 --- a/presentation/src/main/res/layout/fragment_chat_detail.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_guide.xml b/presentation/src/main/res/layout/fragment_guide.xml deleted file mode 100644 index a1b07f828..000000000 --- a/presentation/src/main/res/layout/fragment_guide.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_home.xml b/presentation/src/main/res/layout/fragment_home.xml deleted file mode 100644 index b54c29ba7..000000000 --- a/presentation/src/main/res/layout/fragment_home.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_message_detail.xml b/presentation/src/main/res/layout/fragment_message_detail.xml deleted file mode 100644 index b54c29ba7..000000000 --- a/presentation/src/main/res/layout/fragment_message_detail.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_notification_list.xml b/presentation/src/main/res/layout/fragment_notification_list.xml deleted file mode 100644 index 76d680f90..000000000 --- a/presentation/src/main/res/layout/fragment_notification_list.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_received_signal.xml b/presentation/src/main/res/layout/fragment_received_signal.xml deleted file mode 100644 index 6a9dd9432..000000000 --- a/presentation/src/main/res/layout/fragment_received_signal.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_signal_complete.xml b/presentation/src/main/res/layout/fragment_signal_complete.xml deleted file mode 100644 index afd09729d..000000000 --- a/presentation/src/main/res/layout/fragment_signal_complete.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_signal_content.xml b/presentation/src/main/res/layout/fragment_signal_content.xml deleted file mode 100644 index 865e6105c..000000000 --- a/presentation/src/main/res/layout/fragment_signal_content.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_signal_keyword.xml b/presentation/src/main/res/layout/fragment_signal_keyword.xml deleted file mode 100644 index 865e6105c..000000000 --- a/presentation/src/main/res/layout/fragment_signal_keyword.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/fragment_subscribe_keyword.xml b/presentation/src/main/res/layout/fragment_subscribe_keyword.xml deleted file mode 100644 index a1b07f828..000000000 --- a/presentation/src/main/res/layout/fragment_subscribe_keyword.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/item_profile_app_version_content.xml b/presentation/src/main/res/layout/item_profile_app_version_content.xml index 869f53511..e5406dccd 100644 --- a/presentation/src/main/res/layout/item_profile_app_version_content.xml +++ b/presentation/src/main/res/layout/item_profile_app_version_content.xml @@ -7,7 +7,7 @@ + type="com.mashup.presentation.feature.mypage.profile.ProfileViewType.AppVersionContent" /> diff --git a/presentation/src/main/res/layout/item_profile_header.xml b/presentation/src/main/res/layout/item_profile_header.xml index e944840d6..8ff5153c8 100644 --- a/presentation/src/main/res/layout/item_profile_header.xml +++ b/presentation/src/main/res/layout/item_profile_header.xml @@ -7,7 +7,7 @@ + type="com.mashup.presentation.feature.mypage.profile.ProfileViewType.Header" /> diff --git a/presentation/src/main/res/layout/item_profile_navigation_content.xml b/presentation/src/main/res/layout/item_profile_navigation_content.xml index be7adb758..0bf92e89c 100644 --- a/presentation/src/main/res/layout/item_profile_navigation_content.xml +++ b/presentation/src/main/res/layout/item_profile_navigation_content.xml @@ -7,7 +7,7 @@ + type="com.mashup.presentation.feature.mypage.profile.ProfileViewType.NavigationContent" /> diff --git a/presentation/src/main/res/layout/item_profile_notification.xml b/presentation/src/main/res/layout/item_profile_notification.xml index 14e66cecc..b3e093112 100644 --- a/presentation/src/main/res/layout/item_profile_notification.xml +++ b/presentation/src/main/res/layout/item_profile_notification.xml @@ -7,7 +7,7 @@ + type="com.mashup.presentation.feature.mypage.profile.ProfileViewType.NotificationContent" /> diff --git a/presentation/src/main/res/layout/item_profile_user_info.xml b/presentation/src/main/res/layout/item_profile_user_info.xml index 1e622988d..b66eb4294 100644 --- a/presentation/src/main/res/layout/item_profile_user_info.xml +++ b/presentation/src/main/res/layout/item_profile_user_info.xml @@ -7,7 +7,7 @@ + type="com.mashup.presentation.feature.mypage.profile.ProfileViewType.UserInfo" /> - - - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_home.xml b/presentation/src/main/res/navigation/graph_home.xml deleted file mode 100644 index 7febd1f48..000000000 --- a/presentation/src/main/res/navigation/graph_home.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_navigation.xml b/presentation/src/main/res/navigation/graph_navigation.xml deleted file mode 100644 index aa16c59e1..000000000 --- a/presentation/src/main/res/navigation/graph_navigation.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_onboarding.xml b/presentation/src/main/res/navigation/graph_onboarding.xml index cbfc53f97..23edaaea4 100644 --- a/presentation/src/main/res/navigation/graph_onboarding.xml +++ b/presentation/src/main/res/navigation/graph_onboarding.xml @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_profile.xml b/presentation/src/main/res/navigation/graph_profile.xml index c17da844b..35756743c 100644 --- a/presentation/src/main/res/navigation/graph_profile.xml +++ b/presentation/src/main/res/navigation/graph_profile.xml @@ -6,7 +6,7 @@ \ No newline at end of file diff --git a/presentation/src/main/res/navigation/graph_signal.xml b/presentation/src/main/res/navigation/graph_signal.xml deleted file mode 100644 index 277a7f314..000000000 --- a/presentation/src/main/res/navigation/graph_signal.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index cd9e4959a..2b1afb4de 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -3,8 +3,8 @@ - 시그널 보내기 - 채팅 + 보내기 + 연결됨 최대 10자 입력 닫기 둘러보기