Skip to content

Commit

Permalink
✨ Kotlin/JS を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Nov 23, 2023
1 parent 345215b commit 0b511c9
Show file tree
Hide file tree
Showing 23 changed files with 92 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.koin.dsl.module

@Composable
fun NitoApp(
shouldKeepOnScreen: (Boolean) -> Unit,
shouldKeepOnScreen: (Boolean) -> Unit = {},
modifier: Modifier = Modifier,
) {
PreComposeApp {
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
43 changes: 21 additions & 22 deletions app/web/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
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()
binaries.executable()
}

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)
}
}
}
Expand All @@ -43,6 +45,3 @@ kotlin {
compose.experimental {
web.application {}
}

//tasks.getByPath("jsProcessResources").dependsOn("libresGenerateResources")

2 changes: 1 addition & 1 deletion app/web/src/jsMain/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Binary file added app/web/src/jsMain/resources/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion app/web/src/jsMain/resources/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>NITO</title>
Expand Down
4 changes: 4 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class FeaturePlugin : Plugin<Project> {
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class KmpComposePlugin : Plugin<Project> {
implementation(libs.library("precompose"))
}
}
getByName("androidMain").apply {
findByName("androidMain")?.apply {
dependencies {
implementation(libs.library("androidxActivityActivityCompose"))
}
Expand Down
17 changes: 17 additions & 0 deletions build-logic/src/main/kotlin/club/nito/primitive/KmpJsPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package club.nito.primitive

import org.gradle.api.Plugin
import org.gradle.api.Project

@Suppress("unused")
class KmpJsPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
kotlin {
js {
browser()
}
}
}
}
}
1 change: 1 addition & 0 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
1 change: 1 addition & 0 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
1 change: 1 addition & 0 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package club.nito.core.designsystem.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable

@Composable
Expand All @@ -8,4 +9,9 @@ public actual fun NitoTheme(
dynamicColor: Boolean,
content: @Composable () -> Unit,
) {
MaterialTheme(
colorScheme = if (useDarkTheme) DarkColorScheme else LightColorScheme,
typography = Typography,
content = content,
)
}
1 change: 1 addition & 0 deletions core/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
1 change: 1 addition & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
1 change: 1 addition & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
1 change: 1 addition & 0 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b511c9

Please sign in to comment.