Skip to content

Commit 2424e72

Browse files
committed
Apply wizard changes
1 parent 73eac70 commit 2424e72

File tree

14 files changed

+147
-159
lines changed

14 files changed

+147
-159
lines changed

.gitignore

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
*.iml
2-
.gradle/
3-
build/
4-
.idea/
5-
.DS_STORE
62
.kotlin
3+
.gradle
4+
**/build/
5+
xcuserdata
6+
!src/**/build/
77
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ This sample demonstrates basic KMP features:
1212

1313
## How to use
1414

15-
With the [KMP plugin for Android Studio](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) you can run, test, and debug shared code on both platforms without switching IDEs. Run and debug the application by selecting the corresponding configuration in the **Run configuration** menu. Run and debug shared module tests by pressing the gutter icon on a test class or method.
15+
With the [Kotlin Multiplatform plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile) you can run, test, and debug shared code on both platforms without switching IDEs. Run and debug the application by selecting the corresponding configuration in the **Run configuration** menu. Run and debug shared module tests by pressing the gutter icon on a test class or method.
1616

1717
## Related links
1818

19-
* Visit [Kotlin Multiplatform Developer Portal](https://kotlinlang.org/lp/mobile/) to learn more about the technology
20-
* Check out the [Networking and data storage with KMP hands-on](https://play.kotlinlang.org/hands-on/Networking%20and%20Data%20Storage%20with%20Kotlin%20Multiplatfrom%20Mobile/) lab to learn how to create a mobile application for Android and iOS with a shared codebase with Ktor and SQLDelight.
19+
* Visit the [Kotlin Multiplatform landing page](https://www.jetbrains.com/kotlin-multiplatform/) to learn more about the technology
20+
* Get started with [Kotlin Multiplatform on developer portal](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)
21+
* Check out the [Networking and data storage with KMP hands-on](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-ktor-sqldelight.html) lab to learn how to create a mobile application for Android and iOS with a shared codebase with Ktor and SQLDelight.
2122

2223

2324

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
// in each subproject's classloader
44
alias(libs.plugins.androidApplication) apply false
55
alias(libs.plugins.androidLibrary) apply false
6-
alias(libs.plugins.jetbrainsCompose) apply false
7-
alias(libs.plugins.compose.compiler) apply false
6+
alias(libs.plugins.composeMultiplatform) apply false
7+
alias(libs.plugins.composeCompiler) apply false
88
alias(libs.plugins.kotlinMultiplatform) apply false
99
}

composeApp/build.gradle.kts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
44
plugins {
55
alias(libs.plugins.kotlinMultiplatform)
66
alias(libs.plugins.androidApplication)
7-
alias(libs.plugins.jetbrainsCompose)
8-
alias(libs.plugins.compose.compiler)
7+
alias(libs.plugins.composeMultiplatform)
8+
alias(libs.plugins.composeCompiler)
99
}
1010

1111
kotlin {
@@ -20,37 +20,28 @@ kotlin {
2020
androidMain.dependencies {
2121
implementation(compose.preview)
2222
implementation(libs.androidx.activity.compose)
23-
implementation(project(":shared"))
24-
implementation(libs.androidx.material)
25-
implementation(libs.androidx.appcompat)
26-
implementation(libs.androidx.constraintlayout)
27-
28-
implementation(platform("androidx.compose:compose-bom:2024.06.00"))
29-
implementation(libs.activity.compose)
30-
implementation(libs.androidx.ui)
31-
implementation(libs.androidx.ui.graphics)
32-
implementation(libs.androidx.material3)
3323
}
3424
commonMain.dependencies {
3525
implementation(compose.runtime)
3626
implementation(compose.foundation)
37-
implementation(compose.material)
27+
implementation(compose.material3)
3828
implementation(compose.ui)
3929
implementation(compose.components.resources)
4030
implementation(compose.components.uiToolingPreview)
31+
implementation(libs.androidx.lifecycle.viewmodel)
32+
implementation(libs.androidx.lifecycle.runtimeCompose)
4133
implementation(projects.shared)
4234
}
35+
commonTest.dependencies {
36+
implementation(libs.kotlin.test)
37+
}
4338
}
4439
}
4540

4641
android {
4742
namespace = "com.jetbrains.basicsample"
4843
compileSdk = libs.versions.android.compileSdk.get().toInt()
4944

50-
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
51-
sourceSets["main"].res.srcDirs("src/androidMain/res")
52-
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
53-
5445
defaultConfig {
5546
applicationId = "com.jetbrains.basicsample"
5647
minSdk = libs.versions.android.minSdk.get().toInt()
@@ -72,11 +63,8 @@ android {
7263
sourceCompatibility = JavaVersion.VERSION_11
7364
targetCompatibility = JavaVersion.VERSION_11
7465
}
75-
buildFeatures {
76-
compose = true
77-
}
78-
dependencies {
79-
debugImplementation(compose.uiTooling)
80-
}
8166
}
8267

68+
dependencies {
69+
debugImplementation(compose.uiTooling)
70+
}

composeApp/src/androidMain/AndroidManifest.xml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33

44
<application
5-
android:allowBackup="false"
6-
android:supportsRtl="true"
7-
android:theme="@style/AppTheme">
5+
android:allowBackup="true"
6+
android:icon="@mipmap/ic_launcher"
7+
android:roundIcon="@mipmap/ic_launcher_round"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@android:style/Theme.Material.Light.NoActionBar">
811
<activity
9-
android:name="com.jetbrains.basicsample.MainActivity"
10-
android:exported="true">
12+
android:name="com.jetbrains.basicsample.MainActivity"
13+
android:exported="true">
1114
<intent-filter>
12-
<action android:name="android.intent.action.MAIN" />
15+
<action android:name="android.intent.action.MAIN"/>
1316

14-
<category android:name="android.intent.category.LAUNCHER" />
17+
<category android:name="android.intent.category.LAUNCHER"/>
1518
</intent-filter>
1619
</activity>
1720
</application>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.jetbrains.basicsample
2+
3+
import androidx.compose.foundation.layout.Box
4+
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.Row
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.foundation.layout.padding
8+
import androidx.compose.foundation.layout.width
9+
import androidx.compose.foundation.text.KeyboardOptions
10+
import androidx.compose.material3.MaterialTheme
11+
import androidx.compose.material3.Text
12+
import androidx.compose.material3.TextField
13+
import androidx.compose.runtime.Composable
14+
import androidx.compose.runtime.getValue
15+
import androidx.compose.runtime.mutableStateOf
16+
import androidx.compose.runtime.saveable.rememberSaveable
17+
import androidx.compose.runtime.setValue
18+
import androidx.compose.ui.Alignment
19+
import androidx.compose.ui.Modifier
20+
import androidx.compose.ui.text.input.KeyboardType
21+
import androidx.compose.ui.unit.dp
22+
import org.jetbrains.compose.ui.tooling.preview.Preview
23+
24+
@Composable
25+
@Preview
26+
fun App() {
27+
MaterialTheme {
28+
Box(
29+
modifier = Modifier.fillMaxSize(),
30+
contentAlignment = Alignment.Center
31+
) {
32+
Column(
33+
horizontalAlignment = Alignment.Start,
34+
) {
35+
Text(greet(), Modifier.padding(8.dp))
36+
37+
var firstNumber by rememberSaveable { mutableStateOf("") }
38+
var secondNumber by rememberSaveable { mutableStateOf("") }
39+
40+
Row(verticalAlignment = Alignment.CenterVertically) {
41+
TextField(
42+
value = firstNumber,
43+
onValueChange = { firstNumber = it },
44+
modifier = Modifier.width(100.dp),
45+
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
46+
)
47+
Text(text = "+", modifier = Modifier.padding(4.dp))
48+
TextField(
49+
value = secondNumber,
50+
onValueChange = { secondNumber = it },
51+
modifier = Modifier.width(100.dp),
52+
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
53+
)
54+
55+
val first = firstNumber.toIntOrNull()
56+
val second = secondNumber.toIntOrNull()
57+
Text(
58+
text = if (first != null && second != null) {
59+
"= ${Calculator.sum(first, second)}"
60+
} else {
61+
"= \uD83E\uDD14"
62+
},
63+
modifier = Modifier
64+
.width(100.dp)
65+
.padding(4.dp)
66+
)
67+
}
68+
}
69+
}
70+
}
71+
}
72+
73+
fun greet(): String {
74+
return Greeting().greeting()
75+
}

composeApp/src/androidMain/kotlin/com/jetbrains/basicsample/MainActivity.kt

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,74 +3,15 @@ package com.jetbrains.basicsample
33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import androidx.compose.foundation.layout.Box
7-
import androidx.compose.foundation.layout.Column
8-
import androidx.compose.foundation.layout.Row
9-
import androidx.compose.foundation.layout.fillMaxSize
10-
import androidx.compose.foundation.layout.padding
11-
import androidx.compose.foundation.layout.width
12-
import androidx.compose.foundation.text.KeyboardOptions
13-
import androidx.compose.material3.Text
14-
import androidx.compose.material3.TextField
15-
import androidx.compose.runtime.getValue
16-
import androidx.compose.runtime.mutableStateOf
17-
import androidx.compose.runtime.saveable.rememberSaveable
18-
import androidx.compose.runtime.setValue
19-
import androidx.compose.ui.Alignment
20-
import androidx.compose.ui.Modifier
21-
import androidx.compose.ui.text.input.KeyboardType
22-
import androidx.compose.ui.unit.dp
23-
24-
fun greet(): String {
25-
return Greeting().greeting()
26-
}
6+
import androidx.activity.enableEdgeToEdge
277

288
class MainActivity : ComponentActivity() {
299
override fun onCreate(savedInstanceState: Bundle?) {
10+
enableEdgeToEdge()
3011
super.onCreate(savedInstanceState)
31-
setContent {
32-
Box(
33-
modifier = Modifier.fillMaxSize(),
34-
contentAlignment = Alignment.Center
35-
) {
36-
Column(
37-
horizontalAlignment = Alignment.Start,
38-
) {
39-
Text(greet(), Modifier.padding(8.dp))
4012

41-
var firstNumber by rememberSaveable { mutableStateOf("") }
42-
var secondNumber by rememberSaveable { mutableStateOf("") }
43-
44-
Row(verticalAlignment = Alignment.CenterVertically) {
45-
TextField(
46-
value = firstNumber,
47-
onValueChange = { firstNumber = it },
48-
modifier = Modifier.width(100.dp),
49-
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
50-
)
51-
Text(text = "+", modifier = Modifier.padding(4.dp))
52-
TextField(
53-
value = secondNumber,
54-
onValueChange = { secondNumber = it },
55-
modifier = Modifier.width(100.dp),
56-
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
57-
)
58-
59-
val first = firstNumber.toIntOrNull()
60-
val second = secondNumber.toIntOrNull()
61-
Text(
62-
text = if (first != null && second != null) {
63-
"= ${Calculator.sum(first, second)}"
64-
} else {
65-
"= \uD83E\uDD14"
66-
},
67-
modifier = Modifier
68-
.width(100.dp)
69-
.padding(4.dp)
70-
)
71-
}
72-
}
73-
}
13+
setContent {
14+
App()
7415
}
7516
}
7617
}

composeApp/src/androidMain/res/values/colors.xml

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

composeApp/src/androidMain/res/values/themes.xml

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

0 commit comments

Comments
 (0)