Skip to content

Commit

Permalink
Merge pull request #8 from oikvpqya/dev/kmp-pr
Browse files Browse the repository at this point in the history
feat: KMP (Kotlin Multiplatform) support
  • Loading branch information
alexjlockwood authored Oct 18, 2024
2 parents 4285984 + 827f01d commit 1348403
Show file tree
Hide file tree
Showing 68 changed files with 4,196 additions and 908 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build

on:
workflow_dispatch:
workflow_call:
push:
paths-ignore:
- '**.md'
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build with Gradle
run: ./gradlew assemble --no-daemon

- name: Upload Debug APK
uses: actions/upload-artifact@v4
with:
name: debug-apk
path: |
app/build/outputs/apk/debug/app-debug.apk
- name: Upload Release APK
uses: actions/upload-artifact@v4
with:
name: release-apk
path: |
app/build/outputs/apk/release/app-release.apk
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
*.iml
.gradle
.kotlin
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/*
!/.idea/copyright
!/.idea/codeStyles
/.idea/codeStyles/*
!/.idea/codeStyles/Project.xml
!/.idea/codeStyles/codeStyleConfig.xml
.DS_Store
/build
/captures
Expand Down
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/gradle.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/jarRepositories.xml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

124 changes: 90 additions & 34 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,53 +1,109 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
id 'com.android.application'
id 'kotlin-android'
alias libs.plugins.android.application
alias libs.plugins.compose.compiler
alias libs.plugins.jetbrains.compose
alias libs.plugins.kotlin.multiplatform
alias libs.plugins.kotlin.serialization
}

kotlin {
jvmToolchain(17)
androidTarget()
jvm("desktop")

wasmJs {
moduleName = "composeApp"
browser {
commonWebpackConfig {
outputFileName = "composeApp.js"
}
}
binaries.executable()
}

sourceSets {
androidMain {
dependencies {
implementation libs.androidx.core.ktx
implementation libs.androidx.activity.compose
implementation libs.squareup.okio
implementation libs.xxfast.kstore.file
}
}

commonMain {
dependencies {
implementation compose.material
implementation compose.ui
implementation libs.androidx.lifecycle.viewmodel.compose
implementation libs.kotlinx.coroutines.core
implementation libs.kotlinx.serialization.json
implementation libs.xxfast.kstore.common
}
}

desktopMain {
dependencies {
implementation compose.desktop.currentOs
implementation libs.harawata.appdirs
implementation libs.kotlinx.coroutines.swing
implementation libs.squareup.okio
implementation libs.xxfast.kstore.file
}
}

wasmJsMain {
dependencies {
implementation libs.xxfast.kstore.storage
}
}
}
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
compileSdk 34
namespace "com.alexjlockwood.twentyfortyeightcompose"

defaultConfig {
applicationId "com.alexjlockwood.twentyfortyeightcompose"
minSdkVersion 21
targetSdkVersion 30
minSdk 21
targetSdk 34
versionCode 1
versionName "1.0"
versionName "1.0.0"
}

buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.getByName("debug")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = '1.8'
useIR = true
}

buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.activity:activity-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-rc01'
implementation 'com.google.code.gson:gson:2.8.6'
}
compose {
desktop {
application {
mainClass = "MainKt"

nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "com.alexjlockwood.twentyfortyeightcompose"
packageVersion = "1.0.0"
}
}
}

experimental {
web.application {}
}
}
21 changes: 0 additions & 21 deletions app/proguard-rules.pro

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alexjlockwood.twentyfortyeight">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
Expand All @@ -10,14 +9,13 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:name="com.alexjlockwood.twentyfortyeight.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>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.alexjlockwood.twentyfortyeight

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.alexjlockwood.twentyfortyeight.domain.UserData
import com.alexjlockwood.twentyfortyeight.repository.GameRepository
import com.alexjlockwood.twentyfortyeight.repository.USER_DATA_FILE_NAME
import io.github.xxfast.kstore.file.storeOf
import okio.Path.Companion.toPath

class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val filesDir = application.filesDir.absolutePath.toPath()
val store = storeOf(file = filesDir.resolve(USER_DATA_FILE_NAME), default = UserData.EMPTY_USER_DATA)

setContent {
App(
repository = GameRepository(store),
)
}
}
}
5 changes: 5 additions & 0 deletions app/src/androidMain/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>
<style name="AppTheme" parent="@android:style/Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">#303f9f</item>
</style>
</resources>
File renamed without changes.
Loading

0 comments on commit 1348403

Please sign in to comment.