Skip to content

Commit 45795c1

Browse files
committed
Initial checkin
0 parents  commit 45795c1

File tree

69 files changed

+2886
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2886
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ ubuntu-latest, macOS-latest, windows-latest ]
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Set up JDK 17
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: '17'
17+
distribution: 'adopt'
18+
- name: Validate Gradle wrapper
19+
uses: gradle/wrapper-validation-action@v1
20+
21+
- name: 'Build + Test Android on Linux'
22+
if: matrix.os == 'ubuntu-latest'
23+
run: ./gradlew build --stacktrace -PisCI -Pnosign
24+
25+
- name: 'Build + Common OSX Sources'
26+
if: matrix.os == 'macOS-latest'
27+
run: ./gradlew :shared:build --stacktrace -PisCI -Pnosign

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.iml
2+
.kotlin
3+
.gradle
4+
**/build/
5+
xcuserdata
6+
!src/**/build/
7+
local.properties
8+
.idea
9+
.DS_Store
10+
captures
11+
.externalNativeBuild
12+
.cxx
13+
*.xcodeproj/*
14+
!*.xcodeproj/project.pbxproj
15+
!*.xcodeproj/xcshareddata/
16+
!*.xcodeproj/project.xcworkspace/
17+
!*.xcworkspace/contents.xcworkspacedata
18+
**/xcshareddata/WorkspaceSettings.xcsettings

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This is a Kotlin Multiplatform project targeting Android, iOS.
2+
3+
* `/composeApp` is for code that will be shared across your Compose Multiplatform applications.
4+
It contains several subfolders:
5+
- `commonMain` is for code that’s common for all targets.
6+
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name.
7+
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app,
8+
`iosMain` would be the right folder for such calls.
9+
10+
* `/iosApp` contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform,
11+
you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.
12+
13+
* `/shared` is for the code that will be shared between all targets in the project.
14+
The most important subfolder is `commonMain`. If preferred, you can add code to the platform-specific folders here too.
15+
16+
17+
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)

build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
plugins {
2+
// this is necessary to avoid the plugins to be loaded multiple times
3+
// in each subproject's classloader
4+
alias(libs.plugins.androidApplication) apply false
5+
alias(libs.plugins.androidLibrary) apply false
6+
alias(libs.plugins.jetbrainsCompose) apply false
7+
alias(libs.plugins.compose.compiler) apply false
8+
alias(libs.plugins.kotlinJvm) apply false
9+
alias(libs.plugins.kotlinMultiplatform) apply false
10+
alias(libs.plugins.exoquery) apply false
11+
12+
}

composeApp/build.gradle.kts

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2+
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
5+
plugins {
6+
alias(libs.plugins.kotlinMultiplatform)
7+
alias(libs.plugins.androidApplication)
8+
alias(libs.plugins.jetbrainsCompose)
9+
alias(libs.plugins.compose.compiler)
10+
alias(libs.plugins.exoquery)
11+
}
12+
13+
// Workaround for https://youtrack.jetbrains.com/issue/KT-51970
14+
//afterEvaluate {
15+
// afterEvaluate {
16+
// tasks.configureEach {
17+
// if (
18+
// name.startsWith("compile")
19+
// && name.endsWith("KotlinMetadata")
20+
// ) {
21+
// println("disabling ${this}:$name")
22+
// enabled = false
23+
// }
24+
// }
25+
// }
26+
//}
27+
28+
kotlin {
29+
androidTarget {
30+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
31+
compilerOptions {
32+
jvmTarget.set(JvmTarget.JVM_17)
33+
}
34+
}
35+
36+
listOf(
37+
//iosX64(),
38+
iosArm64(),
39+
//iosSimulatorArm64()
40+
).forEach { iosTarget ->
41+
iosTarget.binaries.framework {
42+
baseName = "ComposeApp"
43+
isStatic = true
44+
}
45+
iosTarget.binaries.configureEach {
46+
linkerOpts.add("-lsqlite3")
47+
}
48+
}
49+
50+
sourceSets {
51+
androidMain.dependencies {
52+
implementation(compose.preview)
53+
implementation(libs.androidx.activity.compose)
54+
implementation(libs.android.driver)
55+
implementation(libs.androidx.lifecycle.runtime)
56+
implementation(libs.androidx.lifecycle.runtime.ktx)
57+
implementation(libs.koin.androidx.compose)
58+
implementation(libs.exoquery.runner.android)
59+
// Android-specific dependencies
60+
implementation(libs.androidx.lifecycle.viewmodel.compose)
61+
}
62+
commonMain.dependencies {
63+
implementation(compose.runtime)
64+
implementation(compose.foundation)
65+
implementation(compose.material)
66+
implementation(compose.ui)
67+
implementation(compose.components.resources)
68+
implementation(compose.components.uiToolingPreview)
69+
implementation(projects.shared)
70+
implementation(libs.koin.compose)
71+
// Use Jetbrains Compose Material3 for multiplatform
72+
implementation(compose.material3)
73+
}
74+
iosMain.dependencies {
75+
implementation(libs.exoquery.runner.native)
76+
implementation(libs.jetbrains.annotations.kmp)
77+
}
78+
}
79+
}
80+
81+
configurations.all {
82+
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-debug")
83+
}
84+
85+
fun MinimalExternalModuleDependency.simpleString() =
86+
this.let { "${it.module}:${it.versionConstraint.requiredVersion}" }
87+
88+
android {
89+
compileSdk = 34 // for example
90+
91+
namespace = "com.example.project"
92+
compileSdk = libs.versions.android.compileSdk.get().toInt()
93+
94+
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
95+
sourceSets["main"].res.srcDirs("src/androidMain/res")
96+
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
97+
98+
defaultConfig {
99+
minSdk = 30
100+
applicationId = "com.example.project"
101+
minSdk = libs.versions.android.minSdk.get().toInt()
102+
targetSdk = libs.versions.android.targetSdk.get().toInt()
103+
versionCode = 1
104+
versionName = "1.0"
105+
}
106+
packaging {
107+
resources {
108+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
109+
}
110+
}
111+
buildTypes {
112+
getByName("release") {
113+
isMinifyEnabled = false
114+
}
115+
}
116+
compileOptions {
117+
sourceCompatibility = JavaVersion.VERSION_17
118+
targetCompatibility = JavaVersion.VERSION_17
119+
}
120+
buildFeatures {
121+
compose = true
122+
}
123+
dependencies {
124+
debugImplementation(compose.uiTooling)
125+
}
126+
// kotlinx-coroutines-debug and bytebuddy both include win32-x86-64/attach_hotspot_windows.dll, tell package to ignore
127+
packaging {
128+
resources {
129+
excludes += "**/attach_hotspot_windows.dll"
130+
}
131+
}
132+
}
133+
dependencies {
134+
implementation(libs.androidx.ui.text.google.fonts)
135+
implementation(libs.androidx.sqlite.framework)
136+
}
137+
138+
compose.desktop {
139+
application {
140+
mainClass = "com.example.project.MainKt"
141+
142+
nativeDistributions {
143+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
144+
packageName = "com.example.project"
145+
packageVersion = "1.0.0"
146+
}
147+
}
148+
}
149+
150+
151+
repositories {
152+
google {
153+
mavenContent {
154+
includeGroupAndSubgroups("androidx")
155+
includeGroupAndSubgroups("com.android")
156+
includeGroupAndSubgroups("com.google")
157+
}
158+
}
159+
mavenCentral()
160+
maven("https://s01.oss.sonatype.org/service/local/repositories/releases/content/")
161+
mavenLocal()
162+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<uses-permission android:name="android.permission.INTERNET" />
4+
<application
5+
android:name="com.example.project.MainApplication"
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
12+
<activity
13+
android:name="com.example.project.MainActivity"
14+
android:exported="true"
15+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
24+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.example.project
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.runtime.remember
5+
import org.koin.compose.koinInject
6+
7+
@Composable
8+
fun App() {
9+
val sdk = koinInject<SpaceXSDK>()
10+
val viewModel = remember { CommonRocketLaunchViewModel(sdk) }
11+
CommonApp(viewModel = viewModel)
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.example.project
2+
3+
import com.example.project.cache.AndroidDatabaseDriverFactory
4+
import com.example.project.network.SpaceXApi
5+
import org.koin.android.ext.koin.androidContext
6+
import org.koin.androidx.viewmodel.dsl.viewModel
7+
import org.koin.dsl.module
8+
9+
val appModule = module {
10+
single<SpaceXApi> { SpaceXApi() }
11+
single<SpaceXSDK> {
12+
SpaceXSDK(
13+
databaseDriverFactory = AndroidDatabaseDriverFactory(androidContext()),
14+
api = get()
15+
)
16+
}
17+
viewModel { RocketLaunchViewModel(sdk = get()) }
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.example.project
2+
3+
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.ui.tooling.preview.Preview
8+
9+
class MainActivity : ComponentActivity() {
10+
override fun onCreate(savedInstanceState: Bundle?) {
11+
super.onCreate(savedInstanceState)
12+
13+
setContent {
14+
App()
15+
}
16+
}
17+
}
18+
19+
@Preview
20+
@Composable
21+
fun AppAndroidPreview() {
22+
App()
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.example.project
2+
3+
import android.app.Application
4+
import org.koin.android.ext.koin.androidContext
5+
import org.koin.core.context.startKoin
6+
7+
class MainApplication : Application() {
8+
override fun onCreate() {
9+
super.onCreate()
10+
11+
startKoin {
12+
androidContext(this@MainApplication)
13+
modules(appModule)
14+
}
15+
}
16+
17+
18+
}

0 commit comments

Comments
 (0)