Skip to content

Commit 1b5395b

Browse files
authored
update: use the new wizard and adjust for the tutorial
1 parent 5ac9c2c commit 1b5395b

File tree

252 files changed

+4972
-3877
lines changed

Some content is hidden

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

252 files changed

+4972
-3877
lines changed

step2/androidApp/build.gradle.kts

Lines changed: 0 additions & 48 deletions
This file was deleted.

step2/androidApp/src/main/AndroidManifest.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

step2/androidApp/src/main/java/com/jetbrains/simplelogin/kotlinmultiplatformsandbox/MainActivity.kt

Lines changed: 0 additions & 40 deletions
This file was deleted.

step2/androidApp/src/main/java/com/jetbrains/simplelogin/kotlinmultiplatformsandbox/MyApplicationTheme.kt

Lines changed: 0 additions & 55 deletions
This file was deleted.

step2/androidApp/src/main/res/values/styles.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

step2/build.gradle.kts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
plugins {
2-
//trick: for the same plugin versions in all sub-modules
3-
alias(libs.plugins.androidApplication).apply(false)
4-
alias(libs.plugins.androidLibrary).apply(false)
5-
alias(libs.plugins.kotlinAndroid).apply(false)
6-
alias(libs.plugins.kotlinMultiplatform).apply(false)
7-
}
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.kotlinMultiplatform) apply false
8+
}

step2/composeApp/build.gradle.kts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import org.jetbrains.compose.ExperimentalComposeLibrary
2+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
3+
4+
plugins {
5+
alias(libs.plugins.kotlinMultiplatform)
6+
alias(libs.plugins.androidApplication)
7+
alias(libs.plugins.jetbrainsCompose)
8+
}
9+
10+
kotlin {
11+
androidTarget {
12+
compilations.all {
13+
kotlinOptions {
14+
jvmTarget = "1.8"
15+
}
16+
}
17+
}
18+
19+
sourceSets {
20+
21+
androidMain.dependencies {
22+
implementation(libs.compose.ui.tooling.preview)
23+
implementation(libs.androidx.activity.compose)
24+
}
25+
commonMain.dependencies {
26+
implementation(compose.runtime)
27+
implementation(compose.foundation)
28+
implementation(compose.material)
29+
implementation(compose.ui)
30+
@OptIn(ExperimentalComposeLibrary::class)
31+
implementation(compose.components.resources)
32+
implementation(projects.shared)
33+
}
34+
}
35+
}
36+
37+
android {
38+
namespace = "com.jetbrains.greeting"
39+
compileSdk = libs.versions.android.compileSdk.get().toInt()
40+
41+
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
42+
sourceSets["main"].res.srcDirs("src/androidMain/res")
43+
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
44+
45+
defaultConfig {
46+
applicationId = "com.jetbrains.greeting"
47+
minSdk = libs.versions.android.minSdk.get().toInt()
48+
targetSdk = libs.versions.android.targetSdk.get().toInt()
49+
versionCode = 1
50+
versionName = "1.0"
51+
}
52+
packaging {
53+
resources {
54+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
55+
}
56+
}
57+
buildTypes {
58+
getByName("release") {
59+
isMinifyEnabled = false
60+
}
61+
}
62+
compileOptions {
63+
sourceCompatibility = JavaVersion.VERSION_1_8
64+
targetCompatibility = JavaVersion.VERSION_1_8
65+
}
66+
dependencies {
67+
debugImplementation(libs.compose.ui.tooling)
68+
}
69+
}
70+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<application
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:label="@string/app_name"
8+
android:roundIcon="@mipmap/ic_launcher_round"
9+
android:supportsRtl="true"
10+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
11+
<activity
12+
android:exported="true"
13+
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
14+
android:name=".MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import androidx.compose.animation.AnimatedVisibility
2+
import androidx.compose.foundation.Image
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.fillMaxWidth
5+
import androidx.compose.material.Button
6+
import androidx.compose.material.MaterialTheme
7+
import androidx.compose.material.Text
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.runtime.getValue
10+
import androidx.compose.runtime.mutableStateOf
11+
import androidx.compose.runtime.remember
12+
import androidx.compose.runtime.setValue
13+
import androidx.compose.ui.Alignment
14+
import androidx.compose.ui.Modifier
15+
import org.jetbrains.compose.resources.ExperimentalResourceApi
16+
import org.jetbrains.compose.resources.painterResource
17+
18+
@OptIn(ExperimentalResourceApi::class)
19+
@Composable
20+
fun App() {
21+
MaterialTheme {
22+
var showContent by remember { mutableStateOf(false) }
23+
val greeting = remember { Greeting().greet() }
24+
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
25+
Button(onClick = { showContent = !showContent }) {
26+
Text("Click me!")
27+
}
28+
AnimatedVisibility(showContent) {
29+
Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
30+
Image(painterResource("compose-multiplatform.xml"), null)
31+
Text("Compose: $greeting")
32+
}
33+
}
34+
}
35+
}
36+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.jetbrains.greeting
2+
3+
import App
4+
import android.os.Bundle
5+
import androidx.activity.ComponentActivity
6+
import androidx.activity.compose.setContent
7+
import androidx.compose.runtime.Composable
8+
import androidx.compose.ui.tooling.preview.Preview
9+
10+
class MainActivity : ComponentActivity() {
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
14+
setContent {
15+
App()
16+
}
17+
}
18+
}
19+
20+
@Preview
21+
@Composable
22+
fun AppAndroidPreview() {
23+
App()
24+
}

0 commit comments

Comments
 (0)