Skip to content

Commit 412da8f

Browse files
committed
Added step 3 of the tutorial
1 parent 7adb055 commit 412da8f

File tree

27 files changed

+1170
-0
lines changed

27 files changed

+1170
-0
lines changed

step3/final/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
.idea
4+
.DS_Store
5+
build
6+
captures
7+
.externalNativeBuild
8+
.cxx
9+
local.properties
10+
xcuserdata
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
plugins {
2+
id("com.android.application")
3+
kotlin("android")
4+
}
5+
6+
android {
7+
namespace = "com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android"
8+
compileSdk = 33
9+
defaultConfig {
10+
applicationId = "com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android"
11+
minSdk = 21
12+
targetSdk = 33
13+
versionCode = 1
14+
versionName = "1.0"
15+
}
16+
buildFeatures {
17+
compose = true
18+
}
19+
composeOptions {
20+
kotlinCompilerExtensionVersion = "1.4.7"
21+
}
22+
packaging {
23+
resources {
24+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
25+
}
26+
}
27+
buildTypes {
28+
getByName("release") {
29+
isMinifyEnabled = false
30+
}
31+
}
32+
compileOptions {
33+
sourceCompatibility = JavaVersion.VERSION_1_8
34+
targetCompatibility = JavaVersion.VERSION_1_8
35+
}
36+
kotlinOptions {
37+
jvmTarget = "1.8"
38+
}
39+
}
40+
41+
dependencies {
42+
implementation(project(":shared"))
43+
implementation("androidx.compose.ui:ui:1.4.3")
44+
implementation("androidx.compose.ui:ui-tooling:1.4.3")
45+
implementation("androidx.compose.ui:ui-tooling-preview:1.4.3")
46+
implementation("androidx.compose.foundation:foundation:1.4.3")
47+
implementation("androidx.compose.material:material:1.4.3")
48+
implementation("androidx.activity:activity-compose:1.7.1")
49+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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="false"
6+
android:supportsRtl="true"
7+
android:theme="@style/AppTheme">
8+
<activity
9+
android:name=".MainActivity"
10+
android:exported="true">
11+
<intent-filter>
12+
<action android:name="android.intent.action.MAIN" />
13+
<category android:name="android.intent.category.LAUNCHER" />
14+
</intent-filter>
15+
</activity>
16+
</application>
17+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android
2+
3+
import android.os.Bundle
4+
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.setContent
6+
import androidx.compose.foundation.layout.fillMaxSize
7+
import androidx.compose.material.*
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.tooling.preview.Preview
11+
import com.jetbrains.simplelogin.kotlinmultiplatformsandbox.Greeting
12+
13+
class MainActivity : ComponentActivity() {
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
setContent {
17+
MyApplicationTheme {
18+
Surface(
19+
modifier = Modifier.fillMaxSize(),
20+
color = MaterialTheme.colors.background
21+
) {
22+
GreetingView(Greeting().greet())
23+
}
24+
}
25+
}
26+
}
27+
}
28+
29+
@Composable
30+
fun GreetingView(text: String) {
31+
Text(text = text)
32+
}
33+
34+
@Preview
35+
@Composable
36+
fun DefaultPreview() {
37+
MyApplicationTheme {
38+
GreetingView("Hello, Android!")
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.jetbrains.simplelogin.kotlinmultiplatformsandbox.android
2+
3+
import androidx.compose.foundation.isSystemInDarkTheme
4+
import androidx.compose.foundation.shape.RoundedCornerShape
5+
import androidx.compose.material.MaterialTheme
6+
import androidx.compose.material.Shapes
7+
import androidx.compose.material.Typography
8+
import androidx.compose.material.darkColors
9+
import androidx.compose.material.lightColors
10+
import androidx.compose.runtime.Composable
11+
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.text.TextStyle
13+
import androidx.compose.ui.text.font.FontFamily
14+
import androidx.compose.ui.text.font.FontWeight
15+
import androidx.compose.ui.unit.dp
16+
import androidx.compose.ui.unit.sp
17+
18+
@Composable
19+
fun MyApplicationTheme(
20+
darkTheme: Boolean = isSystemInDarkTheme(),
21+
content: @Composable () -> Unit
22+
) {
23+
val colors = if (darkTheme) {
24+
darkColors(
25+
primary = Color(0xFFBB86FC),
26+
primaryVariant = Color(0xFF3700B3),
27+
secondary = Color(0xFF03DAC5)
28+
)
29+
} else {
30+
lightColors(
31+
primary = Color(0xFF6200EE),
32+
primaryVariant = Color(0xFF3700B3),
33+
secondary = Color(0xFF03DAC5)
34+
)
35+
}
36+
val typography = Typography(
37+
body1 = TextStyle(
38+
fontFamily = FontFamily.Default,
39+
fontWeight = FontWeight.Normal,
40+
fontSize = 16.sp
41+
)
42+
)
43+
val shapes = Shapes(
44+
small = RoundedCornerShape(4.dp),
45+
medium = RoundedCornerShape(4.dp),
46+
large = RoundedCornerShape(0.dp)
47+
)
48+
49+
MaterialTheme(
50+
colors = colors,
51+
typography = typography,
52+
shapes = shapes,
53+
content = content
54+
)
55+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<style name="AppTheme" parent="android:Theme.Material.NoActionBar"/>
3+
</resources>

step3/final/build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
//trick: for the same plugin versions in all sub-modules
3+
id("com.android.application").version("8.0.2").apply(false)
4+
id("com.android.library").version("8.0.2").apply(false)
5+
kotlin("android").version("1.8.21").apply(false)
6+
kotlin("multiplatform").version("1.8.21").apply(false)
7+
}
8+
9+
tasks.register("clean", Delete::class) {
10+
delete(rootProject.buildDir)
11+
}

step3/final/gradle.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#Gradle
2+
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
3+
4+
#Kotlin
5+
kotlin.code.style=official
6+
7+
#Android
8+
android.useAndroidX=true
9+
android.nonTransitiveRClass=true
10+
11+
#MPP
12+
kotlin.mpp.enableCInteropCommonization=true
13+
kotlin.mpp.androidSourceSetLayoutVersion=2
57.8 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Tue Jul 11 12:27:33 SAST 2023
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)