Initial commit

This commit is contained in:
2025-09-17 14:25:27 -03:00
parent 3332749ee0
commit e97df669a4
14 changed files with 91 additions and 28 deletions

14
.editorconfig Normal file
View File

@@ -0,0 +1,14 @@
[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_function_naming_ignore_when_annotated_with = Composable
ktlint_standard_filename = disabled
ktlint_standard_max-line-length = 140
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_backing-property-naming = disabled
ktlint_standard_function-naming = disabled
ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 5
[**/build/**]
generated_code = true
ij_formatter_enabled = false
ktlint = disabled

View File

@@ -4,4 +4,6 @@ plugins {
alias(libs.plugins.composeMultiplatform) apply false alias(libs.plugins.composeMultiplatform) apply false
alias(libs.plugins.composeCompiler) apply false alias(libs.plugins.composeCompiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false alias(libs.plugins.kotlinMultiplatform) apply false
} }
apply("checks.gradle.kts")

43
checks.gradle.kts Normal file
View File

@@ -0,0 +1,43 @@
tasks.register("ensureChecksPreCommitHook") {
group = "verification"
description = "Ensures that the Git pre-commit hook for ktlint is properly set up"
doLast {
val gitHooksDir = rootProject.file(".git/hooks")
val preCommitHookFile = gitHooksDir.resolve("pre-commit")
val requiredHookContent =
"""
#!/bin/sh
# https://github.com/pinterest/ktlint pre-commit hook
ktlint
""".trimIndent()
if (!gitHooksDir.exists()) {
logger.warn("Git hooks directory not found. Is this a Git repository?")
return@doLast
}
if (!preCommitHookFile.exists()) {
logger.lifecycle("Creating ktlint pre-commit hook")
preCommitHookFile.writeText(requiredHookContent)
preCommitHookFile.setExecutable(true)
} else {
val currentContent = preCommitHookFile.readText()
if (!currentContent.contains(requiredHookContent)) {
logger.lifecycle("Updating pre-commit hook with ktlint check")
preCommitHookFile.writeText(requiredHookContent)
preCommitHookFile.setExecutable(true)
} else {
logger.lifecycle("ktlint pre-commit hook is already properly configured")
}
}
}
}
gradle.projectsEvaluated {
tasks.matching { it.name != "ensureChecksPreCommitHook" }.configureEach {
dependsOn("ensureChecksPreCommitHook")
}
}

View File

@@ -14,17 +14,17 @@ kotlin {
jvmTarget.set(JvmTarget.JVM_11) jvmTarget.set(JvmTarget.JVM_11)
} }
} }
listOf( listOf(
iosArm64(), iosArm64(),
iosSimulatorArm64() iosSimulatorArm64(),
).forEach { iosTarget -> ).forEach { iosTarget ->
iosTarget.binaries.framework { iosTarget.binaries.framework {
baseName = "ComposeApp" baseName = "ComposeApp"
isStatic = true isStatic = true
} }
} }
sourceSets { sourceSets {
androidMain.dependencies { androidMain.dependencies {
implementation(compose.preview) implementation(compose.preview)
@@ -48,12 +48,18 @@ kotlin {
android { android {
namespace = "dev.carlosmartino.triplogic" namespace = "dev.carlosmartino.triplogic"
compileSdk = libs.versions.android.compileSdk.get().toInt() compileSdk = libs.versions.android.compileSdk
.get()
.toInt()
defaultConfig { defaultConfig {
applicationId = "dev.carlosmartino.triplogic" applicationId = "dev.carlosmartino.triplogic"
minSdk = libs.versions.android.minSdk.get().toInt() minSdk = libs.versions.android.minSdk
targetSdk = libs.versions.android.targetSdk.get().toInt() .get()
.toInt()
targetSdk = libs.versions.android.targetSdk
.get()
.toInt()
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@@ -76,4 +82,3 @@ android {
dependencies { dependencies {
debugImplementation(compose.uiTooling) debugImplementation(compose.uiTooling)
} }

View File

@@ -22,4 +22,4 @@ class MainActivity : ComponentActivity() {
@Composable @Composable
fun AppAndroidPreview() { fun AppAndroidPreview() {
App() App()
} }

View File

@@ -6,4 +6,4 @@ class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}" override val name: String = "Android ${Build.VERSION.SDK_INT}"
} }
actual fun getPlatform(): Platform = AndroidPlatform() actual fun getPlatform(): Platform = AndroidPlatform()

View File

@@ -10,15 +10,16 @@ import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.* import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.ui.tooling.preview.Preview import org.jetbrains.compose.ui.tooling.preview.Preview
import triplogic.composeapp.generated.resources.Res
import triplogic.composeapp.generated.resources.compose_multiplatform
@Composable @Composable
@Preview @Preview
fun App() { fun App() {
@@ -40,10 +41,9 @@ fun App() {
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
) { ) {
Image(painterResource(Res.drawable.compose_multiplatform), null)
Text("Compose: $greeting") Text("Compose: $greeting")
} }
} }
} }
} }
} }

View File

@@ -3,7 +3,5 @@ package dev.carlosmartino.triplogic
class Greeting { class Greeting {
private val platform = getPlatform() private val platform = getPlatform()
fun greet(): String { fun greet(): String = "Hello, ${platform.name}!"
return "Hello, ${platform.name}!" }
}
}

View File

@@ -4,4 +4,4 @@ interface Platform {
val name: String val name: String
} }
expect fun getPlatform(): Platform expect fun getPlatform(): Platform

View File

@@ -4,9 +4,8 @@ import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
class ComposeAppCommonTest { class ComposeAppCommonTest {
@Test @Test
fun example() { fun example() {
assertEquals(3, 1 + 2) assertEquals(3, 1 + 2)
} }
} }

View File

@@ -2,4 +2,4 @@ package dev.carlosmartino.triplogic
import androidx.compose.ui.window.ComposeUIViewController import androidx.compose.ui.window.ComposeUIViewController
fun MainViewController() = ComposeUIViewController { App() } fun MainViewController() = ComposeUIViewController { App() }

View File

@@ -2,8 +2,8 @@ package dev.carlosmartino.triplogic
import platform.UIKit.UIDevice import platform.UIKit.UIDevice
class IOSPlatform: Platform { class IOSPlatform : Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
} }
actual fun getPlatform(): Platform = IOSPlatform() actual fun getPlatform(): Platform = IOSPlatform()

View File

@@ -1,6 +1,8 @@
#Kotlin #Kotlin
kotlin.code.style=official kotlin.code.style=official
kotlin.daemon.jvmargs=-Xmx3072M kotlin.daemon.jvmargs=-Xmx4096M
kotlin.native.ignoreDisabledTargets=true
kotlin.mpp.enableCInteropCommonization=true
#Gradle #Gradle
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8

View File

@@ -28,4 +28,4 @@ dependencyResolutionManagement {
} }
} }
include(":composeApp") include(":composeApp")