Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split :feature:settings module to api and impl #303

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ dependencies {
implementation projects.feature.home
implementation projects.feature.detail
implementation projects.feature.search
implementation projects.feature.settings
implementation projects.feature.theme.api
runtimeOnly projects.feature.theme.impl
implementation projects.feature.settings.api
runtimeOnly projects.feature.settings.impl
implementation projects.feature.navigator.api
runtimeOnly projects.feature.navigator.impl
implementation projects.feature.notification.api
Expand Down
2 changes: 1 addition & 1 deletion feature/home/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
implementation projects.data.repository.api
implementation projects.data.model
implementation projects.domain
implementation projects.feature.settings
implementation projects.feature.settings.api

implementation libs.kotlin.stdlib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import soup.movie.core.designsystem.showToast
import soup.movie.core.designsystem.theme.MovieTheme
import soup.movie.core.designsystem.windowsizeclass.WindowWidthSizeClass
import soup.movie.feature.home.favorite.HomeFavoriteList
import soup.movie.feature.settings.SettingsNavGraph
import soup.movie.feature.settings.rememberSettingsComposableFactory
import soup.movie.model.MovieModel
import soup.movie.resources.R

Expand Down Expand Up @@ -94,7 +94,8 @@ fun MainScreen(
)
}
MainTabUiModel.Settings -> {
SettingsNavGraph()
val factory = rememberSettingsComposableFactory()
factory.SettingsScreen()
}
}
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

android {
namespace "soup.movie.feature.theme"
namespace "soup.movie.feature.settings"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 SOUP
* 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.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package soup.movie.feature.theme
package soup.movie.feature.settings

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
Expand All @@ -23,23 +23,22 @@ import dagger.hilt.InstallIn
import dagger.hilt.android.EntryPointAccessors
import dagger.hilt.components.SingletonComponent

interface ThemeEntry {
@Composable
fun ThemeOptionScreen()
interface SettingsComposableFactory {
@Composable fun SettingsScreen()
}

@Composable
fun rememberThemeEntry(): ThemeEntry {
fun rememberSettingsComposableFactory(): SettingsComposableFactory {
val context = LocalContext.current
return remember(context) {
EntryPointAccessors
.fromApplication(context, ThemeEntryPoint::class.java)
.providesThemeEntry()
.fromApplication(context, SettingsComposableFactoryEntryPoint::class.java)
.settingsComposableFactory()
}
}

@EntryPoint
@InstallIn(SingletonComponent::class)
internal interface ThemeEntryPoint {
fun providesThemeEntry(): ThemeEntry
interface SettingsComposableFactoryEntryPoint {
fun settingsComposableFactory(): SettingsComposableFactory
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

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

dependencies {
Expand All @@ -15,10 +15,11 @@ dependencies {
implementation projects.core.resources
implementation projects.data.settings.api
implementation projects.data.model
implementation projects.feature.theme.api
implementation projects.feature.settings.api

implementation libs.kotlin.stdlib

implementation libs.androidx.appcompat
implementation libs.androidx.hilt.navigation.compose
implementation libs.compose.foundation
implementation libs.compose.material
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 SOUP
* 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.
Expand All @@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package soup.movie.feature.theme.impl
package soup.movie.feature.settings.impl

import androidx.compose.runtime.Composable
import soup.movie.feature.theme.ThemeEntry
import soup.movie.feature.settings.SettingsComposableFactory
import javax.inject.Inject

class ThemeEntryImpl @Inject constructor() : ThemeEntry {
class SettingsComposableFactoryImpl @Inject constructor() : SettingsComposableFactory {

@Composable
override fun ThemeOptionScreen() {
ThemeOptionScreenImpl()
override fun SettingsScreen() {
SettingsNavGraph()
}
}
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.settings
package soup.movie.feature.settings.impl

import androidx.compose.runtime.Composable
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -22,8 +22,9 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import soup.compose.material.motion.animation.materialSharedAxisZIn
import soup.compose.material.motion.animation.materialSharedAxisZOut
import soup.movie.feature.theme.ThemeEntry
import soup.movie.feature.theme.rememberThemeEntry
import soup.movie.feature.settings.impl.home.SettingsScreen
import soup.movie.feature.settings.impl.home.SettingsViewModel
import soup.movie.feature.settings.impl.theme.ThemeOptionScreen

private enum class Screen(val route: String) {
Settings("SettingsScreen"),
Expand Down Expand Up @@ -51,8 +52,7 @@ fun SettingsNavGraph() {
)
}
composable(Screen.ThemeOption.route) {
val entry: ThemeEntry = rememberThemeEntry()
entry.ThemeOptionScreen()
ThemeOptionScreen()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2022 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.settings.impl.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import soup.movie.feature.settings.SettingsComposableFactory
import soup.movie.feature.settings.impl.SettingsComposableFactoryImpl

@Module
@InstallIn(SingletonComponent::class)
interface FeatureSettingsModule {

@Binds
fun bindsSettingsComposableFactory(
impl: SettingsComposableFactoryImpl,
): SettingsComposableFactory
}
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.theme.impl.di
package soup.movie.feature.settings.impl.di

import dagger.Binds
import dagger.Module
Expand All @@ -22,22 +22,15 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.coroutines.runBlocking
import soup.movie.data.settings.AppSettings
import soup.movie.feature.theme.ThemeEntry
import soup.movie.feature.settings.impl.theme.ThemeOptionManagerImpl
import soup.movie.feature.settings.impl.theme.ThemeOptionStore
import soup.movie.feature.theme.ThemeOptionManager
import soup.movie.feature.theme.impl.ThemeEntryImpl
import soup.movie.feature.theme.impl.ThemeOptionManagerImpl
import soup.movie.feature.theme.impl.ThemeOptionStore
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
interface FeatureThemeModule {

@Binds
fun bindsThemeEntry(
impl: ThemeEntryImpl,
): ThemeEntry

@Binds
@Singleton
fun bindsThemeOptionManager(
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.settings
package soup.movie.feature.settings.impl.home

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -47,7 +47,7 @@ import soup.movie.core.designsystem.UnelevatedButton
import soup.movie.core.designsystem.icon.MovieIcons
import soup.movie.core.designsystem.theme.MovieTheme
import soup.movie.core.designsystem.util.debounce
import soup.movie.feature.theme.stringResIdOf
import soup.movie.feature.settings.impl.theme.stringResIdOf
import soup.movie.resources.R

@Composable
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.settings
package soup.movie.feature.settings.impl.home

import androidx.annotation.Keep
import soup.movie.feature.theme.ThemeOption
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.settings
package soup.movie.feature.settings.impl.home

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
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.theme.impl
package soup.movie.feature.settings.impl.theme

import android.os.Build
import androidx.appcompat.app.AppCompatDelegate
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.theme.impl
package soup.movie.feature.settings.impl.theme

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -33,11 +33,10 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import soup.movie.core.designsystem.util.debounce
import soup.movie.feature.theme.stringResIdOf
import soup.movie.resources.R

@Composable
fun ThemeOptionScreenImpl() {
fun ThemeOptionScreen() {
val viewModel: ThemeOptionViewModel = hiltViewModel()
Scaffold(
topBar = {
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.theme.impl
package soup.movie.feature.settings.impl.theme

interface ThemeOptionStore {

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.theme.impl
package soup.movie.feature.settings.impl.theme

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package soup.movie.feature.theme
package soup.movie.feature.settings.impl.theme

import androidx.annotation.StringRes
import soup.movie.feature.theme.ThemeOption
import soup.movie.resources.R

@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.theme.impl
package soup.movie.feature.settings.impl.theme

import soup.movie.feature.theme.ThemeOption

Expand Down
1 change: 0 additions & 1 deletion feature/theme/impl/.gitignore

This file was deleted.

29 changes: 0 additions & 29 deletions feature/theme/impl/build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion feature/theme/impl/src/main/AndroidManifest.xml

This file was deleted.

Loading