Skip to content

Commit 102c43c

Browse files
committed
Step 4
1 parent f8b7286 commit 102c43c

File tree

17 files changed

+551
-754
lines changed

17 files changed

+551
-754
lines changed

step4/androidApp/build.gradle.kts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
2-
id("com.android.application")
3-
kotlin("android")
2+
alias(libs.plugins.androidApplication)
3+
alias(libs.plugins.kotlinAndroid)
44
}
55

66
android {
7-
namespace = "com.jetbrains.simplelogin.kotlinmultiplatformsandbox"
7+
namespace = "com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android"
88
compileSdk = 34
99
defaultConfig {
10-
applicationId = "com.jetbrains.simplelogin.kotlinmultiplatformsandbox"
11-
minSdk = 26
10+
applicationId = "com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android"
11+
minSdk = 24
1212
targetSdk = 34
1313
versionCode = 1
1414
versionName = "1.0"
@@ -17,11 +17,11 @@ android {
1717
compose = true
1818
}
1919
composeOptions {
20-
kotlinCompilerExtensionVersion = "1.5.4-dev-k1.9.20-Beta2-ac5f960bdaf"
20+
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
2121
}
2222
packaging {
2323
resources {
24-
excludes += "/META-INF/**"
24+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
2525
}
2626
}
2727
buildTypes {
@@ -30,22 +30,19 @@ android {
3030
}
3131
}
3232
compileOptions {
33-
sourceCompatibility = JavaVersion.VERSION_17
34-
targetCompatibility = JavaVersion.VERSION_17
33+
sourceCompatibility = JavaVersion.VERSION_1_8
34+
targetCompatibility = JavaVersion.VERSION_1_8
3535
}
3636
kotlinOptions {
37-
jvmTarget = "17"
37+
jvmTarget = "1.8"
3838
}
3939
}
4040

4141
dependencies {
42-
implementation(project(":shared"))
43-
implementation("androidx.compose.ui:ui:1.5.4")
44-
implementation("androidx.compose.ui:ui-tooling:1.5.4")
45-
implementation("androidx.compose.ui:ui-tooling-preview:1.5.4")
46-
implementation("androidx.compose.foundation:foundation:1.5.4")
47-
implementation("androidx.compose.material3:material3:1.1.2")
48-
implementation("androidx.activity:activity-compose:1.8.1")
49-
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
50-
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.2")
42+
implementation(projects.shared)
43+
implementation(libs.compose.ui)
44+
implementation(libs.compose.ui.tooling.preview)
45+
implementation(libs.compose.material3)
46+
implementation(libs.androidx.activity.compose)
47+
debugImplementation(libs.compose.ui.tooling)
5148
}

step4/androidApp/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
<uses-permission android:name="android.permission.INTERNET"/>
3+
44
<application
55
android:allowBackup="false"
66
android:supportsRtl="true"
77
android:theme="@style/AppTheme">
88
<activity
9-
android:name="com.jetbrains.simplelogin.kotlinmultiplatformsandbox.MainActivity"
9+
android:name=".MainActivity"
1010
android:exported="true">
1111
<intent-filter>
1212
<action android:name="android.intent.action.MAIN" />

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
package com.jetbrains.simplelogin.kotlinmultiplatformsandbox
1+
package com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android
22

33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
6-
import androidx.activity.viewModels
76
import androidx.compose.foundation.layout.Arrangement
87
import androidx.compose.foundation.layout.PaddingValues
98
import androidx.compose.foundation.layout.fillMaxSize
109
import androidx.compose.foundation.lazy.LazyColumn
1110
import androidx.compose.foundation.lazy.items
12-
import androidx.compose.material3.Divider
13-
import androidx.compose.material3.MaterialTheme
14-
import androidx.compose.material3.Surface
15-
import androidx.compose.material3.Text
11+
import androidx.compose.material3.*
1612
import androidx.compose.runtime.Composable
1713
import androidx.compose.ui.Modifier
1814
import androidx.compose.ui.tooling.preview.Preview
1915
import androidx.compose.ui.unit.dp
20-
import androidx.lifecycle.compose.collectAsStateWithLifecycle
16+
import com.jetbrains.simplelogin.kotlinmultiplatformsandbox.Greeting
2117

2218
class MainActivity : ComponentActivity() {
23-
private val mainViewModel: MainViewModel by viewModels()
24-
2519
override fun onCreate(savedInstanceState: Bundle?) {
2620
super.onCreate(savedInstanceState)
2721
setContent {
@@ -30,8 +24,7 @@ class MainActivity : ComponentActivity() {
3024
modifier = Modifier.fillMaxSize(),
3125
color = MaterialTheme.colorScheme.background
3226
) {
33-
val greetings = mainViewModel.greetingList.collectAsStateWithLifecycle()
34-
GreetingView(phrases = greetings.value)
27+
GreetingView(Greeting().greet())
3528
}
3629
}
3730
}
@@ -51,7 +44,6 @@ fun GreetingView(phrases: List<String>) {
5144
}
5245
}
5346

54-
5547
@Preview
5648
@Composable
5749
fun DefaultPreview() {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.jetbrains.simplelogin.kotlinmultiplatformsandbox
1+
package com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android
22

33
import androidx.compose.foundation.isSystemInDarkTheme
44
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -23,16 +23,18 @@ fun MyApplicationTheme(
2323
val colors = if (darkTheme) {
2424
darkColorScheme(
2525
primary = Color(0xFFBB86FC),
26-
secondary = Color(0xFF03DAC5)
26+
secondary = Color(0xFF03DAC5),
27+
tertiary = Color(0xFF3700B3)
2728
)
2829
} else {
2930
lightColorScheme(
3031
primary = Color(0xFF6200EE),
31-
secondary = Color(0xFF03DAC5)
32+
secondary = Color(0xFF03DAC5),
33+
tertiary = Color(0xFF3700B3)
3234
)
3335
}
3436
val typography = Typography(
35-
bodyLarge = TextStyle(
37+
bodyMedium = TextStyle(
3638
fontFamily = FontFamily.Default,
3739
fontWeight = FontWeight.Normal,
3840
fontSize = 16.sp

step4/build.gradle.kts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
plugins {
22
//trick: for the same plugin versions in all sub-modules
3-
id("com.android.application").version("8.1.4").apply(false)
4-
id("com.android.library").version("8.1.4").apply(false)
5-
kotlin("android").version("1.9.20-Beta2").apply(false)
6-
kotlin("multiplatform").version("1.9.20-Beta2").apply(false)
7-
kotlin("plugin.serialization").version("1.9.20-Beta2").apply(false)
8-
id("com.google.devtools.ksp").version("1.9.10-1.0.13").apply(false)
9-
id("com.rickclephas.kmp.nativecoroutines").version("1.0.0-ALPHA-18").apply(false)
10-
}
11-
12-
tasks.register("clean", Delete::class) {
13-
delete(rootProject.buildDir)
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)
147
}

step4/gradle.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ kotlin.code.style=official
88

99
#Android
1010
android.useAndroidX=true
11-
android.nonTransitiveRClass=true
12-
13-
#MPP
14-
kotlin.mpp.enableCInteropCommonization=true
15-
kotlin.mpp.androidSourceSetLayoutVersion=2
11+
android.nonTransitiveRClass=true

step4/gradle/libs.versions.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[versions]
2+
agp = "8.2.0-rc03"
3+
kotlin = "1.9.20"
4+
compose = "1.5.4"
5+
compose-compiler = "1.5.4"
6+
compose-material3 = "1.1.2"
7+
androidx-activityCompose = "1.8.0"
8+
9+
[libraries]
10+
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
11+
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
12+
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
13+
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
14+
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
15+
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
16+
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
17+
18+
[plugins]
19+
androidApplication = { id = "com.android.application", version.ref = "agp" }
20+
androidLibrary = { id = "com.android.library", version.ref = "agp" }
21+
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
22+
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
23+
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Jul 11 15:36:23 SAST 2023
1+
#Tue Dec 12 15:01:59 SAST 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)