commit f72938cffb54a642673d64aa5be36679501373d1 Author: FirephoenixX02 Date: Thu Apr 11 13:55:19 2024 +0200 initial commit diff --git a/.fleet/receipt.json b/.fleet/receipt.json new file mode 100644 index 0000000..3a17e28 --- /dev/null +++ b/.fleet/receipt.json @@ -0,0 +1,19 @@ +// Project generated by Kotlin Multiplatform Wizard +{ + "spec": { + "template_id": "kmt", + "targets": { + "android": { + "ui": [ + "compose" + ] + }, + "desktop": { + "ui": [ + "compose" + ] + } + } + }, + "timestamp": "2024-04-10T15:49:04.589746212Z" +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d0c8e67 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +This is a Kotlin Multiplatform project targeting Android, Desktop. + +* `/composeApp` is for code that will be shared across your Compose Multiplatform applications. + It contains several subfolders: + - `commonMain` is for code that’s common for all targets. + - Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name. + For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app, + `iosMain` would be the right folder for such calls. + + +Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)… \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..52cf9fa --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + // this is necessary to avoid the plugins to be loaded multiple times + // in each subproject's classloader + alias(libs.plugins.androidApplication) apply false + alias(libs.plugins.androidLibrary) apply false + alias(libs.plugins.jetbrainsCompose) apply false + alias(libs.plugins.kotlinMultiplatform) apply false +} \ No newline at end of file diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts new file mode 100644 index 0000000..5d17f78 --- /dev/null +++ b/composeApp/build.gradle.kts @@ -0,0 +1,92 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + alias(libs.plugins.kotlinMultiplatform) + alias(libs.plugins.androidApplication) + alias(libs.plugins.jetbrainsCompose) + +} + +kotlin { + androidTarget { + compilations.all { + kotlinOptions { + jvmTarget = "11" + } + } + } + + jvm("desktop") + + sourceSets { + val desktopMain by getting + + androidMain.dependencies { + implementation(libs.compose.ui.tooling.preview) + implementation(libs.androidx.activity.compose) + } + commonMain.dependencies { + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material) + implementation(compose.ui) + implementation(compose.components.resources) + implementation(compose.components.uiToolingPreview) + implementation(libs.kamel.image) + implementation(libs.ktor.client.okhttp) + implementation(libs.json) + } + desktopMain.dependencies { + implementation(compose.desktop.currentOs) + } + } +} + +android { + namespace = "me.firephoenix.pokedex" + compileSdk = libs.versions.android.compileSdk.get().toInt() + + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + sourceSets["main"].res.srcDirs("src/androidMain/res") + sourceSets["main"].resources.srcDirs("src/commonMain/resources") + + defaultConfig { + applicationId = "me.firephoenix.pokedex" + minSdk = libs.versions.android.minSdk.get().toInt() + targetSdk = libs.versions.android.targetSdk.get().toInt() + versionCode = 1 + versionName = "1.0" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + buildTypes { + getByName("release") { + isMinifyEnabled = false + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + dependencies { + debugImplementation(libs.compose.ui.tooling) + } +} +dependencies { + implementation(libs.androidx.media3.effect) +} + +compose.desktop { + application { + mainClass = "MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "me.firephoenix.pokedex" + packageVersion = "1.0.0" + } + } +} diff --git a/composeApp/src/androidMain/AndroidManifest.xml b/composeApp/src/androidMain/AndroidManifest.xml new file mode 100644 index 0000000..b87d944 --- /dev/null +++ b/composeApp/src/androidMain/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/composeApp/src/androidMain/kotlin/Platform.android.kt b/composeApp/src/androidMain/kotlin/Platform.android.kt new file mode 100644 index 0000000..4f3ea05 --- /dev/null +++ b/composeApp/src/androidMain/kotlin/Platform.android.kt @@ -0,0 +1,7 @@ +import android.os.Build + +class AndroidPlatform : Platform { + override val name: String = "Android ${Build.VERSION.SDK_INT}" +} + +actual fun getPlatform(): Platform = AndroidPlatform() \ No newline at end of file diff --git a/composeApp/src/androidMain/kotlin/me/firephoenix/pokedex/MainActivity.kt b/composeApp/src/androidMain/kotlin/me/firephoenix/pokedex/MainActivity.kt new file mode 100644 index 0000000..3db6aa0 --- /dev/null +++ b/composeApp/src/androidMain/kotlin/me/firephoenix/pokedex/MainActivity.kt @@ -0,0 +1,24 @@ +package me.firephoenix.pokedex + +import App +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.runtime.Composable +import androidx.compose.ui.tooling.preview.Preview + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContent { + App() + } + } +} + +@Preview +@Composable +fun AppAndroidPreview() { + App() +} \ No newline at end of file diff --git a/composeApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/composeApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/composeApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/androidMain/res/drawable/ic_launcher_background.xml b/composeApp/src/androidMain/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/composeApp/src/androidMain/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml b/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/composeApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png b/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png differ diff --git a/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png b/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png b/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png differ diff --git a/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png b/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png b/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png b/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png b/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png b/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png b/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png b/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c Binary files /dev/null and b/composeApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/composeApp/src/androidMain/res/values/strings.xml b/composeApp/src/androidMain/res/values/strings.xml new file mode 100644 index 0000000..391021f --- /dev/null +++ b/composeApp/src/androidMain/res/values/strings.xml @@ -0,0 +1,3 @@ + + PokeDex + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/bug.png b/composeApp/src/commonMain/composeResources/drawable/bug.png new file mode 100644 index 0000000..fc0456f Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/bug.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml b/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml new file mode 100644 index 0000000..d7bf795 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/compose-multiplatform.xml @@ -0,0 +1,36 @@ + + + + + + + + diff --git a/composeApp/src/commonMain/composeResources/drawable/dark.png b/composeApp/src/commonMain/composeResources/drawable/dark.png new file mode 100644 index 0000000..7429a09 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/dark.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/dragon.png b/composeApp/src/commonMain/composeResources/drawable/dragon.png new file mode 100644 index 0000000..0233d4d Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/dragon.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/electric.png b/composeApp/src/commonMain/composeResources/drawable/electric.png new file mode 100644 index 0000000..afbbff4 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/electric.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/fairy.png b/composeApp/src/commonMain/composeResources/drawable/fairy.png new file mode 100644 index 0000000..3ae3922 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/fairy.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/fighting.png b/composeApp/src/commonMain/composeResources/drawable/fighting.png new file mode 100644 index 0000000..a29203d Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/fighting.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/fire.png b/composeApp/src/commonMain/composeResources/drawable/fire.png new file mode 100644 index 0000000..d965ffa Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/fire.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/flying.png b/composeApp/src/commonMain/composeResources/drawable/flying.png new file mode 100644 index 0000000..6fb4b08 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/flying.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/ghost.png b/composeApp/src/commonMain/composeResources/drawable/ghost.png new file mode 100644 index 0000000..2b10d8d Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/ghost.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/grass.png b/composeApp/src/commonMain/composeResources/drawable/grass.png new file mode 100644 index 0000000..a3dc136 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/grass.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/ground.png b/composeApp/src/commonMain/composeResources/drawable/ground.png new file mode 100644 index 0000000..fce2f66 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/ground.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/ice.png b/composeApp/src/commonMain/composeResources/drawable/ice.png new file mode 100644 index 0000000..c2b2432 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/ice.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/normal.png b/composeApp/src/commonMain/composeResources/drawable/normal.png new file mode 100644 index 0000000..5bcea37 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/normal.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/poison.png b/composeApp/src/commonMain/composeResources/drawable/poison.png new file mode 100644 index 0000000..f3e17ae Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/poison.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/psychic.png b/composeApp/src/commonMain/composeResources/drawable/psychic.png new file mode 100644 index 0000000..0f6368a Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/psychic.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/rock.png b/composeApp/src/commonMain/composeResources/drawable/rock.png new file mode 100644 index 0000000..5986fde Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/rock.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/steel.png b/composeApp/src/commonMain/composeResources/drawable/steel.png new file mode 100644 index 0000000..4641632 Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/steel.png differ diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/bug.svg b/composeApp/src/commonMain/composeResources/drawable/svg/bug.svg new file mode 100644 index 0000000..26bc80b --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/bug.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/dark.svg b/composeApp/src/commonMain/composeResources/drawable/svg/dark.svg new file mode 100644 index 0000000..3bb988c --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/dark.svg @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/dragon.svg b/composeApp/src/commonMain/composeResources/drawable/svg/dragon.svg new file mode 100644 index 0000000..e079a93 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/dragon.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/electric.svg b/composeApp/src/commonMain/composeResources/drawable/svg/electric.svg new file mode 100644 index 0000000..a250881 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/electric.svg @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/fairy.svg b/composeApp/src/commonMain/composeResources/drawable/svg/fairy.svg new file mode 100644 index 0000000..1a87a20 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/fairy.svg @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/fighting.svg b/composeApp/src/commonMain/composeResources/drawable/svg/fighting.svg new file mode 100644 index 0000000..ae1d5e3 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/fighting.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/fire.svg b/composeApp/src/commonMain/composeResources/drawable/svg/fire.svg new file mode 100644 index 0000000..a2883a2 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/fire.svg @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/flying.svg b/composeApp/src/commonMain/composeResources/drawable/svg/flying.svg new file mode 100644 index 0000000..23bbd98 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/flying.svg @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/ghost.svg b/composeApp/src/commonMain/composeResources/drawable/svg/ghost.svg new file mode 100644 index 0000000..27d16dc --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/ghost.svg @@ -0,0 +1,22 @@ + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/grass.svg b/composeApp/src/commonMain/composeResources/drawable/svg/grass.svg new file mode 100644 index 0000000..e597f98 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/grass.svg @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/ground.svg b/composeApp/src/commonMain/composeResources/drawable/svg/ground.svg new file mode 100644 index 0000000..76ceaf6 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/ground.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/ice.svg b/composeApp/src/commonMain/composeResources/drawable/svg/ice.svg new file mode 100644 index 0000000..8aefcd9 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/ice.svg @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/normal.svg b/composeApp/src/commonMain/composeResources/drawable/svg/normal.svg new file mode 100644 index 0000000..416ac98 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/normal.svg @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/poison.svg b/composeApp/src/commonMain/composeResources/drawable/svg/poison.svg new file mode 100644 index 0000000..f5d5cde --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/poison.svg @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/psychic.svg b/composeApp/src/commonMain/composeResources/drawable/svg/psychic.svg new file mode 100644 index 0000000..b5ab080 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/psychic.svg @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/rock.svg b/composeApp/src/commonMain/composeResources/drawable/svg/rock.svg new file mode 100644 index 0000000..46cbfe3 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/rock.svg @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/steel.svg b/composeApp/src/commonMain/composeResources/drawable/svg/steel.svg new file mode 100644 index 0000000..8097904 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/steel.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/svg/water.svg b/composeApp/src/commonMain/composeResources/drawable/svg/water.svg new file mode 100644 index 0000000..60c2263 --- /dev/null +++ b/composeApp/src/commonMain/composeResources/drawable/svg/water.svg @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/composeApp/src/commonMain/composeResources/drawable/water.png b/composeApp/src/commonMain/composeResources/drawable/water.png new file mode 100644 index 0000000..07195cd Binary files /dev/null and b/composeApp/src/commonMain/composeResources/drawable/water.png differ diff --git a/composeApp/src/commonMain/kotlin/App.kt b/composeApp/src/commonMain/kotlin/App.kt new file mode 100644 index 0000000..1116e61 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/App.kt @@ -0,0 +1,164 @@ +import androidx.compose.foundation.Canvas +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text + +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.CornerRadius +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import io.kamel.image.KamelImage +import io.kamel.image.asyncPainterResource +import org.jetbrains.compose.ui.tooling.preview.Preview +import org.json.JSONObject +import org.jetbrains.compose.resources.ExperimentalResourceApi +import pokedex.composeapp.generated.resources.Res +import pokedex.composeapp.generated.resources.*; + +import java.net.URL + +@OptIn(ExperimentalResourceApi::class) +@Composable +@Preview +fun App() { + val pokemap = ArrayList() + val apiString = "https://pokeapi.co/api/v2/pokemon/" + var dataLoaded by mutableStateOf(false) + val orange = Color(0xFFffa500) + + val pokemonTypeDrawableMap = hashMapOf( + "normal" to Res.drawable.normal, + "fire" to Res.drawable.fire, + "water" to Res.drawable.water, + "electric" to Res.drawable.electric, + "grass" to Res.drawable.grass, + "ice" to Res.drawable.ice, + "fighting" to Res.drawable.fighting, + "poison" to Res.drawable.poison, + "ground" to Res.drawable.ground, + "flying" to Res.drawable.flying, + "psychic" to Res.drawable.psychic, + "bug" to Res.drawable.bug, + "rock" to Res.drawable.rock, + "ghost" to Res.drawable.ghost, + "dragon" to Res.drawable.dragon, + "dark" to Res.drawable.dark, + "steel" to Res.drawable.steel, + "fairy" to Res.drawable.fairy + ) + + MaterialTheme { + Box(modifier = Modifier.background(color = orange).fillMaxSize()) { + if (!dataLoaded) { + println("Should show indicator") + //For some reason the application calls this code but does not diplay the ui if the launchedeffect is running + //This should not happen as launched-effect is an async co routine and non blocking + Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + CircularProgressIndicator(modifier = Modifier.size(128.dp), color = Color.White) + Text( + "Fetching data from API...", + color = Color.White, + fontWeight = FontWeight.Bold, + modifier = Modifier.height(200.dp) + ) + } + } else { + LazyVerticalGrid( + columns = GridCells.Adaptive(minSize = 256.dp), + ) { + items(pokemap.size) { index -> + Box(modifier = Modifier.size(256.dp).padding(5.dp)) { + Canvas(modifier = Modifier.matchParentSize()) { + drawRoundRect( + color = Color.White, + topLeft = Offset(0f, 0f), + size = Size(size.width, size.height), + cornerRadius = CornerRadius(20f, 20f), + ) + } + Column( + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + KamelImage( + resource = asyncPainterResource(pokemap[index].imageUrl), + modifier = Modifier.size(128.dp), + contentDescription = "", + alignment = Alignment.Center + ) + } + Column( + modifier = Modifier.fillMaxSize().padding(vertical = 8.dp), + verticalArrangement = Arrangement.Bottom, + horizontalAlignment = Alignment.CenterHorizontally + ) { + val type: String = pokemap[index].type + Box(modifier = Modifier.size(32.dp)) { + Image( + org.jetbrains.compose.resources.painterResource( + pokemonTypeDrawableMap[type]!! + ), + contentDescription = null + ) + } + Spacer(modifier = Modifier.height(8.dp)) + Text( + text = pokemap[index].name, + textAlign = TextAlign.Center, + color = Color.Black, + fontWeight = FontWeight.Bold + ) + } + } + } + } + } + } + } + //Blocks ui rendering thread? + LaunchedEffect(Unit) { + //PokeDex API: https://pokeapi.co/api/v2/pokemon/ + for (i in 1..10) { + val json = JSONObject(URL(apiString + i).readText()); + val sprites = json.optJSONObject("sprites") + val types = json.getJSONArray("types") + val firstType = types.optJSONObject(0) + val type: String = firstType.optJSONObject("type").optString("name") + + val pokemon = Pokemon( + json.optString("name"), + URL(sprites.optString("front_default")), + type, + json.optInt("id") + ) + + println(pokemon) + + //println(type) + pokemap.add( + pokemon + ) + } + dataLoaded = true; + } + +} diff --git a/composeApp/src/commonMain/kotlin/Platform.kt b/composeApp/src/commonMain/kotlin/Platform.kt new file mode 100644 index 0000000..87ca3ff --- /dev/null +++ b/composeApp/src/commonMain/kotlin/Platform.kt @@ -0,0 +1,5 @@ +interface Platform { + val name: String +} + +expect fun getPlatform(): Platform \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/Pokemon.kt b/composeApp/src/commonMain/kotlin/Pokemon.kt new file mode 100644 index 0000000..788f3a3 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/Pokemon.kt @@ -0,0 +1,8 @@ +import java.net.URL + +data class Pokemon ( + val name: String, + val imageUrl: URL, + val type: String, + val id: Int +) \ No newline at end of file diff --git a/composeApp/src/desktopMain/kotlin/Platform.jvm.kt b/composeApp/src/desktopMain/kotlin/Platform.jvm.kt new file mode 100644 index 0000000..f5e7e49 --- /dev/null +++ b/composeApp/src/desktopMain/kotlin/Platform.jvm.kt @@ -0,0 +1,5 @@ +class JVMPlatform: Platform { + override val name: String = "Java ${System.getProperty("java.version")}" +} + +actual fun getPlatform(): Platform = JVMPlatform() \ No newline at end of file diff --git a/composeApp/src/desktopMain/kotlin/main.kt b/composeApp/src/desktopMain/kotlin/main.kt new file mode 100644 index 0000000..0ed5fa3 --- /dev/null +++ b/composeApp/src/desktopMain/kotlin/main.kt @@ -0,0 +1,9 @@ +import androidx.compose.runtime.Composable +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application + +fun main() = application { + Window(onCloseRequest = ::exitApplication, title = "PokeDex") { + App() + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e20fd2c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,16 @@ +kotlin.code.style=official + +#Gradle +org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M" + + +#Android +android.nonTransitiveRClass=true +android.useAndroidX=true + +#MPP +kotlin.mpp.androidSourceSetLayoutVersion=2 + +#Development +development=true +org.gradle.configuration-cache=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..6a4e346 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,50 @@ +[versions] +accompanistCoil = "0.23.0" +agp = "8.3.1" +android-compileSdk = "34" +android-minSdk = "24" +android-targetSdk = "34" +androidx-activityCompose = "1.8.2" +androidx-appcompat = "1.6.1" +androidx-constraintlayout = "2.1.4" +androidx-core-ktx = "1.12.0" +androidx-espresso-core = "3.5.1" +androidx-material = "1.11.0" +androidx-test-junit = "1.1.5" +coil = "3.0.0-alpha01" +compose = "1.6.5" +compose-plugin = "1.6.0" +composeVersion = "1.0.0-beta01" +json = "20211205" +junit = "4.13.2" +kamelImage = "0.9.4" +kotlin = "1.9.22" +lifecycleProcess = "2.7.0" +media3Effect = "1.3.1" +ktor = "2.3.10" + +[libraries] +androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycleProcess" } +ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" } +compose = { module = "com.github.bumptech.glide:compose", version.ref = "composeVersion" } +json = { module = "org.json:json", version.ref = "json" } +kamel-image = { module = "media.kamel:kamel-image", version.ref = "kamelImage" } +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" } +androidx-test-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-junit" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-espresso-core" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } +androidx-material = { group = "com.google.android.material", name = "material", version.ref = "androidx-material" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" } +androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" } +compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } +compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" } +androidx-media3-effect = { group = "androidx.media3", name = "media3-effect", version.ref = "media3Effect" } + +[plugins] +androidApplication = { id = "com.android.application", version.ref = "agp" } +androidLibrary = { id = "com.android.library", version.ref = "agp" } +jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } +kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..033e24c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3fa8f86 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..fcb6fca --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..6689b85 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..5dce083 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,22 @@ +rootProject.name = "PokeDex" +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") + +pluginManagement { + repositories { + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + google() + gradlePluginPortal() + mavenCentral() + } +} + +dependencyResolutionManagement { + repositories { + google() + mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + maven { url = uri("https://jitpack.io") } // for moko-media android picker + } +} + +include(":composeApp") \ No newline at end of file