Skip to content

Commit

Permalink
WTA #71: Updated compose destinations to have multi module set-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob3075 committed Sep 9, 2023
1 parent 69d7265 commit eacade0
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 46 deletions.

This file was deleted.

23 changes: 23 additions & 0 deletions app/src/main/java/com/jacob/wakatimeapp/navigation/NavGraphs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.jacob.wakatimeapp.navigation

import com.jacob.wakatimeapp.details.ui.destinations.DetailsPageDestination
import com.jacob.wakatimeapp.home.ui.destinations.HomePageDestination
import com.jacob.wakatimeapp.login.ui.destinations.LoginPageDestination
import com.jacob.wakatimeapp.search.ui.destinations.SearchProjectsDestination
import com.ramcosta.composedestinations.spec.DestinationSpec
import com.ramcosta.composedestinations.spec.NavGraphSpec

object NavGraphs {
val root = object : NavGraphSpec {
override val route = "root"

override val startRoute = LoginPageDestination

override val destinationsByRoute = listOf<DestinationSpec<*>>(
LoginPageDestination,
HomePageDestination,
SearchProjectsDestination,
DetailsPageDestination,
).associateBy { it.route }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id "kotlin-android"
id "org.jetbrains.kotlin.kapt"
id "dagger.hilt.android.plugin"
id "com.google.devtools.ksp"

id "wakatimeapp.tooling"
}
Expand Down Expand Up @@ -72,7 +71,6 @@ dependencies {

// Navigation
implementation(libs.raamcosta.compose.destinations.core)
ksp(libs.raamcosta.compose.destinations.ksp)

// Hilt
implementation(libs.hilt.android)
Expand Down
17 changes: 17 additions & 0 deletions buildSrc/src/main/kotlin/wakatimeapp.android.feature.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ android {

buildFeatures { compose = true }
composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() }

// Compose Destination config (https://github.com/raamcosta/compose-destinations/issues/314)
libraryVariants.all { variant ->
kotlin.sourceSets {
getByName(variant.name) {
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
}
}
}
}

dependencies {
Expand All @@ -65,6 +74,10 @@ dependencies {
implementation(libs.bundles.compose.core)
debugImplementation(libs.bundles.compose.debug)

// Navigation
implementation(libs.raamcosta.compose.destinations.core)
ksp(libs.raamcosta.compose.destinations.ksp)

// Hilt
implementation(libs.hilt.android)
implementation(libs.hilt.navigation.compose)
Expand All @@ -85,3 +98,7 @@ dependencies {
kapt {
correctErrorTypes = true
}

ksp {
arg("compose-destinations.mode", "destinations")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import com.ramcosta.composedestinations.annotation.Destination

@Composable
fun DetailsPageScreen(
@Destination(navArgsDelegate = DetailsPageNavArgs::class)
fun DetailsPage(
navigator: DetailsPageNavigator,
modifier: Modifier = Modifier,
) = DetailsPageScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ import com.jacob.wakatimeapp.home.ui.components.OtherDailyStatsSection
import com.jacob.wakatimeapp.home.ui.components.RecentProjects
import com.jacob.wakatimeapp.home.ui.components.UserDetailsSection
import com.jacob.wakatimeapp.home.ui.components.WeeklyReport
import com.ramcosta.composedestinations.annotation.Destination
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.launch
import kotlinx.datetime.LocalDate

@Composable
fun HomePageScreen(
@Destination
fun HomePage(
navigator: HomePageNavigator,
snackbarHostState: SnackbarHostState,
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ import com.jacob.wakatimeapp.core.ui.theme.button
import com.jacob.wakatimeapp.core.ui.theme.gradients
import com.jacob.wakatimeapp.core.ui.theme.pageTitle
import com.jacob.wakatimeapp.core.ui.theme.spacing
import com.ramcosta.composedestinations.annotation.Destination
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

@Composable
fun LoginPageScreen(
@Destination
fun LoginPage(
loginPageNavigator: LoginPageNavigator,
snackbarHostState: SnackbarHostState,
modifier: Modifier = Modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import com.jacob.wakatimeapp.search.ui.SearchProjectsViewState.Loaded
import com.jacob.wakatimeapp.search.ui.SearchProjectsViewState.Loading
import com.jacob.wakatimeapp.search.ui.components.ProjectsList
import com.jacob.wakatimeapp.search.ui.components.SearchBar
import com.ramcosta.composedestinations.annotation.Destination

@Composable
fun SearchProjectsScreen(
@Destination
fun SearchProjects(
navigator: SearchProjectsNavigator,
modifier: Modifier = Modifier,
) = SearchProjectsScreen(
Expand Down

0 comments on commit eacade0

Please sign in to comment.