Skip to content

Commit

Permalink
Upgraded to Kotlin 2.0.0 (#13)
Browse files Browse the repository at this point in the history
* Upgraded to Kotlin 2.0.0

* cleaned dependencies

* use Compose Resources

* cleaned code

* replaced deprecated icons

* corrected font resources for iOS
  • Loading branch information
ferranpons authored May 27, 2024
1 parent 8cc55d0 commit 3cd6e38
Show file tree
Hide file tree
Showing 56 changed files with 106 additions and 93 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ google-services.json

# Android Profiling
*.hprof
xcuserdata
xcuserdata

*.klib
.kotlin/metadata
18 changes: 8 additions & 10 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
kotlin("android")
alias(libs.plugins.compose.compiler)
}

val versionNum: String? by project
Expand All @@ -27,9 +28,6 @@ android {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
Expand Down Expand Up @@ -58,11 +56,11 @@ dependencies {
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.tracing.ktx)

implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material:material")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material3:material3-window-size-class")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation(libs.androidx.ui)
implementation(libs.androidx.material)
implementation(libs.androidx.material3)
implementation(libs.androidx.material3.window.size)
implementation(libs.androidx.ui.tooling.preview)

implementation(libs.androidx.activity.compose)
implementation(libs.accompanist.systemuicontroller)
Expand All @@ -71,13 +69,13 @@ dependencies {
implementation(libs.koin.android)

implementation(platform(libs.firebase.bom))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation(libs.firebase.analytics.ktx)

testImplementation(libs.junit)
testImplementation(libs.koin.test)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

// androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation(libs.androidx.ui.tooling)
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
kotlin("multiplatform").version(libs.versions.kotlin).apply(false)
kotlin("plugin.serialization").version(libs.versions.kotlin).apply(false)
alias(libs.plugins.compose.multiplatform).apply(false)
alias(libs.plugins.compose.compiler).apply(false)
alias(libs.plugins.ktlint).apply(false)
alias(libs.plugins.detekt).apply(false)
}
Expand Down
2 changes: 2 additions & 0 deletions desktopApp/.run/desktopApp.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="desktopApp" type="JetRunConfigurationType">
<option name="ALTERNATIVE_JRE_PATH" value="BUNDLED" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="MainKt" />
<module name="MultiplatformKickstarter.desktopApp.jvmMain" />
<shortenClasspath name="NONE" />
Expand Down
1 change: 1 addition & 0 deletions desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
alias(libs.plugins.compose.compiler)
}

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ multiplatformkickstarter.android.minSdk = 26
multiplatformkickstarter.android.targetSdk = 34

multiplatformkickstarter.version.major = 1
multiplatformkickstarter.version.minor = 4
multiplatformkickstarter.version.minor = 5
multiplatformkickstarter.version.patch = 0
25 changes: 17 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
[versions]
kotlin = "2.0.0-RC1"
ktor-client = "2.3.10"
ktor-server = "2.3.10"
kotlin = "2.0.0"
ktor-client = "2.3.11"
ktor-server = "2.3.11"
multiplatform-settings = "1.0.0"
voyager = "1.0.0"
koin = "3.5.6"
koin-compose = "1.1.3"
junit = "4.13.2"
androidGradlePlugin = "8.2.2"
composeMultiplatform = "1.6.2"
compose-compiler = "1.5.13-dev-k2.0.0-RC1-50f08dfa4b4"
composeMultiplatform = "1.6.10"
exposed = "0.37.3"
skiko = "0.7.97"
skiko = "0.8.4"
ktlint = "11.5.1"
detekt = "1.23.1"
kotlinx-coroutines = "1.8.0"
kotlinx-coroutines = "1.8.1"
androidx-junit = "1.1.5"
espressoCore = "3.5.1"
accompanistSystemuicontroller = "0.32.0"
Expand Down Expand Up @@ -67,12 +66,20 @@ junit = { module = "junit:junit", version.ref = "junit" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoCore" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "androidx-junit" }

androidx-material = { module = "androidx.compose.material:material" }
androidx-material3 = { module = "androidx.compose.material3:material3" }
androidx-material3-window-size = { module = "androidx.compose.material3:material3-window-size-class" }
androidx-ui = { module = "androidx.compose.ui:ui" }
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
firebase-analytics-ktx = { module = "com.google.firebase:firebase-analytics-ktx" }

# iOS
stately-common = { module = "co.touchlab:stately-common", version.ref = "touchlab" }

# Desktop
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin-compose" }
kotlinx-coroutines-swingui = "org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.8.0"
kotlinx-coroutines-swingui = "org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.8.1"
ktor-client-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor-client" }
androidx-compose-ui-util = "androidx.compose.ui:ui-util:1.6.7"

Expand Down Expand Up @@ -117,6 +124,8 @@ android-library = { id = "com.android.library", version.ref = "androidGradlePlug
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }

#Backend
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version = "kotlin" }
Expand Down
15 changes: 14 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id("com.android.library")
id("org.jetbrains.compose")
kotlin("plugin.serialization")
alias(libs.plugins.compose.compiler)
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
Expand Down Expand Up @@ -31,6 +32,13 @@ kotlin {
}

sourceSets {
all {
languageSettings {
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
optIn("androidx.compose.foundation.layout.ExperimentalLayoutApi")
optIn("androidx.compose.material3.ExperimentalMaterial3Api")
}
}
commonMain.dependencies {
implementation(libs.skiko)
implementation(compose.ui)
Expand All @@ -39,7 +47,6 @@ kotlin {
implementation(compose.material3)
implementation(compose.animation)
implementation(compose.materialIconsExtended)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.datetime)
Expand Down Expand Up @@ -106,3 +113,9 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}
}

compose.resources {
publicResClass = true
packageOfResClass = "com.multiplatformkickstarter.app.resources"
generateResClass = always
}
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxColors
Expand Down Expand Up @@ -139,7 +139,7 @@ class DebugMenuScreen : Screen {
),
navigationIcon = {
IconButton(onClick = { onClose.invoke() }) {
Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = "Go back")
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Go back")
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -123,7 +123,7 @@ fun EmailLoginView(viewModel: EmailLoginViewModel, snackbarHostState: SnackbarHo
navigationIcon = {
IconButton(onClick = { currentNavigator.pop() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = localization.backLabel
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -111,7 +111,7 @@ fun EmailSignUpView(viewModel: EmailSignUpViewModel, snackbarHostState: Snackbar
navigationIcon = {
IconButton(onClick = { currentNavigator.pop() }) {
Icon(
imageVector = Icons.Filled.ArrowBack,
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = localization.backLabel
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:OptIn(ExperimentalMaterial3Api::class, ExperimentalResourceApi::class)
@file:OptIn(ExperimentalMaterial3Api::class)

package com.multiplatformkickstarter.app.feature.loginsignup

Expand Down Expand Up @@ -34,12 +34,11 @@ import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import com.multiplatformkickstarter.app.localization.getCurrentLocalization
import com.multiplatformkickstarter.app.platform.Resources
import com.multiplatformkickstarter.app.resources.Res
import com.multiplatformkickstarter.app.resources.cat_dog
import com.multiplatformkickstarter.app.ui.theme.MultiplatformKickstarterTheme
import com.multiplatformkickstarter.app.ui.theme.Typography
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.vectorResource

class LoginSignUpLandingScreen : Screen {
@Composable
Expand Down Expand Up @@ -76,7 +75,7 @@ fun LoginSignUpView() {
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painterResource(DrawableResource(Resources.Drawables.catAndDog)),
imageVector = vectorResource(Res.drawable.cat_dog),
contentDescription = "",
modifier = Modifier.size(150.dp)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
Expand Down Expand Up @@ -71,7 +71,7 @@ fun MyPetsScreenView(viewModel: MyPetsViewModel, localization: Localization, onC
TopAppBar(
navigationIcon = {
IconButton(onClick = { onClose.invoke() }) {
Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = "Go back")
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Go back")
}
},
title = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
Expand Down Expand Up @@ -172,7 +172,7 @@ class PetUploadScreen : Screen {
),
navigationIcon = {
IconButton(onClick = { onClose.invoke() }) {
Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = "Go back")
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Go back")
}
},
actions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,3 @@ import androidx.compose.ui.text.font.FontWeight

@Composable
expect fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font

object Resources {
object Drawables {
const val mindMap = "drawable/mind_map.xml"
const val noData = "drawable/no_data_cuate.xml"
const val login = "drawable/authentication_rafiki.xml"
const val catAndDog = "drawable/cat_dog.xml"
const val mkLogo = "drawable/mklogo.xml"
const val features = "drawable/features_overview_cuate.xml"
const val productQuality = "drawable/product_quality_amico.xml"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:OptIn(ExperimentalResourceApi::class)

package com.multiplatformkickstarter.app.ui.components

import androidx.compose.foundation.Image
Expand All @@ -22,17 +20,17 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.multiplatformkickstarter.app.localization.Localization
import com.multiplatformkickstarter.app.platform.Resources
import com.multiplatformkickstarter.app.resources.Res
import com.multiplatformkickstarter.app.resources.no_data_cuate
import com.multiplatformkickstarter.app.ui.theme.Typography
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
import org.jetbrains.compose.resources.vectorResource

@Composable
fun EmptyLayout(
title: String? = null,
description: String? = null,
imageResource: String? = null,
imageResource: DrawableResource? = null,
actionLabel: String? = null,
localization: Localization,
action: () -> Unit
Expand All @@ -57,7 +55,7 @@ fun EmptyLayout(
color = MaterialTheme.colorScheme.outline
)
Image(
painterResource(DrawableResource(imageResource ?: Resources.Drawables.noData)),
imageVector = vectorResource(imageResource ?: Res.drawable.no_data_cuate),
contentDescription = description,
modifier = Modifier.size(260.dp)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:OptIn(ExperimentalFoundationApi::class, ExperimentalFoundationApi::class, ExperimentalResourceApi::class)
@file:OptIn(ExperimentalFoundationApi::class, ExperimentalFoundationApi::class)

package com.multiplatformkickstarter.app.ui.components

Expand Down Expand Up @@ -35,7 +35,6 @@ import androidx.compose.ui.unit.dp
import com.multiplatformkickstarter.app.ui.theme.Typography
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource

private val defaultAction = {}
Expand Down Expand Up @@ -109,7 +108,7 @@ class OnboardingComponent(
verticalArrangement = Arrangement.SpaceBetween
) {
Image(
painterResource(DrawableResource(item.imageResource)),
painterResource(item.imageResource),
"",
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -178,7 +177,7 @@ class OnboardingComponent(
}

data class CarouselItem(
val imageResource: String,
val imageResource: DrawableResource,
val title: AnnotatedString?,
val description: AnnotatedString?,
val actionText: String,
Expand Down
Loading

0 comments on commit 3cd6e38

Please sign in to comment.