Skip to content

Commit

Permalink
prepare skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
DatL4g committed Jun 1, 2024
1 parent 0ebfda7 commit 84ef108
Show file tree
Hide file tree
Showing 42 changed files with 1,997 additions and 0 deletions.
616 changes: 616 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Compose Multiplatform Application

## Before running!
- check your system with [KDoctor](https://github.com/Kotlin/kdoctor)
- install JDK 17 or higher on your machine
- add `local.properties` file to the project root and set a path to Android SDK there

### Android
To run the application on android device/emulator:
- open project in Android Studio and run imported android run configuration

To build the application bundle:
- run `./gradlew :composeApp:assembleDebug`
- find `.apk` file in `composeApp/build/outputs/apk/debug/composeApp-debug.apk`
Run android simulator UI tests: `./gradlew :composeApp:pixel5Check`

### Desktop
Run the desktop application: `./gradlew :composeApp:run`
Run desktop UI tests: `./gradlew :composeApp:jvmTest`

### iOS
To run the application on iPhone device/simulator:
- Open `iosApp/iosApp.xcproject` in Xcode and run standard configuration
- Or use [Kotlin Multiplatform Mobile plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) for Android Studio
Run iOS simulator UI tests: `./gradlew :composeApp:iosSimulatorArm64Test`

139 changes: 139 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.aboutlibraries) apply false
alias(libs.plugins.android) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.cocoapods) apply false
alias(libs.plugins.compose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.konfig) apply false
alias(libs.plugins.multiplatform) apply false
alias(libs.plugins.serialization) apply false
alias(libs.plugins.versions)
}

buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven("https://jitpack.io")
maven("https://jogamp.org/deployment/maven")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}

allprojects {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven("https://jitpack.io")
maven("https://jogamp.org/deployment/maven")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
plugins.withType<YarnPlugin> {
yarn.yarnLockAutoReplace = true
}
}


tasks.withType<DependencyUpdatesTask> {
outputFormatter {
val updatable = this.outdated.dependencies
val markdown = if (updatable.isEmpty()) {
buildString {
append("### Dependencies up-to-date")
appendLine()
appendLine()
appendLine("Everything up-to-date")
appendLine()
appendLine("### Gradle Version")
appendLine()
appendLine("**Current version:** ${this@outputFormatter.gradle.running.version}")
appendLine("**Latest version:** ${this@outputFormatter.gradle.current.version}")
}
} else {
buildString {
append("## Updatable dependencies (${updatable.size})")
appendLine()
appendLine()
append('|')
append("Group")
append('|')
append("Module")
append('|')
append("Used Version")
append('|')
append("Available Version")
append('|')
appendLine()
append('|')
repeat(2) {
append("---")
append('|')
}
repeat(2) {
append(":-:")
append('|')
}
updatable.forEach { dependency ->
appendLine()
append('|')
append(dependency.group ?: ' ')
append('|')
append(dependency.name ?: ' ')
append('|')
append(dependency.version ?: ' ')
append('|')
append(dependency.available.release ?: dependency.available.milestone ?: ' ')
append('|')
}
appendLine()
appendLine()
appendLine("### Gradle Version")
appendLine()
appendLine("**Current version:** ${this@outputFormatter.gradle.running.version}")
appendLine("**Latest version:** ${this@outputFormatter.gradle.current.version}")
}
}
val outputFile = layout.buildDirectory.file("dependencyUpdates/report.md").get().asFile
try {
if (outputFile.exists()) {
outputFile.delete()
}
} catch (ignored: Throwable) { }
try {
outputFile.parentFile.mkdirs()
} catch (ignored: Throwable) { }
try {
outputFile.writeText(markdown)
} catch (ignored: Throwable) { }
}
rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}

fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
}
140 changes: 140 additions & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import com.codingfeline.buildkonfig.compiler.FieldSpec
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.aboutlibraries)
alias(libs.plugins.multiplatform)
alias(libs.plugins.android.application)
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.konfig)
alias(libs.plugins.serialization)
}

val artifact = "dev.datlag.burningseries"
val appVersion = "6.0.0"
val appVersionCode = 600

group = artifact
version = appVersion

composeCompiler {
enableStrongSkippingMode.set(true)
enableNonSkippingGroupOptimization.set(true)
}

buildkonfig {
packageName = artifact

defaultConfigs {
buildConfigField(FieldSpec.Type.STRING, "packageName", artifact)
}
}

kotlin {
androidTarget()
jvm()

/*listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "ComposeApp"
isStatic = true
}
}*/

applyDefaultHierarchyTemplate()

sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.materialIconsExtended)
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)

implementation(libs.kodein)
implementation(libs.kodein.compose)

implementation(libs.haze)
implementation(libs.haze.materials)

implementation(libs.decompose)
implementation(libs.decompose.compose)

implementation(libs.tooling.decompose)
}

val androidMain by getting {
apply(plugin = "kotlin-parcelize")

dependencies {
implementation(libs.android)
implementation(libs.activity)
implementation(libs.activity.compose)
implementation(libs.multidex)

implementation(libs.ktor.jvm)
implementation(libs.coroutines.android)
}
}

jvmMain.dependencies {
implementation(compose.desktop.currentOs)

implementation(libs.coroutines.swing)
}
}
}

dependencies {
coreLibraryDesugaring(libs.desugar)
}

android {
sourceSets["main"].setRoot("src/androidMain/")
sourceSets["main"].res.srcDirs("src/androidMain/res", "src/commonMain/resources")
sourceSets["main"].assets.srcDirs("src/androidMain/assets", "src/commonMain/assets")
compileSdk = 34
namespace = artifact

defaultConfig {
applicationId = artifact
minSdk = 23
targetSdk = 43
versionCode = appVersionCode
versionName = appVersion

multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
merges += "values**"
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
buildConfig = true
}
}

compose {
desktop {
application {
mainClass = "$artifact.MainKt"
}
}
web { }
}
21 changes: 21 additions & 0 deletions composeApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:icon="@android:drawable/ic_menu_compass"
android:label="Burning-Series"
android:theme="@android:style/Theme.Material.NoActionBar">
<activity
android:name=".AppActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustPan"
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,14 @@
package dev.datlag.burningseries

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge

class AppActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent { App() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.datlag.burningseries.theme

import android.app.Activity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowInsetsControllerCompat

@Composable
internal actual fun SystemAppearance(isDark: Boolean) {
val view = LocalView.current
LaunchedEffect(isDark) {
val window = (view.context as Activity).window
WindowInsetsControllerCompat(window, window.decorView).apply {
isAppearanceLightStatusBars = isDark
isAppearanceLightNavigationBars = isDark
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions composeApp/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<string name="app_name">Burning-Series</string>
<string name="home">Home</string>
</resources>
Loading

0 comments on commit 84ef108

Please sign in to comment.