From 233b0b0af1e152ab32ee679250832f038205ab8d Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Sat, 5 Oct 2024 15:40:53 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Feat]=20=EA=B3=B5=ED=86=B5=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/ppac/navigation/FarmemeNavHost.kt | 8 +- core/common/android/build.gradle.kts | 1 + .../component/empty}/EmptyResultContent.kt | 2 +- .../paging/PagingItemsLoadingContent.kt | 91 +++++++++++++++++++ .../component/paging/PagingMemesContent.kt | 39 +++++--- .../component/paging/PagingResultFooter.kt | 2 +- .../paging/PagingResultItemCountHeader.kt | 2 +- ...tailRoute.kt => KeywordCollectionRoute.kt} | 19 ++-- ...ilScreen.kt => KeywordCollectionScreen.kt} | 24 ++--- ...Model.kt => KeywordCollectionViewModel.kt} | 39 ++++---- ....kt => KeywordCollectionLoadingContent.kt} | 4 +- .../detail/model/SearchResultUiModel.kt | 17 ---- .../detail/mvi/KeywordCollectionIntent.kt | 10 ++ ...fect.kt => KeywordCollectionSideEffect.kt} | 4 +- ...UiState.kt => KeywordCollectionUiState.kt} | 10 +- .../search/detail/mvi/SearchDetailIntent.kt | 10 -- ...tion.kt => KeywordCollectionNavigation.kt} | 14 +-- .../java/team/ppac/search/main/SearchRoute.kt | 4 +- .../team/ppac/search/main/SearchViewModel.kt | 4 +- .../ppac/search/main/mvi/SearchSideEffect.kt | 2 +- .../main/navigation/SearchNavigation.kt | 4 +- .../ppac/search/result/SearchResultScreen.kt | 12 +-- .../search/result/SearchResultViewModel.kt | 15 +-- .../search/result/mvi/SearchResultUiState.kt | 4 +- 24 files changed, 209 insertions(+), 132 deletions(-) rename {feature/search/src/main/java/team/ppac/search/detail/component => core/common/android/src/main/kotlin/team/ppac/common/android/component/empty}/EmptyResultContent.kt (97%) create mode 100644 core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingItemsLoadingContent.kt rename feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultContent.kt => core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingMemesContent.kt (64%) rename feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultFooter.kt => core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultFooter.kt (95%) rename feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultHeader.kt => core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultItemCountHeader.kt (95%) rename feature/search/src/main/java/team/ppac/search/detail/{SearchDetailRoute.kt => KeywordCollectionRoute.kt} (84%) rename feature/search/src/main/java/team/ppac/search/detail/{SearchDetailScreen.kt => KeywordCollectionScreen.kt} (84%) rename feature/search/src/main/java/team/ppac/search/detail/{SearchDetailViewModel.kt => KeywordCollectionViewModel.kt} (76%) rename feature/search/src/main/java/team/ppac/search/detail/component/{SearchDetailLoadingContent.kt => KeywordCollectionLoadingContent.kt} (97%) delete mode 100644 feature/search/src/main/java/team/ppac/search/detail/model/SearchResultUiModel.kt create mode 100644 feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt rename feature/search/src/main/java/team/ppac/search/detail/mvi/{SearchDetailSideEffect.kt => KeywordCollectionSideEffect.kt} (61%) rename feature/search/src/main/java/team/ppac/search/detail/mvi/{SearchDetailUiState.kt => KeywordCollectionUiState.kt} (64%) delete mode 100644 feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailIntent.kt rename feature/search/src/main/java/team/ppac/search/detail/navigation/{SearchDetailNavigation.kt => KeywordCollectionNavigation.kt} (68%) diff --git a/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt b/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt index 8db0e138..d7dfe8d1 100644 --- a/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt +++ b/app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt @@ -14,8 +14,8 @@ import team.ppac.mypage.navigation.navigateToMyPage import team.ppac.recommendation.navigation.RECOMMENDATION_ROUTE import team.ppac.recommendation.navigation.navigateToRecommendation import team.ppac.recommendation.navigation.recommendationScreen -import team.ppac.search.detail.navigation.navigateToSearchDetail -import team.ppac.search.detail.navigation.searchDetailScreen +import team.ppac.feature.keyword_collection.navigation.navigateToKeywordCollection +import team.ppac.feature.keyword_collection.navigation.keywordCollectionScreen import team.ppac.search.main.navigation.navigateToSearch import team.ppac.search.main.navigation.searchScreen import team.ppac.search.result.navigation.navigateToSearchResult @@ -44,10 +44,10 @@ fun FarmemeNavHost( ) searchScreen( analyticsHelper = analyticsHelper, - navigateToSearchDetail = { navController.navigateToSearchDetail(it) }, + navigateToKeywordCollection = { navController.navigateToKeywordCollection(it) }, navigateToSearchResult = { navController.navigateToSearchResult(it) } ) - searchDetailScreen( + keywordCollectionScreen( analyticsHelper = analyticsHelper, navigateBack = { navController.popBackStack() }, navigateToMemeDetail = navigateToDetail diff --git a/core/common/android/build.gradle.kts b/core/common/android/build.gradle.kts index be0c44ab..f8a297e5 100644 --- a/core/common/android/build.gradle.kts +++ b/core/common/android/build.gradle.kts @@ -24,6 +24,7 @@ android { dependencies { implementation(project(":core:designsystem")) + implementation(project(":core:domain")) implementation(libs.kotlin.coroutines.android) implementation(libs.kotlin.coroutines.core) diff --git a/feature/search/src/main/java/team/ppac/search/detail/component/EmptyResultContent.kt b/core/common/android/src/main/kotlin/team/ppac/common/android/component/empty/EmptyResultContent.kt similarity index 97% rename from feature/search/src/main/java/team/ppac/search/detail/component/EmptyResultContent.kt rename to core/common/android/src/main/kotlin/team/ppac/common/android/component/empty/EmptyResultContent.kt index 99e827f3..5d59a555 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/component/EmptyResultContent.kt +++ b/core/common/android/src/main/kotlin/team/ppac/common/android/component/empty/EmptyResultContent.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.component +package team.ppac.common.android.component.empty import androidx.compose.foundation.Image import androidx.compose.foundation.background diff --git a/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingItemsLoadingContent.kt b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingItemsLoadingContent.kt new file mode 100644 index 00000000..2fbea403 --- /dev/null +++ b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingItemsLoadingContent.kt @@ -0,0 +1,91 @@ +package team.ppac.common.android.component.paging + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import team.ppac.common.android.util.showSkeleton +import team.ppac.designsystem.foundation.FarmemeRadius + +@Composable +fun PagingItemsLoadingContent( + modifier: Modifier = Modifier, + isLoading: Boolean, +) { + Column( + modifier = modifier + ) { + Spacer(modifier = Modifier.size(20.dp)) + Box( + modifier = Modifier + .width(100.dp) + .height(18.dp) + .padding(start = 20.dp) + .clip(FarmemeRadius.Radius4.shape) + .showSkeleton(isLoading = isLoading) + ) + Spacer(modifier = Modifier.size(20.dp)) + Row( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp), + horizontalArrangement = Arrangement.spacedBy(12.dp) + ) { + repeat(2) { + Column( + modifier = Modifier.weight(1f) + ) { + Box( + modifier = Modifier + .fillMaxWidth() + .height(210.dp) + .clip(RoundedCornerShape(16.dp)) + .showSkeleton(isLoading = isLoading) + ) + Spacer(modifier = Modifier.size(10.dp)) + Box( + modifier = Modifier + .fillMaxWidth() + .height(18.dp) + .clip(FarmemeRadius.Radius4.shape) + .showSkeleton(isLoading = isLoading) + ) + Spacer(modifier = Modifier.size(10.dp)) + Box( + modifier = Modifier + .width(80.dp) + .height(18.dp) + .clip(FarmemeRadius.Radius4.shape) + .showSkeleton(isLoading = isLoading) + ) + } + } + } + } +} + +@Preview +@Composable +private fun PagingItemsLoadingContentPreview() { + Box(modifier = Modifier.background(Color.White)) { + PagingItemsLoadingContent( + modifier = Modifier.fillMaxSize(), + isLoading = true + ) + } +} \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultContent.kt b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingMemesContent.kt similarity index 64% rename from feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultContent.kt rename to core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingMemesContent.kt index 2f125af9..299643c1 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultContent.kt +++ b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingMemesContent.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.component +package team.ppac.common.android.component.paging import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.offset @@ -7,18 +7,22 @@ import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.paging.LoadState +import androidx.paging.PagingData import androidx.paging.compose.LazyPagingItems +import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.itemKey +import kotlinx.coroutines.flow.emptyFlow import team.ppac.common.android.component.FarmemeMemeItem -import team.ppac.search.detail.model.SearchResultUiModel +import team.ppac.domain.model.Meme @Composable -fun SearchDetailResultContent( +fun PagingMemesContent( modifier: Modifier = Modifier, totalItemCount: Int, - searchResults: LazyPagingItems, + pagingItems: LazyPagingItems, onMemeClick: (String) -> Unit, onCopyClick: (String, String) -> Unit, ) { @@ -32,25 +36,25 @@ fun SearchDetailResultContent( SearchDetailResultHeader(totalCount = totalItemCount) } items( - count = searchResults.itemCount, - key = searchResults.itemKey(SearchResultUiModel::memeId) + count = pagingItems.itemCount, + key = pagingItems.itemKey(Meme::id) ) { index -> - val searchResult = searchResults[index] ?: return@items + val searchResult = pagingItems[index] ?: return@items with(searchResult) { FarmemeMemeItem( modifier = Modifier.offset(y = (-20).dp), - memeId = memeId, - memeTitle = memeTitle, - lolCount = lolCount, + memeId = id, + memeTitle = title, + lolCount = reactionCount, imageUrl = imageUrl, onMemeClick = onMemeClick, - onCopyClick = { onCopyClick(memeId, memeTitle) }, + onCopyClick = { onCopyClick(id, title) }, ) } } - searchResults.apply { + pagingItems.apply { when { loadState.append is LoadState.NotLoading && loadState.append.endOfPaginationReached -> { item(span = StaggeredGridItemSpan.FullLine) { @@ -60,4 +64,15 @@ fun SearchDetailResultContent( } } } +} + +@Preview +@Composable +private fun PagingMemesContentPreview() { + PagingMemesContent( + totalItemCount = 10, + pagingItems = emptyFlow>().collectAsLazyPagingItems(), + onMemeClick = {}, + onCopyClick = { _, _ -> } + ) } \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultFooter.kt b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultFooter.kt similarity index 95% rename from feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultFooter.kt rename to core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultFooter.kt index ed2df193..49e1125a 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultFooter.kt +++ b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultFooter.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.component +package team.ppac.common.android.component.paging import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box diff --git a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultHeader.kt b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultItemCountHeader.kt similarity index 95% rename from feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultHeader.kt rename to core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultItemCountHeader.kt index a5c9fbff..c71e2bf5 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailResultHeader.kt +++ b/core/common/android/src/main/kotlin/team/ppac/common/android/component/paging/PagingResultItemCountHeader.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.component +package team.ppac.common.android.component.paging import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxWidth diff --git a/feature/search/src/main/java/team/ppac/search/detail/SearchDetailRoute.kt b/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionRoute.kt similarity index 84% rename from feature/search/src/main/java/team/ppac/search/detail/SearchDetailRoute.kt rename to feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionRoute.kt index 9b9bd456..07c532be 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/SearchDetailRoute.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionRoute.kt @@ -2,10 +2,8 @@ package team.ppac.search.detail import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier @@ -21,15 +19,14 @@ import team.ppac.analytics.action.SearchDetailAction import team.ppac.analytics.type.ScreenType import team.ppac.common.android.base.BaseComposable import team.ppac.common.android.util.ComposableLifecycle -import team.ppac.search.detail.mvi.SearchDetailIntent -import team.ppac.search.detail.mvi.SearchDetailSideEffect -import timber.log.Timber +import team.ppac.search.detail.mvi.KeywordCollectionIntent +import team.ppac.search.detail.mvi.KeywordCollectionSideEffect @Composable -internal fun SearchDetailRoute( +internal fun KeywordCollectionRoute( modifier: Modifier = Modifier, analyticsHelper: AnalyticsHelper, - viewModel: SearchDetailViewModel = hiltViewModel(), + viewModel: KeywordCollectionViewModel = hiltViewModel(), navigateBack: () -> Unit, navigateToMemeDetail: (String) -> Unit, ) { @@ -55,13 +52,13 @@ internal fun SearchDetailRoute( LaunchedEffect(key1 = viewModel) { viewModel.sideEffect.collect { sideEffect -> when (sideEffect) { - is SearchDetailSideEffect.NavigateToMemeDetail -> + is KeywordCollectionSideEffect.NavigateToMemeDetail -> navigateToMemeDetail(sideEffect.memeId) } } } - SearchDetailScreen( + KeywordCollectionScreen( modifier = modifier, uiState = uiState, handleLoadStates = viewModel::handleLoadErrorStates, @@ -85,9 +82,9 @@ internal fun SearchDetailRoute( } ) - viewModel.intent(SearchDetailIntent.ClickMeme(memeId)) + viewModel.intent(KeywordCollectionIntent.ClickMeme(memeId)) }, - onRetryClick = { viewModel.intent(SearchDetailIntent.ClickErrorRetry) }, + onRetryClick = { viewModel.intent(KeywordCollectionIntent.ClickErrorRetry) }, onCopyClick = { memeId, memeTitle -> analyticsHelper.reportAction( action = SearchDetailAction.CLICK_COPY, diff --git a/feature/search/src/main/java/team/ppac/search/detail/SearchDetailScreen.kt b/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionScreen.kt similarity index 84% rename from feature/search/src/main/java/team/ppac/search/detail/SearchDetailScreen.kt rename to feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionScreen.kt index 965ff4c8..5d690d82 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/SearchDetailScreen.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionScreen.kt @@ -13,28 +13,28 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.LayoutDirection import androidx.paging.LoadStates +import team.ppac.common.android.component.empty.EmptyResultContent +import team.ppac.common.android.component.paging.PagingMemesContent import team.ppac.common.android.component.error.FarmemeErrorScreen import team.ppac.common.android.extension.collectPagingItemsWithHandleState import team.ppac.designsystem.FarmemeTheme import team.ppac.designsystem.component.scaffold.FarmemeScaffold import team.ppac.designsystem.component.tabbar.TabBarHeight import team.ppac.designsystem.component.toolbar.FarmemeBackToolBar -import team.ppac.search.detail.component.EmptyResultContent -import team.ppac.search.detail.component.SearchDetailLoadingContent -import team.ppac.search.detail.component.SearchDetailResultContent -import team.ppac.search.detail.mvi.SearchDetailUiState +import team.ppac.search.detail.component.KeywordCollectionLoadingContent +import team.ppac.search.detail.mvi.KeywordCollectionUiState @Composable -internal fun SearchDetailScreen( +internal fun KeywordCollectionScreen( modifier: Modifier = Modifier, - uiState: SearchDetailUiState, + uiState: KeywordCollectionUiState, handleLoadStates: (LoadStates) -> Unit, onBackClick: () -> Unit, onMemeClick: (String) -> Unit, onRetryClick: () -> Unit, onCopyClick: (String, String) -> Unit, ) { - val searchResults = uiState.searchResults.collectPagingItemsWithHandleState(handleLoadStates) + val memes = uiState.memes.collectPagingItemsWithHandleState(handleLoadStates) when { uiState.isError -> { @@ -72,7 +72,7 @@ internal fun SearchDetailScreen( when { uiState.isLoading -> { - SearchDetailLoadingContent( + KeywordCollectionLoadingContent( modifier = Modifier.fillMaxSize(), isLoading = uiState.isLoading ) @@ -85,9 +85,9 @@ internal fun SearchDetailScreen( if (uiState.totalMemeCount == 0) { EmptyResultContent() } else { - SearchDetailResultContent( + PagingMemesContent( totalItemCount = uiState.totalMemeCount, - searchResults = searchResults, + pagingItems = memes, onMemeClick = onMemeClick, onCopyClick = onCopyClick, ) @@ -103,8 +103,8 @@ internal fun SearchDetailScreen( @Preview @Composable private fun SearchDetailScreenPreview() { - SearchDetailScreen( - uiState = SearchDetailUiState.INITIAL_STATE, + KeywordCollectionScreen( + uiState = KeywordCollectionUiState.INITIAL_STATE, handleLoadStates = {}, onBackClick = {}, onMemeClick = {}, diff --git a/feature/search/src/main/java/team/ppac/search/detail/SearchDetailViewModel.kt b/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionViewModel.kt similarity index 76% rename from feature/search/src/main/java/team/ppac/search/detail/SearchDetailViewModel.kt rename to feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionViewModel.kt index 3dafdce7..18567ce6 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/SearchDetailViewModel.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionViewModel.kt @@ -6,30 +6,29 @@ import androidx.paging.LoadState import androidx.paging.LoadStates import androidx.paging.PagingData import androidx.paging.cachedIn -import androidx.paging.map import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.map import team.ppac.common.android.base.BaseViewModel +import team.ppac.domain.model.Meme import team.ppac.domain.model.MemeWatchType import team.ppac.domain.usecase.GetSearchMemeUseCase import team.ppac.domain.usecase.WatchMemeUseCase import team.ppac.errorhandling.FarmemeNetworkException -import team.ppac.search.detail.model.SearchResultUiModel -import team.ppac.search.detail.model.toSearchResultUiModel -import team.ppac.search.detail.mvi.SearchDetailIntent -import team.ppac.search.detail.mvi.SearchDetailSideEffect -import team.ppac.search.detail.mvi.SearchDetailUiState +import team.ppac.search.detail.mvi.KeywordCollectionIntent +import team.ppac.search.detail.mvi.KeywordCollectionSideEffect +import team.ppac.search.detail.mvi.KeywordCollectionUiState import javax.inject.Inject @HiltViewModel -class SearchDetailViewModel @Inject constructor( +class KeywordCollectionViewModel @Inject constructor( savedStateHandle: SavedStateHandle, private val getSearchMemeUseCase: GetSearchMemeUseCase, private val watchMemeUseCase: WatchMemeUseCase, -) : BaseViewModel(savedStateHandle) { +) : BaseViewModel( + savedStateHandle +) { val currentPage: MutableSharedFlow = MutableSharedFlow(replay = 1) @@ -41,27 +40,27 @@ class SearchDetailViewModel @Inject constructor( getSearchResults(keyword, getCurrentPage = { currentPage.tryEmit(it) }) } - override fun createInitialState(savedStateHandle: SavedStateHandle): SearchDetailUiState { - return SearchDetailUiState.INITIAL_STATE + override fun createInitialState(savedStateHandle: SavedStateHandle): KeywordCollectionUiState { + return KeywordCollectionUiState.INITIAL_STATE } override fun handleClientException(throwable: Throwable) {} - override suspend fun handleIntent(intent: SearchDetailIntent) { + override suspend fun handleIntent(intent: KeywordCollectionIntent) { when (intent) { - is SearchDetailIntent.ClickErrorRetry -> { + is KeywordCollectionIntent.ClickErrorRetry -> { getSearchResults(currentState.keyword, getCurrentPage = { currentPage.tryEmit(it) }) updateErrorState(isError = false) } - is SearchDetailIntent.ClickMeme -> { + is KeywordCollectionIntent.ClickMeme -> { runCatching { watchMemeUseCase( memeId = intent.memeId, watchType = MemeWatchType.SEARCH ) }.onSuccess { - postSideEffect(SearchDetailSideEffect.NavigateToMemeDetail(memeId = intent.memeId)) + postSideEffect(KeywordCollectionSideEffect.NavigateToMemeDetail(memeId = intent.memeId)) }.onFailure { // 에러 처리 } @@ -88,7 +87,7 @@ class SearchDetailViewModel @Inject constructor( private fun getSearchResults( keyword: String, - getCurrentPage: (Int) -> Unit + getCurrentPage: (Int) -> Unit, ) = launch { updateLoadingState(true) delay(300L) @@ -97,9 +96,7 @@ class SearchDetailViewModel @Inject constructor( val paginationResults = getSearchMemeUseCase(keyword, getCurrentPage) val totalMemeCount = paginationResults.totalMemeCount val searchResults = paginationResults.memes - .map { pagingData -> - pagingData.map { it.toSearchResultUiModel() } - }.cachedIn(viewModelScope) + .cachedIn(viewModelScope) updateLoadingState(false) updateSearchResults(totalMemeCount, keyword, searchResults) @@ -120,13 +117,13 @@ class SearchDetailViewModel @Inject constructor( private fun updateSearchResults( totalMemeCount: Int, keyword: String, - searchResults: Flow>, + searchResults: Flow>, ) { reduce { copy( totalMemeCount = totalMemeCount, keyword = keyword, - searchResults = searchResults + memes = searchResults ) } } diff --git a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailLoadingContent.kt b/feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt similarity index 97% rename from feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailLoadingContent.kt rename to feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt index 1273eb68..f3cf939e 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/component/SearchDetailLoadingContent.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt @@ -23,7 +23,7 @@ import team.ppac.common.android.util.showSkeleton import team.ppac.designsystem.foundation.FarmemeRadius @Composable -internal fun SearchDetailLoadingContent( +internal fun KeywordCollectionLoadingContent( modifier: Modifier = Modifier, isLoading: Boolean, ) { @@ -83,7 +83,7 @@ internal fun SearchDetailLoadingContent( @Composable private fun SearchDetailLoadingContentPreview() { Box(modifier = Modifier.background(Color.White)) { - SearchDetailLoadingContent( + KeywordCollectionLoadingContent( modifier = Modifier.fillMaxSize(), isLoading = true ) diff --git a/feature/search/src/main/java/team/ppac/search/detail/model/SearchResultUiModel.kt b/feature/search/src/main/java/team/ppac/search/detail/model/SearchResultUiModel.kt deleted file mode 100644 index 10d96c0c..00000000 --- a/feature/search/src/main/java/team/ppac/search/detail/model/SearchResultUiModel.kt +++ /dev/null @@ -1,17 +0,0 @@ -package team.ppac.search.detail.model - -import team.ppac.domain.model.Meme - -data class SearchResultUiModel( - val memeId: String, - val imageUrl: String, - val memeTitle: String, - val lolCount: Int, -) - -fun Meme.toSearchResultUiModel() = SearchResultUiModel( - memeId = id, - imageUrl = imageUrl, - memeTitle = title, - lolCount = reactionCount -) diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt b/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt new file mode 100644 index 00000000..819e6391 --- /dev/null +++ b/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt @@ -0,0 +1,10 @@ +package team.ppac.search.detail.mvi + +import team.ppac.common.android.base.UiIntent + +sealed class KeywordCollectionIntent : UiIntent { + data object ClickErrorRetry : KeywordCollectionIntent() + data class ClickMeme( + val memeId: String, + ) : KeywordCollectionIntent() +} \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailSideEffect.kt b/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionSideEffect.kt similarity index 61% rename from feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailSideEffect.kt rename to feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionSideEffect.kt index f97ac47f..9004312d 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailSideEffect.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionSideEffect.kt @@ -2,8 +2,8 @@ package team.ppac.search.detail.mvi import team.ppac.common.android.base.UiSideEffect -sealed class SearchDetailSideEffect : UiSideEffect { +sealed class KeywordCollectionSideEffect : UiSideEffect { data class NavigateToMemeDetail( val memeId: String, - ) : SearchDetailSideEffect() + ) : KeywordCollectionSideEffect() } \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailUiState.kt b/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionUiState.kt similarity index 64% rename from feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailUiState.kt rename to feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionUiState.kt index b8ddc764..6afbcf0c 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailUiState.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionUiState.kt @@ -4,23 +4,23 @@ import androidx.paging.PagingData import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import team.ppac.common.android.base.UiState -import team.ppac.search.detail.model.SearchResultUiModel +import team.ppac.domain.model.Meme -data class SearchDetailUiState( +data class KeywordCollectionUiState( val isLoading: Boolean, val isError: Boolean, val totalMemeCount: Int, val keyword: String, - val searchResults: Flow>, + val memes: Flow>, ) : UiState { companion object { - val INITIAL_STATE = SearchDetailUiState( + val INITIAL_STATE = KeywordCollectionUiState( isLoading = true, isError = false, totalMemeCount = 0, keyword = "", - searchResults = flowOf(PagingData.empty()) + memes = flowOf(PagingData.empty()) ) } } diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailIntent.kt b/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailIntent.kt deleted file mode 100644 index a4d350ef..00000000 --- a/feature/search/src/main/java/team/ppac/search/detail/mvi/SearchDetailIntent.kt +++ /dev/null @@ -1,10 +0,0 @@ -package team.ppac.search.detail.mvi - -import team.ppac.common.android.base.UiIntent - -sealed class SearchDetailIntent : UiIntent { - data object ClickErrorRetry : SearchDetailIntent() - data class ClickMeme( - val memeId: String, - ) : SearchDetailIntent() -} \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/detail/navigation/SearchDetailNavigation.kt b/feature/search/src/main/java/team/ppac/search/detail/navigation/KeywordCollectionNavigation.kt similarity index 68% rename from feature/search/src/main/java/team/ppac/search/detail/navigation/SearchDetailNavigation.kt rename to feature/search/src/main/java/team/ppac/search/detail/navigation/KeywordCollectionNavigation.kt index 9bc78939..fbb2bede 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/navigation/SearchDetailNavigation.kt +++ b/feature/search/src/main/java/team/ppac/search/detail/navigation/KeywordCollectionNavigation.kt @@ -6,28 +6,28 @@ import androidx.navigation.NavType import androidx.navigation.compose.composable import androidx.navigation.navArgument import team.ppac.analytics.AnalyticsHelper -import team.ppac.search.detail.SearchDetailRoute +import team.ppac.search.detail.KeywordCollectionRoute -const val SEARCH_DETAIL_ROUTE = "search_detail" +const val KEYWORD_COLLECTION_ROUTE = "keyword_collection" -fun NavController.navigateToSearchDetail( +fun NavController.navigateToKeywordCollection( keyword: String, -) = navigate("$SEARCH_DETAIL_ROUTE/${keyword}") +) = navigate("$KEYWORD_COLLECTION_ROUTE/${keyword}") -fun NavGraphBuilder.searchDetailScreen( +fun NavGraphBuilder.keywordCollectionScreen( analyticsHelper: AnalyticsHelper, navigateBack: () -> Unit, navigateToMemeDetail: (String) -> Unit, ) { composable( - route = "$SEARCH_DETAIL_ROUTE/{keyword}", + route = "$KEYWORD_COLLECTION_ROUTE/{keyword}", arguments = listOf( navArgument("keyword") { type = NavType.StringType } ) ) { - SearchDetailRoute( + KeywordCollectionRoute( analyticsHelper = analyticsHelper, navigateBack = navigateBack, navigateToMemeDetail = navigateToMemeDetail, diff --git a/feature/search/src/main/java/team/ppac/search/main/SearchRoute.kt b/feature/search/src/main/java/team/ppac/search/main/SearchRoute.kt index 4ed04b2d..b5a22ca9 100644 --- a/feature/search/src/main/java/team/ppac/search/main/SearchRoute.kt +++ b/feature/search/src/main/java/team/ppac/search/main/SearchRoute.kt @@ -21,7 +21,7 @@ internal fun SearchRoute( modifier: Modifier = Modifier, analyticsHelper: AnalyticsHelper, viewModel: SearchViewModel = hiltViewModel(), - navigateToSearchDetail: (String) -> Unit, + navigateToKeywordCollection: (String) -> Unit, navigateToSearchResult: (String) -> Unit, ) { ComposableLifecycle { _, event -> @@ -38,7 +38,7 @@ internal fun SearchRoute( LaunchedEffect(key1 = viewModel) { viewModel.sideEffect.collect { sideEffect -> when (sideEffect) { - is SearchSideEffect.NavigateToSearchDetail -> navigateToSearchDetail(sideEffect.argument) + is SearchSideEffect.NavigateToKeywordCollection -> navigateToKeywordCollection(sideEffect.argument) is SearchSideEffect.NavigateToSearchResult -> navigateToSearchResult(sideEffect.argument) } } diff --git a/feature/search/src/main/java/team/ppac/search/main/SearchViewModel.kt b/feature/search/src/main/java/team/ppac/search/main/SearchViewModel.kt index 754fbdb1..07331d8b 100644 --- a/feature/search/src/main/java/team/ppac/search/main/SearchViewModel.kt +++ b/feature/search/src/main/java/team/ppac/search/main/SearchViewModel.kt @@ -54,11 +54,11 @@ class SearchViewModel @Inject constructor( } is SearchIntent.ClickKeywordCard -> { - postSideEffect(SearchSideEffect.NavigateToSearchDetail(argument = intent.keyword)) + postSideEffect(SearchSideEffect.NavigateToKeywordCollection(argument = intent.keyword)) } is SearchIntent.ClickMemeKeyword -> { - postSideEffect(SearchSideEffect.NavigateToSearchDetail(argument = intent.keyword)) + postSideEffect(SearchSideEffect.NavigateToKeywordCollection(argument = intent.keyword)) } is SearchIntent.ClickServiceOpenDialogConfirm -> { diff --git a/feature/search/src/main/java/team/ppac/search/main/mvi/SearchSideEffect.kt b/feature/search/src/main/java/team/ppac/search/main/mvi/SearchSideEffect.kt index 122bd8ff..e1e7e5bb 100644 --- a/feature/search/src/main/java/team/ppac/search/main/mvi/SearchSideEffect.kt +++ b/feature/search/src/main/java/team/ppac/search/main/mvi/SearchSideEffect.kt @@ -3,6 +3,6 @@ package team.ppac.search.main.mvi import team.ppac.common.android.base.UiSideEffect sealed class SearchSideEffect : UiSideEffect { - data class NavigateToSearchDetail(val argument: String) : SearchSideEffect() + data class NavigateToKeywordCollection(val argument: String) : SearchSideEffect() data class NavigateToSearchResult(val argument: String) : SearchSideEffect() } \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/main/navigation/SearchNavigation.kt b/feature/search/src/main/java/team/ppac/search/main/navigation/SearchNavigation.kt index aa608e84..49128ac4 100644 --- a/feature/search/src/main/java/team/ppac/search/main/navigation/SearchNavigation.kt +++ b/feature/search/src/main/java/team/ppac/search/main/navigation/SearchNavigation.kt @@ -13,7 +13,7 @@ fun NavController.navigateToSearch(navOptions: NavOptions) = navigate(SEARCH_ROU fun NavGraphBuilder.searchScreen( analyticsHelper: AnalyticsHelper, - navigateToSearchDetail: (String) -> Unit, + navigateToKeywordCollection: (String) -> Unit, navigateToSearchResult: (String) -> Unit, ) { composable( @@ -21,7 +21,7 @@ fun NavGraphBuilder.searchScreen( ) { SearchRoute( analyticsHelper = analyticsHelper, - navigateToSearchDetail = navigateToSearchDetail, + navigateToKeywordCollection = navigateToKeywordCollection, navigateToSearchResult = navigateToSearchResult, ) } diff --git a/feature/search/src/main/java/team/ppac/search/result/SearchResultScreen.kt b/feature/search/src/main/java/team/ppac/search/result/SearchResultScreen.kt index bb54215f..5c02d305 100644 --- a/feature/search/src/main/java/team/ppac/search/result/SearchResultScreen.kt +++ b/feature/search/src/main/java/team/ppac/search/result/SearchResultScreen.kt @@ -14,14 +14,14 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.LayoutDirection import androidx.paging.LoadStates +import team.ppac.common.android.component.empty.EmptyResultContent import team.ppac.common.android.component.error.FarmemeErrorScreen +import team.ppac.common.android.component.paging.PagingItemsLoadingContent +import team.ppac.common.android.component.paging.PagingMemesContent import team.ppac.common.android.extension.collectPagingItemsWithHandleState import team.ppac.designsystem.component.scaffold.FarmemeScaffold import team.ppac.designsystem.component.tabbar.TabBarHeight import team.ppac.designsystem.component.toolbar.FarmemeSearchToolbar -import team.ppac.search.detail.component.EmptyResultContent -import team.ppac.search.detail.component.SearchDetailLoadingContent -import team.ppac.search.detail.component.SearchDetailResultContent import team.ppac.search.result.mvi.SearchResultUiState @Composable @@ -76,7 +76,7 @@ internal fun SearchResultScreen( when { uiState.isLoading -> { - SearchDetailLoadingContent( + PagingItemsLoadingContent( modifier = Modifier.fillMaxSize(), isLoading = uiState.isLoading ) @@ -89,9 +89,9 @@ internal fun SearchResultScreen( if (uiState.totalMemeCount == 0) { EmptyResultContent() } else { - SearchDetailResultContent( + PagingMemesContent( totalItemCount = uiState.totalMemeCount, - searchResults = searchResults, + pagingItems = searchResults, onMemeClick = onMemeClick, onCopyClick = onCopyClick, ) diff --git a/feature/search/src/main/java/team/ppac/search/result/SearchResultViewModel.kt b/feature/search/src/main/java/team/ppac/search/result/SearchResultViewModel.kt index 029bc569..750b5d73 100644 --- a/feature/search/src/main/java/team/ppac/search/result/SearchResultViewModel.kt +++ b/feature/search/src/main/java/team/ppac/search/result/SearchResultViewModel.kt @@ -6,19 +6,15 @@ import androidx.paging.LoadState import androidx.paging.LoadStates import androidx.paging.PagingData import androidx.paging.cachedIn -import androidx.paging.map import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map import team.ppac.common.android.base.BaseViewModel +import team.ppac.domain.model.Meme import team.ppac.domain.model.MemeWatchType import team.ppac.domain.usecase.SearchMemeUseCase import team.ppac.domain.usecase.WatchMemeUseCase import team.ppac.errorhandling.FarmemeNetworkException -import team.ppac.search.detail.model.SearchResultUiModel -import team.ppac.search.detail.model.toSearchResultUiModel -import team.ppac.search.detail.mvi.SearchDetailSideEffect import team.ppac.search.result.mvi.ClickBackButton import team.ppac.search.result.mvi.ClickErrorRetry import team.ppac.search.result.mvi.ClickMeme @@ -27,7 +23,6 @@ import team.ppac.search.result.mvi.NavigateToMemeDetail import team.ppac.search.result.mvi.SearchResultIntent import team.ppac.search.result.mvi.SearchResultSideEffect import team.ppac.search.result.mvi.SearchResultUiState -import timber.log.Timber import javax.inject.Inject @HiltViewModel @@ -54,6 +49,7 @@ class SearchResultViewModel @Inject constructor( getSearchResults(currentState.query) updateErrorState(isError = false) } + is ClickMeme -> { runCatching { watchMemeUseCase( @@ -86,10 +82,7 @@ class SearchResultViewModel @Inject constructor( val paginationResults = searchMemeUseCase(query) val totalMemeCount = paginationResults.totalMemeCount val searchResults = paginationResults.memes - .map { pagingData -> - pagingData.map { - it.toSearchResultUiModel() } - }.cachedIn(viewModelScope) + .cachedIn(viewModelScope) updateLoadingState(false) updateSearchResults(totalMemeCount, searchResults) @@ -130,7 +123,7 @@ class SearchResultViewModel @Inject constructor( private fun updateSearchResults( totalMemeCount: Int, - searchResults: Flow>, + searchResults: Flow>, ) { reduce { copy( diff --git a/feature/search/src/main/java/team/ppac/search/result/mvi/SearchResultUiState.kt b/feature/search/src/main/java/team/ppac/search/result/mvi/SearchResultUiState.kt index 321dab35..2dd40dab 100644 --- a/feature/search/src/main/java/team/ppac/search/result/mvi/SearchResultUiState.kt +++ b/feature/search/src/main/java/team/ppac/search/result/mvi/SearchResultUiState.kt @@ -4,14 +4,14 @@ import androidx.paging.PagingData import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import team.ppac.common.android.base.UiState -import team.ppac.search.detail.model.SearchResultUiModel +import team.ppac.domain.model.Meme data class SearchResultUiState( val isLoading: Boolean, val isError: Boolean, val query: String, val totalMemeCount: Int, - val searchResults: Flow>, + val searchResults: Flow>, ) : UiState { companion object { From 0840d324d3b7822f14712332fe8eb2a8e9b45a6d Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Sat, 5 Oct 2024 16:04:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Feat]=20=ED=82=A4=EC=9B=8C=EB=93=9C=20?= =?UTF-8?q?=EB=AA=A8=EC=95=84=EB=B3=B4=EA=B8=B0=20=EB=AA=A8=EB=93=88?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 1 + feature/keyword-collection/.gitignore | 1 + feature/keyword-collection/build.gradle.kts | 50 ++++++++++ .../src/main/AndroidManifest.xml | 4 + .../KeywordCollectionRoute.kt | 6 +- .../KeywordCollectionScreen.kt | 8 +- .../KeywordCollectionViewModel.kt | 8 +- .../mvi/KeywordCollectionIntent.kt | 2 +- .../mvi/KeywordCollectionSideEffect.kt | 2 +- .../mvi/KeywordCollectionUiState.kt | 2 +- .../navigation/KeywordCollectionNavigation.kt | 4 +- .../KeywordCollectionLoadingContent.kt | 91 ------------------- settings.gradle.kts | 1 + 13 files changed, 73 insertions(+), 107 deletions(-) create mode 100644 feature/keyword-collection/.gitignore create mode 100644 feature/keyword-collection/build.gradle.kts create mode 100644 feature/keyword-collection/src/main/AndroidManifest.xml rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/KeywordCollectionRoute.kt (94%) rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/KeywordCollectionScreen.kt (94%) rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/KeywordCollectionViewModel.kt (94%) rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/mvi/KeywordCollectionIntent.kt (83%) rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/mvi/KeywordCollectionSideEffect.kt (81%) rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/mvi/KeywordCollectionUiState.kt (92%) rename feature/{search/src/main/java/team/ppac/search/detail => keyword-collection/src/main/java/team/ppac/feature/keyword_collection}/navigation/KeywordCollectionNavigation.kt (88%) delete mode 100644 feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ae552c81..4a23ac5d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -94,6 +94,7 @@ dependencies { implementation(project(":feature:setting")) implementation(project(":feature:splash")) implementation(project(":feature:register")) + implementation(project(":feature:keyword-collection")) implementation(libs.core.ktx) implementation(libs.lifecycle) diff --git a/feature/keyword-collection/.gitignore b/feature/keyword-collection/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/feature/keyword-collection/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/keyword-collection/build.gradle.kts b/feature/keyword-collection/build.gradle.kts new file mode 100644 index 00000000..f1becad7 --- /dev/null +++ b/feature/keyword-collection/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.dagger.hilt) + alias(libs.plugins.kotlin.kapt) +} + +android { + namespace = "team.ppac.feature.keyword_collection" + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + } + kotlinOptions { + jvmTarget = "17" + } +} + +dependencies { + implementation(project(":core:common:android")) + implementation(project(":core:common:kotlin")) + implementation(project(":core:domain")) + implementation(project(":core:designsystem")) + implementation(project(":core:error-handling")) + implementation(project(":core:analytics")) + + implementation(platform(libs.compose.bom)) + implementation(libs.bundles.compose) + implementation(libs.bundles.lifecycle) + implementation(libs.appcompat) + implementation(libs.core.ktx) + implementation(libs.kotlin.coroutines.android) + implementation(libs.timber) + implementation(libs.hilt.android) + implementation(libs.kotlinx.collections.immutable) + kapt(libs.hilt.compiler) + implementation(libs.paging.runtime) + implementation(libs.paging.compose) +} \ No newline at end of file diff --git a/feature/keyword-collection/src/main/AndroidManifest.xml b/feature/keyword-collection/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/feature/keyword-collection/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionRoute.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionRoute.kt similarity index 94% rename from feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionRoute.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionRoute.kt index 07c532be..05852745 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionRoute.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionRoute.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail +package team.ppac.feature.keyword_collection import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -19,8 +19,8 @@ import team.ppac.analytics.action.SearchDetailAction import team.ppac.analytics.type.ScreenType import team.ppac.common.android.base.BaseComposable import team.ppac.common.android.util.ComposableLifecycle -import team.ppac.search.detail.mvi.KeywordCollectionIntent -import team.ppac.search.detail.mvi.KeywordCollectionSideEffect +import team.ppac.feature.keyword_collection.mvi.KeywordCollectionIntent +import team.ppac.feature.keyword_collection.mvi.KeywordCollectionSideEffect @Composable internal fun KeywordCollectionRoute( diff --git a/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionScreen.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionScreen.kt similarity index 94% rename from feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionScreen.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionScreen.kt index 5d690d82..cee994b5 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionScreen.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionScreen.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail +package team.ppac.feature.keyword_collection import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues @@ -21,8 +21,8 @@ import team.ppac.designsystem.FarmemeTheme import team.ppac.designsystem.component.scaffold.FarmemeScaffold import team.ppac.designsystem.component.tabbar.TabBarHeight import team.ppac.designsystem.component.toolbar.FarmemeBackToolBar -import team.ppac.search.detail.component.KeywordCollectionLoadingContent -import team.ppac.search.detail.mvi.KeywordCollectionUiState +import team.ppac.common.android.component.paging.PagingItemsLoadingContent +import team.ppac.feature.keyword_collection.mvi.KeywordCollectionUiState @Composable internal fun KeywordCollectionScreen( @@ -72,7 +72,7 @@ internal fun KeywordCollectionScreen( when { uiState.isLoading -> { - KeywordCollectionLoadingContent( + PagingItemsLoadingContent( modifier = Modifier.fillMaxSize(), isLoading = uiState.isLoading ) diff --git a/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionViewModel.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionViewModel.kt similarity index 94% rename from feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionViewModel.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionViewModel.kt index 18567ce6..4336ff89 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/KeywordCollectionViewModel.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/KeywordCollectionViewModel.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail +package team.ppac.feature.keyword_collection import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.viewModelScope @@ -16,9 +16,9 @@ import team.ppac.domain.model.MemeWatchType import team.ppac.domain.usecase.GetSearchMemeUseCase import team.ppac.domain.usecase.WatchMemeUseCase import team.ppac.errorhandling.FarmemeNetworkException -import team.ppac.search.detail.mvi.KeywordCollectionIntent -import team.ppac.search.detail.mvi.KeywordCollectionSideEffect -import team.ppac.search.detail.mvi.KeywordCollectionUiState +import team.ppac.feature.keyword_collection.mvi.KeywordCollectionIntent +import team.ppac.feature.keyword_collection.mvi.KeywordCollectionSideEffect +import team.ppac.feature.keyword_collection.mvi.KeywordCollectionUiState import javax.inject.Inject @HiltViewModel diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionIntent.kt similarity index 83% rename from feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionIntent.kt index 819e6391..f6d01d7a 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionIntent.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionIntent.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.mvi +package team.ppac.feature.keyword_collection.mvi import team.ppac.common.android.base.UiIntent diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionSideEffect.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionSideEffect.kt similarity index 81% rename from feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionSideEffect.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionSideEffect.kt index 9004312d..489b0663 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionSideEffect.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionSideEffect.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.mvi +package team.ppac.feature.keyword_collection.mvi import team.ppac.common.android.base.UiSideEffect diff --git a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionUiState.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionUiState.kt similarity index 92% rename from feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionUiState.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionUiState.kt index 6afbcf0c..a16c80d3 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/mvi/KeywordCollectionUiState.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/mvi/KeywordCollectionUiState.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.mvi +package team.ppac.feature.keyword_collection.mvi import androidx.paging.PagingData import kotlinx.coroutines.flow.Flow diff --git a/feature/search/src/main/java/team/ppac/search/detail/navigation/KeywordCollectionNavigation.kt b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/navigation/KeywordCollectionNavigation.kt similarity index 88% rename from feature/search/src/main/java/team/ppac/search/detail/navigation/KeywordCollectionNavigation.kt rename to feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/navigation/KeywordCollectionNavigation.kt index fbb2bede..ea0e4d11 100644 --- a/feature/search/src/main/java/team/ppac/search/detail/navigation/KeywordCollectionNavigation.kt +++ b/feature/keyword-collection/src/main/java/team/ppac/feature/keyword_collection/navigation/KeywordCollectionNavigation.kt @@ -1,4 +1,4 @@ -package team.ppac.search.detail.navigation +package team.ppac.feature.keyword_collection.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder @@ -6,7 +6,7 @@ import androidx.navigation.NavType import androidx.navigation.compose.composable import androidx.navigation.navArgument import team.ppac.analytics.AnalyticsHelper -import team.ppac.search.detail.KeywordCollectionRoute +import team.ppac.feature.keyword_collection.KeywordCollectionRoute const val KEYWORD_COLLECTION_ROUTE = "keyword_collection" diff --git a/feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt b/feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt deleted file mode 100644 index f3cf939e..00000000 --- a/feature/search/src/main/java/team/ppac/search/detail/component/KeywordCollectionLoadingContent.kt +++ /dev/null @@ -1,91 +0,0 @@ -package team.ppac.search.detail.component - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import team.ppac.common.android.util.showSkeleton -import team.ppac.designsystem.foundation.FarmemeRadius - -@Composable -internal fun KeywordCollectionLoadingContent( - modifier: Modifier = Modifier, - isLoading: Boolean, -) { - Column( - modifier = modifier - ) { - Spacer(modifier = Modifier.size(20.dp)) - Box( - modifier = Modifier - .width(100.dp) - .height(18.dp) - .padding(start = 20.dp) - .clip(FarmemeRadius.Radius4.shape) - .showSkeleton(isLoading = isLoading) - ) - Spacer(modifier = Modifier.size(20.dp)) - Row( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp), - horizontalArrangement = Arrangement.spacedBy(12.dp) - ) { - repeat(2) { - Column( - modifier = Modifier.weight(1f) - ) { - Box( - modifier = Modifier - .fillMaxWidth() - .height(210.dp) - .clip(RoundedCornerShape(16.dp)) - .showSkeleton(isLoading = isLoading) - ) - Spacer(modifier = Modifier.size(10.dp)) - Box( - modifier = Modifier - .fillMaxWidth() - .height(18.dp) - .clip(FarmemeRadius.Radius4.shape) - .showSkeleton(isLoading = isLoading) - ) - Spacer(modifier = Modifier.size(10.dp)) - Box( - modifier = Modifier - .width(80.dp) - .height(18.dp) - .clip(FarmemeRadius.Radius4.shape) - .showSkeleton(isLoading = isLoading) - ) - } - } - } - } -} - -@Preview -@Composable -private fun SearchDetailLoadingContentPreview() { - Box(modifier = Modifier.background(Color.White)) { - KeywordCollectionLoadingContent( - modifier = Modifier.fillMaxSize(), - isLoading = true - ) - } -} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index aaeb95da..6ff54ce0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -42,3 +42,4 @@ include(":feature:detail") include(":feature:setting") include(":feature:splash") include(":feature:register") +include(":feature:keyword-collection")