chore(frontend): refactor navigation and DI setup, remove unused shared module

- Replaced `initKoin` with `startKoin` for DI initialization consistency across platforms.
- Introduced `StateNavigationPort` with `StateFlow` to streamline navigation state management.
- Migrated `AppScreen` to sealed class with route mapping for better navigation handling.
- Deleted unused `frontend/shared` module and removed related dependencies from build files.
- Cleaned up legacy navigation and Redux-related code, aligning with MVVM architecture.
This commit is contained in:
2026-02-01 13:46:39 +01:00
parent 77c20bf2ba
commit f78563f8c8
41 changed files with 186 additions and 187 deletions
+3 -3
View File
@@ -26,12 +26,12 @@ kotlin {
// UI Kit (Design System)
implementation(projects.frontend.core.designSystem)
// Shared Konfig & Utilities
implementation(projects.frontend.shared)
// Network core (provides apiClient + TokenProvider interface)
implementation(projects.frontend.core.network)
// Domain core (provides AppConstants)
implementation(projects.frontend.core.domain)
// Compose dependencies
implementation(compose.runtime)
implementation(compose.foundation)
@@ -1,11 +1,12 @@
package at.mocode.frontend.core.auth.data
import at.mocode.shared.core.AppConstants
import at.mocode.frontend.core.domain.AppConstants
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.request.forms.*
import io.ktor.client.statement.*
import io.ktor.http.*
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@@ -68,7 +69,7 @@ class AuthApiClient(
val kc = response.body<KeycloakTokenResponse>()
LoginResponse(
success = true,
token = kc.access_token,
token = kc.accessToken,
message = null,
userId = null,
username = username
@@ -112,7 +113,7 @@ class AuthApiClient(
val kc = response.body<KeycloakTokenResponse>()
LoginResponse(
success = true,
token = kc.access_token,
token = kc.accessToken,
message = null
)
} else {
@@ -132,13 +133,13 @@ class AuthApiClient(
@Serializable
private data class KeycloakTokenResponse(
val access_token: String,
val expires_in: Long? = null,
val refresh_expires_in: Long? = null,
val refresh_token: String? = null,
val token_type: String? = null,
val not_before_policy: Long? = null,
val session_state: String? = null,
val scope: String? = null
@SerialName("access_token") val accessToken: String,
@SerialName("expires_in") val expiresIn: Long? = null,
@SerialName("refresh_expires_in") val refreshExpiresIn: Long? = null,
@SerialName("refresh_token") val refreshToken: String? = null,
@SerialName("token_type") val tokenType: String? = null,
@SerialName("not_before_policy") val notBeforePolicy: Long? = null,
@SerialName("session_state") val sessionState: String? = null,
@SerialName("scope") val scope: String? = null
)
}
@@ -4,7 +4,7 @@ import at.mocode.frontend.core.auth.data.AuthApiClient
import at.mocode.frontend.core.auth.data.AuthTokenManager
import at.mocode.frontend.core.auth.presentation.LoginViewModel
import at.mocode.frontend.core.network.TokenProvider
import at.mocode.shared.core.AppConstants
import at.mocode.frontend.core.domain.AppConstants
import org.koin.core.qualifier.named
import org.koin.dsl.module
@@ -24,8 +24,6 @@ kotlin {
sourceSets {
commonMain.dependencies {
// Shared module dependency
implementation(projects.frontend.shared)
// Compose dependencies
implementation(compose.runtime)
@@ -0,0 +1,11 @@
package at.mocode.frontend.core.domain
object AppConstants {
// Keycloak Configuration
// Note: These defaults are for local development.
// In production, these should be provided via build config or environment variables.
const val KEYCLOAK_URL = "http://localhost:8180"
const val KEYCLOAK_REALM = "meldestelle"
const val KEYCLOAK_CLIENT_ID = "web-app"
const val KEYCLOAK_CLIENT_SECRET = "" // Public client usually has no secret
}
@@ -1,10 +0,0 @@
package at.mocode.clients.shared.navigation
sealed class AppScreen {
data object Landing : AppScreen()
data object Home : AppScreen()
data object Login : AppScreen()
data object Ping : AppScreen()
data object Profile : AppScreen()
data object AuthCallback : AppScreen()
}
@@ -0,0 +1,24 @@
package at.mocode.frontend.core.navigation
sealed class AppScreen(val route: String) {
data object Landing : AppScreen(Routes.HOME)
data object Home : AppScreen("/home")
data object Login : AppScreen(Routes.LOGIN)
data object Ping : AppScreen("/ping")
data object Profile : AppScreen("/profile")
data object AuthCallback : AppScreen("/auth/callback")
companion object {
fun fromRoute(route: String): AppScreen {
return when (route) {
Routes.HOME -> Landing
"/home" -> Home
Routes.LOGIN, Routes.Auth.LOGIN -> Login
"/ping" -> Ping
"/profile" -> Profile
"/auth/callback" -> AuthCallback
else -> Landing // Default fallback
}
}
}
}
@@ -28,7 +28,7 @@ class DeepLinkHandler(
private fun processDeepLink(deepLink: DeepLink): Boolean {
val route = cleanRoute(deepLink.route)
// If route requires auth and user is missing → redirect to login
// If the route requires auth and the user is missing → redirect to log in
if (requiresAuth(route)) {
val user = currentUserProvider.getCurrentUser()
if (user == null) {