Skip to content

Commit

Permalink
Split :feature:detail module to api and impl
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Nov 9, 2024
1 parent 59335b7 commit 7a6968b
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 19 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/java/soup/movie/ui/main/MainNavGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -72,10 +70,8 @@ fun MainNavGraph(
route = Screen.Detail.route + "/{movieId}",
arguments = listOf(navArgument("movieId") { nullable = false }),
) {
val viewModel = hiltViewModel<DetailViewModel>()
DetailNavGraph(
viewModel = viewModel,
)
val factory = rememberDetailComposableFactory()
factory.DetailNavGraph()
}
}
}
File renamed without changes.
19 changes: 19 additions & 0 deletions feature/detail/api/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions feature/detail/impl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

android {
namespace "soup.movie.feature.detail"
namespace "soup.movie.feature.detail.impl"
}

dependencies {
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions feature/detail/impl/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest />
Original file line number Diff line number Diff line change
@@ -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(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 7a6968b

Please sign in to comment.