fahimfarhan / kmmapp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KMM App Demo

  • Initially, creating kmm project gives you a hello world project. It has compose-android app, and an ios app.
  • Since our existing codebase (b2b, b2c etc) don't use compose, but xml, fragments, etc, we need to convert this compose app into a normal app
  • In androidApp/build.gradle.kts, make the following changes:
android {
    buildFeatures {
        compose = false
        viewBinding = true
        dataBinding = true
    }
}

dependencies {
    // kmm android-ios shared module
    implementation(project(":shared"))
    // AppCompatActivity
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("androidx.appcompat:appcompat-resources:1.6.1")
    // ConstraintLayout
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
}

In res/values/styles.xml, make the change: <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar" /> Finally, create a res/layout/activity_main.xml, and make some changes in MainActivity.kt. Remove compose related codes.

  • Warning: SqlDelight has changed package name, so use app.cash.sqldelight, not the old one.

References

Sharing viewModel

About

License:Creative Commons Attribution 4.0 International


Languages

Language:Kotlin 80.6%Language:Swift 19.4%