From 7a6968bc843688887031945b202509687f0212ec Mon Sep 17 00:00:00 2001 From: Sungyong An Date: Sat, 9 Nov 2024 21:58:10 +0900 Subject: [PATCH] Split :feature:detail module to api and impl --- app/build.gradle | 3 +- .../java/soup/movie/ui/main/MainNavGraph.kt | 10 ++--- feature/detail/{ => api}/.gitignore | 0 feature/detail/api/build.gradle | 19 ++++++++ .../{ => api}/src/main/AndroidManifest.xml | 0 .../feature/detail/DetailComposableFactory.kt | 45 +++++++++++++++++++ feature/detail/impl/.gitignore | 1 + feature/detail/{ => impl}/build.gradle | 3 +- .../detail/impl/src/main/AndroidManifest.xml | 1 + .../impl/DetailComposableFactoryImpl.kt | 31 +++++++++++++ .../feature/detail/impl}/DetailContent.kt | 2 +- .../movie/feature/detail/impl}/DetailError.kt | 2 +- .../feature/detail/impl}/DetailEventModel.kt | 2 +- .../feature/detail/impl}/DetailHeader.kt | 2 +- .../movie/feature/detail/impl}/DetailList.kt | 2 +- .../feature/detail/impl}/DetailNavGraph.kt | 2 +- .../feature/detail/impl}/DetailPoster.kt | 2 +- .../feature/detail/impl}/DetailScreen.kt | 2 +- .../feature/detail/impl}/DetailUiModel.kt | 2 +- .../feature/detail/impl}/DetailViewModel.kt | 2 +- .../detail/impl/di/FeatureDetailModule.kt | 33 ++++++++++++++ 21 files changed, 147 insertions(+), 19 deletions(-) rename feature/detail/{ => api}/.gitignore (100%) create mode 100644 feature/detail/api/build.gradle rename feature/detail/{ => api}/src/main/AndroidManifest.xml (100%) create mode 100644 feature/detail/api/src/main/java/soup/movie/feature/detail/DetailComposableFactory.kt create mode 100644 feature/detail/impl/.gitignore rename feature/detail/{ => impl}/build.gradle (92%) create mode 100644 feature/detail/impl/src/main/AndroidManifest.xml create mode 100644 feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailComposableFactoryImpl.kt rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailContent.kt (98%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailError.kt (98%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailEventModel.kt (95%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailHeader.kt (99%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailList.kt (99%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailNavGraph.kt (98%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailPoster.kt (98%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailScreen.kt (99%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailUiModel.kt (98%) rename feature/detail/{src/main/java/soup/movie/feature/detail => impl/src/main/java/soup/movie/feature/detail/impl}/DetailViewModel.kt (99%) create mode 100644 feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/di/FeatureDetailModule.kt diff --git a/app/build.gradle b/app/build.gradle index c64c2670e..99fc8c3b2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -86,7 +86,8 @@ dependencies { implementation projects.data.model implementation projects.feature.home.api runtimeOnly projects.feature.home.impl - implementation projects.feature.detail + implementation projects.feature.detail.api + runtimeOnly projects.feature.detail.impl implementation projects.feature.search.api runtimeOnly projects.feature.search.impl implementation projects.feature.settings.api diff --git a/app/src/main/java/soup/movie/ui/main/MainNavGraph.kt b/app/src/main/java/soup/movie/ui/main/MainNavGraph.kt index daeefe3e8..7a7e395a8 100644 --- a/app/src/main/java/soup/movie/ui/main/MainNavGraph.kt +++ b/app/src/main/java/soup/movie/ui/main/MainNavGraph.kt @@ -16,15 +16,13 @@ package soup.movie.ui.main import androidx.compose.runtime.Composable -import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import androidx.navigation.navArgument import soup.movie.core.designsystem.windowsizeclass.WindowWidthSizeClass -import soup.movie.feature.detail.DetailNavGraph -import soup.movie.feature.detail.DetailViewModel +import soup.movie.feature.detail.rememberDetailComposableFactory import soup.movie.feature.home.rememberHomeComposableFactory import soup.movie.feature.search.rememberSearchComposableFactory @@ -72,10 +70,8 @@ fun MainNavGraph( route = Screen.Detail.route + "/{movieId}", arguments = listOf(navArgument("movieId") { nullable = false }), ) { - val viewModel = hiltViewModel() - DetailNavGraph( - viewModel = viewModel, - ) + val factory = rememberDetailComposableFactory() + factory.DetailNavGraph() } } } diff --git a/feature/detail/.gitignore b/feature/detail/api/.gitignore similarity index 100% rename from feature/detail/.gitignore rename to feature/detail/api/.gitignore diff --git a/feature/detail/api/build.gradle b/feature/detail/api/build.gradle new file mode 100644 index 000000000..224a6ab97 --- /dev/null +++ b/feature/detail/api/build.gradle @@ -0,0 +1,19 @@ +plugins { + id "moop.android.library" + id "moop.android.compose" + id "moop.android.hilt" +} + +android { + namespace "soup.movie.feature.detail" +} + +dependencies { + implementation projects.core.kotlin + implementation projects.core.designsystem + implementation projects.core.resources + + implementation libs.kotlin.stdlib + + implementation libs.compose.foundation +} diff --git a/feature/detail/src/main/AndroidManifest.xml b/feature/detail/api/src/main/AndroidManifest.xml similarity index 100% rename from feature/detail/src/main/AndroidManifest.xml rename to feature/detail/api/src/main/AndroidManifest.xml diff --git a/feature/detail/api/src/main/java/soup/movie/feature/detail/DetailComposableFactory.kt b/feature/detail/api/src/main/java/soup/movie/feature/detail/DetailComposableFactory.kt new file mode 100644 index 000000000..a403c98c4 --- /dev/null +++ b/feature/detail/api/src/main/java/soup/movie/feature/detail/DetailComposableFactory.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2024 SOUP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package soup.movie.feature.detail + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.LocalContext +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.components.SingletonComponent + +interface DetailComposableFactory { + @Composable + fun DetailNavGraph() +} + +@Composable +fun rememberDetailComposableFactory(): DetailComposableFactory { + val context = LocalContext.current + return remember(context) { + EntryPointAccessors + .fromApplication(context, DetailComposableFactoryEntryPoint::class.java) + .detailComposableFactory() + } +} + +@EntryPoint +@InstallIn(SingletonComponent::class) +interface DetailComposableFactoryEntryPoint { + fun detailComposableFactory(): DetailComposableFactory +} diff --git a/feature/detail/impl/.gitignore b/feature/detail/impl/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/feature/detail/impl/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/detail/build.gradle b/feature/detail/impl/build.gradle similarity index 92% rename from feature/detail/build.gradle rename to feature/detail/impl/build.gradle index a839ff672..f259b8c39 100644 --- a/feature/detail/build.gradle +++ b/feature/detail/impl/build.gradle @@ -5,7 +5,7 @@ plugins { } android { - namespace "soup.movie.feature.detail" + namespace "soup.movie.feature.detail.impl" } dependencies { @@ -19,6 +19,7 @@ dependencies { implementation projects.data.model implementation projects.domain implementation projects.feature.home.api + implementation projects.feature.detail.api implementation libs.kotlin.stdlib diff --git a/feature/detail/impl/src/main/AndroidManifest.xml b/feature/detail/impl/src/main/AndroidManifest.xml new file mode 100644 index 000000000..cc947c567 --- /dev/null +++ b/feature/detail/impl/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailComposableFactoryImpl.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailComposableFactoryImpl.kt new file mode 100644 index 000000000..33383bf4f --- /dev/null +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailComposableFactoryImpl.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2024 SOUP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package soup.movie.feature.detail.impl + +import androidx.compose.runtime.Composable +import androidx.hilt.navigation.compose.hiltViewModel +import soup.movie.feature.detail.DetailComposableFactory +import javax.inject.Inject + +class DetailComposableFactoryImpl @Inject constructor() : DetailComposableFactory { + + @Composable + override fun DetailNavGraph() { + DetailNavGraph( + viewModel = hiltViewModel(), + ) + } +} diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailContent.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailContent.kt similarity index 98% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailContent.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailContent.kt index 6a8e6b554..cf442ffad 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailContent.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailContent.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailError.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailError.kt similarity index 98% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailError.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailError.kt index 30edd2bae..096df5efb 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailError.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailError.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailEventModel.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailEventModel.kt similarity index 95% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailEventModel.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailEventModel.kt index 2cec1ddac..1fce56abe 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailEventModel.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailEventModel.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.annotation.Keep import androidx.annotation.StringRes diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailHeader.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailHeader.kt similarity index 99% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailHeader.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailHeader.kt index 1a618d15d..4372fcc91 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailHeader.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailHeader.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi import androidx.compose.animation.graphics.res.animatedVectorResource diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailList.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailList.kt similarity index 99% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailList.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailList.kt index a152704f0..b2737554b 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailList.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailList.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.compose.animation.animateContentSize import androidx.compose.animation.core.tween diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailNavGraph.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailNavGraph.kt similarity index 98% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailNavGraph.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailNavGraph.kt index ecfe21e39..803602691 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailNavGraph.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailNavGraph.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailPoster.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailPoster.kt similarity index 98% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailPoster.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailPoster.kt index 420b4dafc..287b8083d 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailPoster.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailPoster.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.activity.compose.BackHandler import androidx.compose.foundation.background diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailScreen.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailScreen.kt similarity index 99% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailScreen.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailScreen.kt index de1072616..c03fd9375 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailScreen.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailScreen.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailUiModel.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailUiModel.kt similarity index 98% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailUiModel.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailUiModel.kt index 40382de96..06f363470 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailUiModel.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailUiModel.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.annotation.Keep import soup.movie.model.CompanyModel diff --git a/feature/detail/src/main/java/soup/movie/feature/detail/DetailViewModel.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailViewModel.kt similarity index 99% rename from feature/detail/src/main/java/soup/movie/feature/detail/DetailViewModel.kt rename to feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailViewModel.kt index ea1a2ed0f..ecc010f39 100644 --- a/feature/detail/src/main/java/soup/movie/feature/detail/DetailViewModel.kt +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/DetailViewModel.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package soup.movie.feature.detail +package soup.movie.feature.detail.impl import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel diff --git a/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/di/FeatureDetailModule.kt b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/di/FeatureDetailModule.kt new file mode 100644 index 000000000..39a7623b2 --- /dev/null +++ b/feature/detail/impl/src/main/java/soup/movie/feature/detail/impl/di/FeatureDetailModule.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2024 SOUP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package soup.movie.feature.detail.impl.di + +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import soup.movie.feature.detail.DetailComposableFactory +import soup.movie.feature.detail.impl.DetailComposableFactoryImpl + +@Module +@InstallIn(SingletonComponent::class) +interface FeatureDetailModule { + + @Binds + fun bindsDetailComposableFactoryImpl( + impl: DetailComposableFactoryImpl, + ): DetailComposableFactory +}