Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# Project exclude paths
/.gradle/
/build/
/.idea
*.iml
.gradle
/local.properties
/.idea
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
build/
/captures
.externalNativeBuild
.cxx
iosApp/Podfile.lock
iosApp/Pods/*
iosApp/iosApp.xcworkspace/*
iosApp/iosApp.xcodeproj/*
!iosApp/iosApp.xcodeproj/project.pbxproj
shared/shared.podspec
/webApp/.gradle/
/webApp/build/
49 changes: 49 additions & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id("com.android.application")
kotlin("android")
}

android {
namespace = "com.example.asteroids.android"
compileSdk = 33
defaultConfig {
applicationId = "com.example.asteroids.android"
minSdk = 24
targetSdk = 33
versionCode = 1
versionName = "1.0"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.0"
}
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(project(":shared"))
implementation("androidx.compose.ui:ui:1.3.1")
implementation("androidx.compose.ui:ui-tooling:1.3.1")
implementation("androidx.compose.ui:ui-tooling-preview:1.3.1")
implementation("androidx.compose.foundation:foundation:1.3.1")
implementation("androidx.compose.material:material:1.3.1")
implementation("androidx.activity:activity-compose:1.6.1")
}
17 changes: 17 additions & 0 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="false"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name="com.example.asteroids.android.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.asteroids.android

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.example.asteroids.MainAndroid

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MainAndroid()
}
}
}
4 changes: 4 additions & 0 deletions androidApp/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>

<style name="AppTheme" parent="android:Theme.Material.NoActionBar" />
</resources>
46 changes: 13 additions & 33 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.4.31"
id("org.jetbrains.compose") version "0.3.2"
id("com.android.application").version("7.4.0-beta02").apply(false)
id("com.android.library").version("7.4.0-beta02").apply(false)
id("org.jetbrains.compose").version("1.3.0") apply false
kotlin("android").version("1.8.0").apply(false)
kotlin("multiplatform").version("1.8.0").apply(false)
kotlin("jvm") apply false
}

group = "me.user"
version = "1.0"

repositories {
jcenter()
mavenCentral()
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
}

dependencies {
implementation(compose.desktop.currentOs)
implementation("org.openrndr:openrndr-math:0.3.47")
}

tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "11"
}

compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "asteroids-for-desktop"
packageVersion = "1.0.0"
}
allprojects {
repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
mavenLocal()
}
}
}
27 changes: 27 additions & 0 deletions desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}

kotlin {
jvm {
withJava()
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
//having some issue with runnign on that, otherwise we dont need that
implementation(compose.desktop.macos_arm64)
implementation(project(":shared"))
}
}
}
}

compose.desktop {
application {
mainClass = "main"
}
}

32 changes: 32 additions & 0 deletions desktopApp/src/jvmMain/kotlin/DesktopApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.application
import com.example.travelapp_kmp.CommonMainDesktop
import java.awt.Dimension
import java.awt.Toolkit

fun main() = application {
Window(
onCloseRequest = ::exitApplication,
title = "Asteroids Web",
state = WindowState(
position = WindowPosition.Aligned(Alignment.Center),
size = getPreferredWindowSize(800, 800)
),
) {
CommonMainDesktop()
}
}

fun getPreferredWindowSize(desiredWidth: Int, desiredHeight: Int): DpSize {
val screenSize: Dimension = Toolkit.getDefaultToolkit().screenSize
val preferredWidth: Int = (screenSize.width * 0.8f).toInt()
val preferredHeight: Int = (screenSize.height * 0.8f).toInt()
val width: Int = if (desiredWidth < preferredWidth) desiredWidth else preferredWidth
val height: Int = if (desiredHeight < preferredHeight) desiredHeight else preferredHeight
return DpSize(width.dp, height.dp)
}
25 changes: 25 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
#Kotlin
kotlin.code.style=official
#Android
android.useAndroidX=true
android.nonTransitiveRClass=true
#MPP
kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.androidSourceSetLayoutVersion=2
org.jetbrains.compose.experimental.uikit.enabled=true
kotlin.version=1.8.0
agp.version=7.1.3
compose.version=1.4.0-alpha01-dev954
ktor.version=2.2.1
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
xcodeproj=iosApp
kotlin.native.cocoapods.generate.wrapper=true
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableGranularSourceSetsMetadata=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.js.ir.output.granularity=whole-program
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading