diff --git a/build-logic/gradm/gradm.yml b/build-logic/gradm/gradm.yml index 407c9f5..75ddece 100644 --- a/build-logic/gradm/gradm.yml +++ b/build-logic/gradm/gradm.yml @@ -1,13 +1,20 @@ versions: + androidx: + activity: "1.9.0-beta01" + compose.multiplatform: "1.6.1" consensus: "0.9.0" gradle: "8.7" kotlin: "1.9.23" plugins: + android: "8.2.2" gradle.enterprise: "3.16.2" spotless: "6.25.0" repositories: + jetbrainsCompose: + url: "https://maven.pkg.jetbrains.space/public/p/compose/dev" omico: + google: mavenCentral: gradlePluginPortal: @@ -15,12 +22,22 @@ plugins: gradlePluginPortal: com.diffplug.spotless: ${versions.plugins.spotless} com.gradle.enterprise: ${versions.plugins.gradle.enterprise} + org.jetbrains.compose: ${versions.compose.multiplatform} omico: me.omico.consensus.api: ${versions.consensus} me.omico.consensus.git: ${versions.consensus} me.omico.consensus.spotless: ${versions.consensus} dependencies: + google: + androidx.activity: + activity-compose: + alias: androidx.activity.compose + version: ${versions.androidx.activity} + com.android.tools.build: + gradle: + alias: androidGradlePlugin + version: ${versions.plugins.android} mavenCentral: org.jetbrains.kotlin: kotlin-gradle-plugin: diff --git a/build-logic/project/build.gradle.kts b/build-logic/project/build.gradle.kts index ae100ff..7ac9d65 100644 --- a/build-logic/project/build.gradle.kts +++ b/build-logic/project/build.gradle.kts @@ -3,6 +3,7 @@ plugins { } dependencies { + implementation(androidGradlePlugin) implementation(com.diffplug.spotless) implementation(gradmGeneratedJar) implementation(kotlinGradlePlugin) @@ -10,4 +11,5 @@ dependencies { implementation(me.omico.consensus.dsl) implementation(me.omico.consensus.git) implementation(me.omico.consensus.spotless) + implementation(org.jetbrains.compose) } diff --git a/gpi/android/.gitignore b/gpi/android/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/gpi/android/.gitignore @@ -0,0 +1 @@ +/build diff --git a/gpi/android/build.gradle.kts b/gpi/android/build.gradle.kts new file mode 100644 index 0000000..7a19953 --- /dev/null +++ b/gpi/android/build.gradle.kts @@ -0,0 +1,31 @@ +plugins { + kotlin("android") + id("com.android.application") +} + +kotlin { + jvmToolchain(11) +} + +android { + namespace = "me.omico.gpi.android" + defaultConfig { + compileSdk = 34 + targetSdk = 34 + minSdk = 21 + } + buildFeatures { + compose = true + } + kotlinOptions { + jvmTarget = "11" + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.11" + } +} + +dependencies { + implementation(project(":gpi-shared")) + implementation(androidx.activity.compose) +} diff --git a/gpi/android/src/main/AndroidManifest.xml b/gpi/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..0aa8d18 --- /dev/null +++ b/gpi/android/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/gpi/android/src/main/kotlin/me/omico/gpi/android/MainActivity.kt b/gpi/android/src/main/kotlin/me/omico/gpi/android/MainActivity.kt new file mode 100644 index 0000000..ab4e99a --- /dev/null +++ b/gpi/android/src/main/kotlin/me/omico/gpi/android/MainActivity.kt @@ -0,0 +1,15 @@ +package me.omico.gpi.android + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import me.omico.gpi.shared.App + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContent { + App() + } + } +} diff --git a/gpi/desktop/.gitignore b/gpi/desktop/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/gpi/desktop/.gitignore @@ -0,0 +1 @@ +/build diff --git a/gpi/desktop/build.gradle.kts b/gpi/desktop/build.gradle.kts new file mode 100644 index 0000000..24dae35 --- /dev/null +++ b/gpi/desktop/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + kotlin("jvm") + id("org.jetbrains.compose") +} + +compose { + desktop { + application { + mainClass = "me.omico.gpi.desktop.DesktopKt" + } + } +} + +dependencies { + implementation(project(":gpi-shared")) + implementation(compose.desktop.currentOs) +} diff --git a/gpi/desktop/src/main/kotlin/me/omico/gpi/desktop/Desktop.kt b/gpi/desktop/src/main/kotlin/me/omico/gpi/desktop/Desktop.kt new file mode 100644 index 0000000..2df3c67 --- /dev/null +++ b/gpi/desktop/src/main/kotlin/me/omico/gpi/desktop/Desktop.kt @@ -0,0 +1,10 @@ +package me.omico.gpi.desktop + +import androidx.compose.ui.window.singleWindowApplication +import me.omico.gpi.shared.App + +fun main() { + singleWindowApplication { + App() + } +} diff --git a/gpi/shared/.gitignore b/gpi/shared/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/gpi/shared/.gitignore @@ -0,0 +1 @@ +/build diff --git a/gpi/shared/build.gradle.kts b/gpi/shared/build.gradle.kts new file mode 100644 index 0000000..fb23081 --- /dev/null +++ b/gpi/shared/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + kotlin("multiplatform") + id("org.jetbrains.compose") + id("com.android.library") +} + +kotlin { + androidTarget { + jvmToolchain(11) + } + + jvm("desktop") + + sourceSets { + commonMain { + dependencies { + implementation(compose.material3) + } + } + } +} + +android { + namespace = "me.omico.gpi.shared" + defaultConfig { + compileSdk = 34 + minSdk = 21 + } +} diff --git a/gpi/shared/src/androidMain/kotlin/me/omico/gpi/shared/App.android.kt b/gpi/shared/src/androidMain/kotlin/me/omico/gpi/shared/App.android.kt new file mode 100644 index 0000000..1723a03 --- /dev/null +++ b/gpi/shared/src/androidMain/kotlin/me/omico/gpi/shared/App.android.kt @@ -0,0 +1,9 @@ +package me.omico.gpi.shared + +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily + +actual val FontFamily_IndieFlower: FontFamily = + FontFamily( + Font(resId = R.font.indie_flower_regular), + ) diff --git a/gpi/shared/src/androidMain/res/font/indie_flower_regular.ttf b/gpi/shared/src/androidMain/res/font/indie_flower_regular.ttf new file mode 100644 index 0000000..87d7dee Binary files /dev/null and b/gpi/shared/src/androidMain/res/font/indie_flower_regular.ttf differ diff --git a/gpi/shared/src/commonMain/kotlin/me/omico/gpi/shared/App.kt b/gpi/shared/src/commonMain/kotlin/me/omico/gpi/shared/App.kt new file mode 100644 index 0000000..279d81b --- /dev/null +++ b/gpi/shared/src/commonMain/kotlin/me/omico/gpi/shared/App.kt @@ -0,0 +1,66 @@ +package me.omico.gpi.shared + +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.width +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +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.Modifier +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.unit.dp + +@Composable +fun App() { + val defaultTypography = MaterialTheme.typography + val indieFlowerTypography = remember { + defaultTypography.copy( + displayLarge = defaultTypography.displayLarge.copy(fontFamily = FontFamily_IndieFlower), + displayMedium = defaultTypography.displayMedium.copy(fontFamily = FontFamily_IndieFlower), + displaySmall = defaultTypography.displaySmall.copy(fontFamily = FontFamily_IndieFlower), + headlineLarge = defaultTypography.headlineLarge.copy(fontFamily = FontFamily_IndieFlower), + headlineMedium = defaultTypography.headlineMedium.copy(fontFamily = FontFamily_IndieFlower), + headlineSmall = defaultTypography.headlineSmall.copy(fontFamily = FontFamily_IndieFlower), + titleLarge = defaultTypography.titleLarge.copy(fontFamily = FontFamily_IndieFlower), + titleMedium = defaultTypography.titleMedium.copy(fontFamily = FontFamily_IndieFlower), + titleSmall = defaultTypography.titleSmall.copy(fontFamily = FontFamily_IndieFlower), + bodyLarge = defaultTypography.bodyLarge.copy(fontFamily = FontFamily_IndieFlower), + bodyMedium = defaultTypography.bodyMedium.copy(fontFamily = FontFamily_IndieFlower), + bodySmall = defaultTypography.bodySmall.copy(fontFamily = FontFamily_IndieFlower), + labelLarge = defaultTypography.labelLarge.copy(fontFamily = FontFamily_IndieFlower), + labelMedium = defaultTypography.labelMedium.copy(fontFamily = FontFamily_IndieFlower), + labelSmall = defaultTypography.labelSmall.copy(fontFamily = FontFamily_IndieFlower), + ) + } + + var currentTypography by remember { mutableStateOf(defaultTypography) } + MaterialTheme(typography = currentTypography) { + AlertDialog( + onDismissRequest = { }, + title = { Text("Select Typography") }, + text = { + Row { + Button( + onClick = { currentTypography = defaultTypography }, + content = { Text("Default") }, + ) + Spacer(modifier = Modifier.width(8.dp)) + Button( + onClick = { currentTypography = indieFlowerTypography }, + content = { Text("Indie Flower") }, + ) + } + }, + confirmButton = { }, + dismissButton = { }, + ) + } +} + +expect val FontFamily_IndieFlower: FontFamily diff --git a/gpi/shared/src/desktopMain/kotlin/me/omico/gpi/shared/App.desktop.kt b/gpi/shared/src/desktopMain/kotlin/me/omico/gpi/shared/App.desktop.kt new file mode 100644 index 0000000..fafd937 --- /dev/null +++ b/gpi/shared/src/desktopMain/kotlin/me/omico/gpi/shared/App.desktop.kt @@ -0,0 +1,9 @@ +package me.omico.gpi.shared + +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.platform.Font + +actual val FontFamily_IndieFlower: FontFamily = + FontFamily( + Font(resource = "font/indie_flower_regular.ttf"), + ) diff --git a/gpi/shared/src/desktopMain/resources/font/indie_flower_regular.ttf b/gpi/shared/src/desktopMain/resources/font/indie_flower_regular.ttf new file mode 100644 index 0000000..87d7dee Binary files /dev/null and b/gpi/shared/src/desktopMain/resources/font/indie_flower_regular.ttf differ diff --git a/gradle.properties b/gradle.properties index 8b0d30a..479f4fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,5 @@ +android.useAndroidX=true + org.gradle.caching=true org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC org.gradle.kotlin.dsl.allWarningsAsErrors=true