diff --git a/app/shared/build.gradle.kts b/app/shared/build.gradle.kts index 22ffd6da..ada5d27b 100644 --- a/app/shared/build.gradle.kts +++ b/app/shared/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.kmp.compose") id("nito.primitive.detekt") } diff --git a/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoApp.kt b/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoApp.kt index 72671370..bb62f22e 100644 --- a/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoApp.kt +++ b/app/shared/src/commonMain/kotlin/club/nito/app/shared/NitoApp.kt @@ -24,7 +24,7 @@ import org.koin.dsl.module @Composable fun NitoApp( - shouldKeepOnScreen: (Boolean) -> Unit, + shouldKeepOnScreen: (Boolean) -> Unit = {}, modifier: Modifier = Modifier, ) { PreComposeApp { diff --git a/app/shared/src/jsMain/kotlin/club/nito/app/shared/di/NitoDateTimeFormatterModule.js.kt b/app/shared/src/jsMain/kotlin/club/nito/app/shared/di/NitoDateTimeFormatterModule.js.kt new file mode 100644 index 00000000..e3b8f72f --- /dev/null +++ b/app/shared/src/jsMain/kotlin/club/nito/app/shared/di/NitoDateTimeFormatterModule.js.kt @@ -0,0 +1,12 @@ +package club.nito.app.shared.di + +import club.nito.core.common.NitoDateTimeFormatter +import kotlinx.datetime.Instant + +actual fun createNitoDateTimeFormatter(): NitoDateTimeFormatter { + return object : NitoDateTimeFormatter { + override fun formatDateTimeString(instant: Instant): String { + return instant.toString() + } + } +} diff --git a/app/web/build.gradle.kts b/app/web/build.gradle.kts index 69fd7352..1c649223 100644 --- a/app/web/build.gradle.kts +++ b/app/web/build.gradle.kts @@ -1,11 +1,11 @@ plugins { id("nito.primitive.kmp") - alias(libs.plugins.composeGradlePlugin) + id("nito.primitive.kmp.js") + id("nito.primitive.kmp.compose") } -@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class) kotlin { - targetHierarchy.default() + applyDefaultHierarchyTemplate() js { browser() @@ -13,28 +13,30 @@ kotlin { } sourceSets { - val commonMain by getting { + val jsMain by getting { dependencies { + implementation(projects.app.shared) + + implementation(projects.core.common) + implementation(projects.core.model) + implementation(projects.core.data) + implementation(projects.core.network) + implementation(projects.core.domain) implementation(projects.core.designsystem) + implementation(projects.core.ui) - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material3) + implementation(projects.feature.top) + implementation(projects.feature.auth) + implementation(projects.feature.schedule) + implementation(projects.feature.settings) + + implementation(compose.html.core) implementation(compose.materialIconsExtended) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) - } - } - val commonTest by getting { - dependencies { -// implementation(kotlin("test")) - } - } + implementation(libs.precompose) + implementation(libs.kermit) - val jsMain by getting { - dependencies { - implementation(compose.html.core) + implementation(libs.koinCompose) } } } @@ -43,6 +45,3 @@ kotlin { compose.experimental { web.application {} } - -//tasks.getByPath("jsProcessResources").dependsOn("libresGenerateResources") - diff --git a/app/web/src/jsMain/kotlin/main.kt b/app/web/src/jsMain/kotlin/main.kt index 5f7fe9e0..4ec72215 100644 --- a/app/web/src/jsMain/kotlin/main.kt +++ b/app/web/src/jsMain/kotlin/main.kt @@ -1,6 +1,6 @@ import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.window.CanvasBasedWindow -import club.nito.web.NitoApp +import club.nito.app.shared.NitoApp import org.jetbrains.skiko.wasm.onWasmReady @OptIn(ExperimentalComposeUiApi::class) diff --git a/app/web/src/jsMain/resources/favicon.ico b/app/web/src/jsMain/resources/favicon.ico new file mode 100644 index 00000000..6951da4d Binary files /dev/null and b/app/web/src/jsMain/resources/favicon.ico differ diff --git a/app/web/src/jsMain/resources/index.html b/app/web/src/jsMain/resources/index.html index 7ccabd52..e86a04bc 100644 --- a/app/web/src/jsMain/resources/index.html +++ b/app/web/src/jsMain/resources/index.html @@ -1,5 +1,5 @@ - + NITO diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 995ec815..e8fe158e 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -54,6 +54,10 @@ gradlePlugin { id = "nito.primitive.kmp.android" implementationClass = "club.nito.primitive.KmpAndroidPlugin" } + register("kmpJs") { + id = "nito.primitive.kmp.js" + implementationClass = "club.nito.primitive.KmpJsPlugin" + } register("kmpCompose") { id = "nito.primitive.kmp.compose" implementationClass = "club.nito.primitive.KmpComposePlugin" diff --git a/build-logic/src/main/kotlin/club/nito/convention/FeaturePlugin.kt b/build-logic/src/main/kotlin/club/nito/convention/FeaturePlugin.kt index f35bf5ca..0c70a56b 100644 --- a/build-logic/src/main/kotlin/club/nito/convention/FeaturePlugin.kt +++ b/build-logic/src/main/kotlin/club/nito/convention/FeaturePlugin.kt @@ -12,6 +12,7 @@ class FeaturePlugin : Plugin { apply("nito.primitive.kmp") apply("nito.primitive.kmp.android") apply("nito.primitive.kmp.ios") + apply("nito.primitive.kmp.js") apply("nito.primitive.kmp.compose") apply("nito.primitive.detekt") apply("nito.primitive.kotest") diff --git a/build-logic/src/main/kotlin/club/nito/primitive/KmpComposePlugin.kt b/build-logic/src/main/kotlin/club/nito/primitive/KmpComposePlugin.kt index b2611dc9..98b434f4 100644 --- a/build-logic/src/main/kotlin/club/nito/primitive/KmpComposePlugin.kt +++ b/build-logic/src/main/kotlin/club/nito/primitive/KmpComposePlugin.kt @@ -25,7 +25,7 @@ class KmpComposePlugin : Plugin { implementation(libs.library("precompose")) } } - getByName("androidMain").apply { + findByName("androidMain")?.apply { dependencies { implementation(libs.library("androidxActivityActivityCompose")) } diff --git a/build-logic/src/main/kotlin/club/nito/primitive/KmpJsPlugin.kt b/build-logic/src/main/kotlin/club/nito/primitive/KmpJsPlugin.kt new file mode 100644 index 00000000..bedbbf47 --- /dev/null +++ b/build-logic/src/main/kotlin/club/nito/primitive/KmpJsPlugin.kt @@ -0,0 +1,17 @@ +package club.nito.primitive + +import org.gradle.api.Plugin +import org.gradle.api.Project + +@Suppress("unused") +class KmpJsPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + kotlin { + js { + browser() + } + } + } + } +} diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index bde04aa2..f622e401 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.detekt") } diff --git a/core/common/src/jsMain/kotlin/club/nito/core/common/RandomUUID.js.kt b/core/common/src/jsMain/kotlin/club/nito/core/common/RandomUUID.js.kt new file mode 100644 index 00000000..36e35c3f --- /dev/null +++ b/core/common/src/jsMain/kotlin/club/nito/core/common/RandomUUID.js.kt @@ -0,0 +1,8 @@ +package club.nito.core.common + +import kotlin.random.Random + +// Number of bytes in a UUID +internal const val UUID_BYTES = 16 + +public actual fun randomUUIDHash(): Int = Random.Default.nextBytes(UUID_BYTES).hashCode() diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 0c6877fd..e3df1b52 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.detekt") } diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index 75e737fd..4fe74253 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.detekt") } diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 413c7024..10b1dd07 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.kmp.compose") id("nito.primitive.detekt") } diff --git a/core/designsystem/src/jsMain/kotlin/club/nito/core/designsystem/theme/Theme.js.kt b/core/designsystem/src/jsMain/kotlin/club/nito/core/designsystem/theme/Theme.js.kt index dc35c899..7625ced1 100644 --- a/core/designsystem/src/jsMain/kotlin/club/nito/core/designsystem/theme/Theme.js.kt +++ b/core/designsystem/src/jsMain/kotlin/club/nito/core/designsystem/theme/Theme.js.kt @@ -1,5 +1,6 @@ package club.nito.core.designsystem.theme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable @Composable @@ -8,4 +9,9 @@ public actual fun NitoTheme( dynamicColor: Boolean, content: @Composable () -> Unit, ) { + MaterialTheme( + colorScheme = if (useDarkTheme) DarkColorScheme else LightColorScheme, + typography = Typography, + content = content, + ) } diff --git a/core/domain/build.gradle.kts b/core/domain/build.gradle.kts index b65accdf..99a0b011 100644 --- a/core/domain/build.gradle.kts +++ b/core/domain/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.detekt") } diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts index 4537fb51..6714da59 100644 --- a/core/model/build.gradle.kts +++ b/core/model/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.detekt") } diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index b8f287c3..8291fbd6 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.detekt") id("nito.primitive.kmp.serialization") } diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index f6b0893f..6d4fca16 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("nito.primitive.kmp") id("nito.primitive.kmp.android") id("nito.primitive.kmp.ios") + id("nito.primitive.kmp.js") id("nito.primitive.kmp.compose") id("nito.primitive.detekt") } diff --git a/core/ui/src/jsMain/kotlin/club/nito/core/ui/ProfileImage.js.kt b/core/ui/src/jsMain/kotlin/club/nito/core/ui/ProfileImage.js.kt new file mode 100644 index 00000000..d4616477 --- /dev/null +++ b/core/ui/src/jsMain/kotlin/club/nito/core/ui/ProfileImage.js.kt @@ -0,0 +1,9 @@ +package club.nito.core.ui + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import club.nito.core.model.UserProfile + +@Composable +public actual fun ProfileImage(profile: UserProfile, modifier: Modifier) { +} diff --git a/feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginScreen.kt b/feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginScreen.kt index 103aea80..5b3b13ec 100644 --- a/feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginScreen.kt +++ b/feature/auth/src/commonMain/kotlin/club/nito/feature/auth/LoginScreen.kt @@ -103,7 +103,7 @@ private fun LoginScreen( placeholder = { Text(text = "password") }, visualTransformation = PasswordVisualTransformation(), keyboardOptions = KeyboardOptions( - keyboardType = KeyboardType.Email, + keyboardType = KeyboardType.Password, imeAction = ImeAction.Done, ), singleLine = true,