Skip to content
Open
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
35 changes: 13 additions & 22 deletions apps/mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -161,39 +161,30 @@ fun properties(propertiesFileName: String): Properties {
}

dependencies {
// Base AndroidX libraries bundle.
implementation(libs.bundles.androidx.base)
// Use Compose BOM for consistent Compose library versions.
implementation(platform(libs.androidx.compose.bom))
// Jetpack Compose libraries bundle.
implementation(libs.bundles.compose)
// Material 3 design components.
implementation(libs.material3)
// AndroidX Navigation libraries bundle.
implementation(libs.bundles.androidx.navigation)
// Dagger Hilt for dependency injection.
implementation(libs.hilt)
// Timber for logging.
implementation(libs.timber)
// Project modules.
implementation(project(":libraries:design:mobile"))
implementation(project(":libraries:architecture:presentation:mobile"))
implementation(project(":libraries:authentication:domain"))
implementation(project(":libraries:design:mobile"))
implementation(project(":libraries:smokes:domain"))
implementation(project(":features:authentication:presentation:mobile"))
implementation(project(":features:chatbot:presentation"))
implementation(project(":features:chatbot:domain"))
implementation(project(":features:history:presentation:mobile"))
implementation(project(":features:home:presentation:mobile"))
implementation(project(":features:home:domain"))
implementation(project(":features:settings:presentation:mobile"))
implementation(project(":features:stats:presentation:mobile"))
implementation(project(":features:chatbot:presentation"))
implementation(project(":features:chatbot:domain"))
// Hilt annotation processor.
kapt(libs.hilt.compiler)
// Include devtools module only in debug builds.
implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.androidx.base)
implementation(libs.bundles.compose)
implementation(libs.material3)
implementation(libs.bundles.androidx.navigation)
implementation(libs.hilt)
implementation(libs.timber)
implementation(libs.animated.navigation.bar)

debugImplementation(project(":features:devtools:presentation"))

implementation(libs.animated.navigation.bar)
kapt(libs.hilt.compiler)
}

// Task to print the current version name to the console.
Expand Down
9 changes: 5 additions & 4 deletions apps/wear/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,23 @@ fun properties(propertiesFileName: String): Properties {
dependencies {
implementation(project(":libraries:architecture:presentation:mobile"))
implementation(project(":libraries:architecture:common"))
implementation(project(":libraries:design:mobile"))
implementation(project(":libraries:smokes:data:mobile"))
implementation(project(":libraries:wear:domain"))
implementation(project(":libraries:wear:data"))
implementation(project(":libraries:smokes:data:mobile"))
implementation(libs.bundles.androidx.base)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.androidx.base)
implementation(libs.bundles.compose)
implementation(libs.hilt)
implementation(libs.timber)
implementation(project(":libraries:design:mobile"))
implementation(libs.androidx.tiles)
implementation(libs.horologist.composables)
implementation(libs.horologist.tiles)
implementation(libs.horologist.compose.tools)
implementation(libs.androidx.protolayout.material)
implementation(libs.androidx.protolayout.core)
kapt(libs.hilt.compiler)
implementation(libs.play.services.wearable)
implementation(libs.androidx.tiles.material)

kapt(libs.hilt.compiler)
}
23 changes: 11 additions & 12 deletions apps/web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,22 @@ kotlin {
sourceSets {
val jsMain by getting {
dependencies {
implementation(compose.runtime)
implementation(compose.html.core)
implementation(libs.kotlinx.coroutines.core)

implementation(project(":libraries:architecture:domain"))
implementation(project(":features:home:domain"))
implementation(project(":features:home:presentation:web"))
implementation(project(":features:history:presentation:web"))
implementation(project(":features:authentication:presentation:web"))
implementation(project(":features:stats:presentation:web"))
implementation(project(":features:settings:presentation:web"))
implementation(project(":libraries:smokes:domain"))
implementation(project(":libraries:smokes:data:web"))
implementation(project(":libraries:authentication:domain"))
implementation(project(":libraries:authentication:data:web"))
implementation(project(":libraries:design:web"))
implementation(project(":libraries:smokes:domain"))
implementation(project(":libraries:smokes:data:web"))
implementation(project(":features:authentication:presentation:web"))
implementation(project(":features:history:presentation:web"))
implementation(project(":features:home:domain"))
implementation(project(":features:home:presentation:web"))
implementation(project(":features:settings:presentation:web"))
implementation(project(":features:stats:presentation:web"))

implementation(compose.runtime)
implementation(compose.html.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.gitlive.firebase.auth)
implementation(libs.firebase.app)
}
Expand Down
77 changes: 37 additions & 40 deletions apps/web/src/jsMain/kotlin/com/feragusper/smokeanalytics/AppRoot.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.feragusper.smokeanalytics

import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -16,6 +17,8 @@ import com.feragusper.smokeanalytics.features.settings.presentation.web.Settings
import com.feragusper.smokeanalytics.features.settings.presentation.web.createSettingsWebDependencies
import com.feragusper.smokeanalytics.features.stats.presentation.web.StatsWebScreen
import com.feragusper.smokeanalytics.features.stats.presentation.web.createStatsWebDependencies
import kotlinx.browser.window
import org.w3c.dom.events.Event

/**
* The root composable for the web application.
Expand All @@ -24,13 +27,20 @@ import com.feragusper.smokeanalytics.features.stats.presentation.web.createStats
*/
@Composable
fun AppRoot(graph: WebAppGraph) {
var tab by remember { mutableStateOf(WebTab.Home) }
var route by remember { mutableStateOf(WebRoute.Tabs) }
var route by remember {
mutableStateOf(parseRouteFromHash(window.location.hash))
}

DisposableEffect(Unit) {
val handler: (Event) -> Unit = {
route = parseRouteFromHash(window.location.hash)
}
window.addEventListener("hashchange", handler)
onDispose { window.removeEventListener("hashchange", handler) }
}

val homeDeps = remember(graph) {
HomeWebDependencies(
homeProcessHolder = graph.homeProcessHolder,
)
HomeWebDependencies(homeProcessHolder = graph.homeProcessHolder)
}

val historyDeps = remember(graph) {
Expand All @@ -46,38 +56,35 @@ fun AppRoot(graph: WebAppGraph) {
}

when (route) {
WebRoute.Tabs -> {
WebRoute.Home, WebRoute.Stats, WebRoute.Settings -> {
WebScaffold(
tab = tab,
onTabSelected = { tab = it },
route = route,
onNavigate = ::navigateTo,
) {
when (tab) {
WebTab.Home -> HomeWebScreen(
when (route) {
WebRoute.Home -> HomeWebScreen(
deps = homeDeps,
onNavigateToHistory = { route = WebRoute.History },
onNavigateToHistory = { navigateTo(WebRoute.History) },
)

WebTab.Stats -> {
WebRoute.Stats -> {
val statsDeps = remember(graph) {
createStatsWebDependencies(
fetchSmokeStatsUseCase = graph.fetchSmokeStatsUseCase,
)
createStatsWebDependencies(fetchSmokeStatsUseCase = graph.fetchSmokeStatsUseCase)
}
StatsWebScreen(
deps = statsDeps
)
StatsWebScreen(deps = statsDeps)
}

WebTab.Settings -> {
WebRoute.Settings -> {
val settingsDeps = remember(graph) {
createSettingsWebDependencies(
fetchSessionUseCase = graph.fetchSessionUseCase,
signOutUseCase = graph.signOutUseCase,
)
}

SettingsWebScreen(deps = settingsDeps)
}

else -> Unit
}
}
}
Expand All @@ -87,39 +94,29 @@ fun AppRoot(graph: WebAppGraph) {
createAuthenticationWebDependencies(
fetchSessionUseCase = graph.fetchSessionUseCase,
signOutUseCase = graph.signOutUseCase,
signInWithGoogle = { /* no-op for now (handled by UI component) */ }
signInWithGoogle = { /* handled by UI component */ }
)
}


AuthenticationWebScreen(
deps = authDeps,
onLoggedIn = {
route = WebRoute.Tabs
tab = WebTab.Home
}
onLoggedIn = { navigateTo(WebRoute.Home) }
)
}

WebRoute.History -> {
HistoryWebScreen(
deps = historyDeps,
onNavigateUp = {
route = WebRoute.Tabs
tab = WebTab.Home
},
onNavigateToAuth = { route = WebRoute.Auth },
onNavigateUp = { navigateTo(WebRoute.Home) },
onNavigateToAuth = { navigateTo(WebRoute.Auth) },
)
}
}
}

/**
* The dependency graph for the web application.
*/
private enum class WebRoute { Tabs, Auth, History }

/**
* The tabs for the web application.
*/
enum class WebTab { Home, Stats, Settings }
private fun navigateTo(route: WebRoute) {
val target = route.toHash()
if (window.location.hash != target) {
window.location.hash = target
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.feragusper.smokeanalytics

sealed class WebRoute {
data object Home : WebRoute()
data object Stats : WebRoute()
data object Settings : WebRoute()
data object History : WebRoute()
data object Auth : WebRoute()
}

internal fun WebRoute.toHash(): String = when (this) {
WebRoute.Home -> "#/home"
WebRoute.Stats -> "#/stats"
WebRoute.Settings -> "#/settings"
WebRoute.History -> "#/history"
WebRoute.Auth -> "#/auth"
}

internal fun parseRouteFromHash(hash: String): WebRoute = when (hash.removePrefix("#")) {
"/stats" -> WebRoute.Stats
"/settings" -> WebRoute.Settings
"/history" -> WebRoute.History
"/auth" -> WebRoute.Auth
"/home", "/", "" -> WebRoute.Home
else -> WebRoute.Home
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,35 @@ import org.jetbrains.compose.web.dom.Text

@Composable
fun WebScaffold(
tab: WebTab,
onTabSelected: (WebTab) -> Unit,
route: WebRoute,
onNavigate: (WebRoute) -> Unit,
content: @Composable () -> Unit,
) {
Div(attrs = { classes(SmokeWebStyles.shell) }) {
Div(attrs = { classes(SmokeWebStyles.sidebar) }) {
Div(attrs = { classes(SmokeWebStyles.sidebarTitle) }) { Text("Smoke Analytics") }

Div(attrs = { classes(SmokeWebStyles.navList) }) {
WebTab.entries.forEach { t ->
val items = listOf(
"Home" to WebRoute.Home,
"Stats" to WebRoute.Stats,
"Settings" to WebRoute.Settings,
)

items.forEach { (label, target) ->
Div(
attrs = {
classes(SmokeWebStyles.navItem)
if (t == tab) classes(SmokeWebStyles.navItemActive)
onClick { onTabSelected(t) }
if (route == target) classes(SmokeWebStyles.navItemActive)
onClick { onNavigate(target) }
}
) { Text(t.label()) }
) { Text(label) }
}
}
}

Div(attrs = { classes(SmokeWebStyles.main) }) {
Div(attrs = { classes(SmokeWebStyles.mainInner) }) {
content()
}
Div(attrs = { classes(SmokeWebStyles.mainInner) }) { content() }
}
}
}

private fun WebTab.label(): String = when (this) {
WebTab.Home -> "Home"
WebTab.Stats -> "Stats"
WebTab.Settings -> "Settings"
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildscript {
plugins {
// Google Services plugin is declared here but not applied by default.
// Apply it in the respective modules as needed.
id("com.google.gms.google-services") version "4.4.3" apply false
id("com.google.gms.google-services") version "4.4.4" apply false

// Apply the SonarQube plugin globally for static code analysis.
sonarqube
Expand Down
7 changes: 3 additions & 4 deletions features/authentication/presentation/web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ kotlin {
sourceSets {
val jsMain by getting {
dependencies {
implementation(libs.kotlinx.coroutines.core)
implementation(compose.runtime)
implementation(compose.html.core)

implementation(project(":libraries:authentication:domain"))
implementation(project(":libraries:authentication:data:web"))
implementation(project(":libraries:authentication:presentation:web"))

implementation(compose.runtime)
implementation(compose.html.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.gitlive.firebase.auth)
implementation(libs.firebase.app)
}
Expand Down
17 changes: 0 additions & 17 deletions features/chatbot/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,6 @@ kotlin {
}
}

val jvmMain by getting {
dependencies {
implementation(libs.javax.inject)
implementation(project(":libraries:smokes:domain"))
}
}

val jvmTest by getting {
dependencies {
implementation(libs.junit.jupiter.api)
implementation(libs.junit.jupiter.params)
runtimeOnly(libs.junit.jupiter.engine)
implementation(libs.kluent)
implementation(libs.coroutines.test)
implementation(libs.app.cash.turbine)
}
}
}
}

Expand Down
Loading