Skip to content

Commit

Permalink
chore(catalog): create a separate catalog and plyalist feature modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mcatta committed Oct 14, 2023
1 parent 056ba3f commit b346b51
Show file tree
Hide file tree
Showing 29 changed files with 238 additions and 70 deletions.
47 changes: 25 additions & 22 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies {

implementation(project(":domain"))
implementation(project(":data"))
implementation(project(":features:catalog:presentation"))
implementation(project(":features:player:presentation"))
implementation(project(":core:design"))
implementation(project(":core:di"))
Expand All @@ -60,11 +61,8 @@ dependencies {

implementation libs.bundles.androidx
implementation libs.bundles.compose
implementation libs.compose.accompanist.swipeToRefresh

implementation libs.polpetta

implementation libs.arrow
implementation libs.timber

implementation libs.firebase.analytics
Expand All @@ -74,8 +72,6 @@ dependencies {
implementation libs.hilt.android

testImplementation project(":core:testing")
testImplementation libs.mockk.core
testImplementation libs.roboeletric

androidTestImplementation libs.androidx.junit
androidTestImplementation libs.compose.test.uiJunit4
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/dev/marcocattaneo/sleep/ui/SleepApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import androidx.compose.ui.platform.LocalConfiguration
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.rememberNavController
import dev.marcocattaneo.core.design.theme.SleepTheme
import dev.marcocattaneo.sleep.ui.screen.Routes
import dev.marcocattaneo.sleep.catalog.presentation.Routes
import dev.marcocattaneo.sleep.player.presentation.screen.PlayerAction
import dev.marcocattaneo.sleep.player.presentation.screen.PlayerScreen
import dev.marcocattaneo.sleep.player.presentation.screen.PlayerViewModel
import dev.marcocattaneo.sleep.ui.screen.home.registerCatalogScreen
import dev.marcocattaneo.sleep.catalog.presentation.screen.registerCatalogScreen

@Composable
fun SleepApp() {
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@

<resources>
<string name="app_name">Sleepify</string>
<string name="home_header">Sleep tracks</string>
<string name="home_header_claim">The sound of silence</string>
<string name="home_info_banner">Welcome, to start the listening tap on the track below. If you want you can set an auto-stop after a set of minutes.</string>
</resources>
4 changes: 4 additions & 0 deletions core/navigation/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
alias libs.plugins.sleep.android.library
alias libs.plugins.sleep.android.compose
alias libs.plugins.sleep.detekt
}

Expand All @@ -10,4 +11,7 @@ android {
dependencies {
implementation(platform(libs.bom.compose))
implementation libs.bundles.compose

api libs.compose.navigation
api libs.compose.navigationHilt
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.lifecycle.ViewModel
import androidx.navigation.*
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import dev.marcocattaneo.navigation.routing.ScreenRoute

/**
* Navigation Component used for the routing
Expand All @@ -30,7 +31,7 @@ import androidx.navigation.compose.composable
*/
@Composable
fun NavigationComponent(
startRoute: dev.marcocattaneo.navigation.routing.ScreenRoute,
startRoute: ScreenRoute,
navHostController: NavHostController,
builder: NavGraphBuilder.() -> Unit
) {
Expand All @@ -47,7 +48,7 @@ fun NavigationComponent(
* @param content content associated to the route
*/
inline fun <reified VM : ViewModel> NavGraphBuilder.composable(
route: dev.marcocattaneo.navigation.routing.ScreenRoute,
route: ScreenRoute,
crossinline content: @Composable (NavBackStackEntry, VM) -> Unit
) {
this.composable(
Expand Down
54 changes: 54 additions & 0 deletions features/catalog/presentation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2022 Marco Cattaneo
*
* 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
*
* http://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.
*/

plugins {
alias libs.plugins.sleep.android.library
alias libs.plugins.sleep.android.compose
alias libs.plugins.sleep.jacoco
alias libs.plugins.sleep.detekt
}

android {
namespace 'dev.marcocattaneo.sleep.catalog.presentation'
}

dependencies {
implementation platform(libs.bom.compose)

implementation project(":core:di")
implementation project(":core:design")
implementation project(":core:utils")
implementation(project(":core:navigation"))
implementation project(":data")
implementation project(":domain")
implementation project(":features:playlist:presentation")

implementation libs.bundles.androidx
implementation libs.bundles.compose
implementation libs.arrow
implementation libs.compose.constraintLayout
implementation libs.compose.accompanist.swipeToRefresh
implementation libs.kotlin.stdlib
implementation libs.polpetta
implementation libs.hilt.android

testImplementation project(":core:testing")

androidTestImplementation libs.androidx.junit
androidTestImplementation libs.compose.test.uiJunit4

debugImplementation libs.bundles.compose.debug
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Marco Cattaneo
* Copyright 2023 Marco Cattaneo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep
package dev.marcocattaneo.sleep.catalog.presentation

import androidx.compose.runtime.Composable
import androidx.compose.ui.test.junit4.ComposeContentTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Marco Cattaneo
* Copyright 2023 Marco Cattaneo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,12 +14,12 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep.ui.composables
package dev.marcocattaneo.sleep.catalog.presentation.composables

import androidx.compose.material.Text
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.onNodeWithText
import dev.marcocattaneo.sleep.AbsComposableTest
import dev.marcocattaneo.sleep.catalog.presentation.AbsComposableTest
import org.junit.Test

internal class ComposableInfoBoxTest : AbsComposableTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep.ui.screen
package dev.marcocattaneo.sleep.catalog.presentation

import dev.marcocattaneo.navigation.routing.ScreenRoute

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep.ui.composables
package dev.marcocattaneo.sleep.catalog.presentation.composables

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Marco Cattaneo
* Copyright 2023 Marco Cattaneo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep.ui.composables
package dev.marcocattaneo.sleep.catalog.presentation.composables

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 Marco Cattaneo
* Copyright 2023 Marco Cattaneo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep.ui.screen.home
package dev.marcocattaneo.sleep.catalog.presentation.screen

import android.annotation.SuppressLint
import androidx.compose.foundation.clickable
Expand All @@ -36,21 +36,25 @@ import dev.marcocattaneo.core.design.composables.*
import dev.marcocattaneo.core.design.theme.Dimen
import dev.marcocattaneo.core.design.theme.placeholder
import dev.marcocattaneo.navigation.composable
import dev.marcocattaneo.sleep.R
import dev.marcocattaneo.sleep.catalog.presentation.Routes
import dev.marcocattaneo.sleep.catalog.presentation.composables.Illustration
import dev.marcocattaneo.sleep.catalog.presentation.composables.InfoBox
import dev.marcocattaneo.sleep.domain.model.MediaFileEntity
import dev.marcocattaneo.sleep.ui.composables.Illustration
import dev.marcocattaneo.sleep.ui.composables.InfoBox
import dev.marcocattaneo.sleep.ui.screen.Routes
import dev.marcocattaneo.sleep.catalog.presentation.R

/**
* Register the composable function into the NavGraphBuilder
* @param onClickMediaFile callback used when a media file is clicked
*/
fun NavGraphBuilder.registerCatalogScreen(onClickMediaFile: (MediaFileEntity) -> Unit) {
composable<HomeViewModel>(
composable<CatalogViewModel>(
route = Routes.Dashboard
) { _, vm -> HomeScreen(vm, onClickMediaFile = onClickMediaFile) }
) { _, vm -> CatalogScreen(vm, onClickMediaFile = onClickMediaFile) }
}

@Composable
fun HomeScreen(
homeViewModel: HomeViewModel,
fun CatalogScreen(
homeViewModel: CatalogViewModel,
onClickMediaFile: (MediaFileEntity) -> Unit
) {
val uiState by homeViewModel.rememberState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package dev.marcocattaneo.sleep.ui.screen.home
package dev.marcocattaneo.sleep.catalog.presentation.screen

import dagger.hilt.android.scopes.ViewModelScoped
import dev.marcocattaneo.sleep.core.di.scope.CoroutineContextScope
Expand Down
Loading

0 comments on commit b346b51

Please sign in to comment.