🤖 🍏
This project is named after the Kaluga, the world's biggest freshwater fish, which is found in the icy Amur river.
Kaluga's main goal is to provide access to common features used in cross-platform mobile app development, separated into modules such as architecture (MVVM), location, permissions, bluetooth etc.
To reach this goal it uses Kotlin, specifically Kotlin Multiplatform which allows running Kotlin code not just on JVM+Android, but also iOS/iPadOS, amongst others (inndeed some kaluga modules also work for Kotlin.js and/or JVM standalone).
Where appropriate coroutines and Flow
are used in the API. This enables developers to use cold streams for a modern and efficient design.
While Kaluga modules can be used individually, together they form a comprehensive approach to cross-platform development with shared native code and native UIs, including SwiftUI and Compose.
Short examples
With Kaluga it is possible to create cross-platform functionality in a few lines of code, that would normally take many lines of code even on just one platform.
Below are some examples, using a commonMain
source-set:
Scanning for nearby devices with Bluetooth LE:
BluetoothBuilder().create().devices().collect {
i("discovered device: $it")
}
Showing a spinner while doing some work:
suspend fun doWork(hudBuilder: HUD.Builder) {
hudBuilder.presentDuring {
delay(1000)
}
}
in this case, since HUD is a UI component the builder needs to be configured on the platform side:
val builder = HUD.Builder()
builder.subscribe(activity)
builder.unsubscribe(activity)
However Kaluga's architecture module offers a cross-platform LifecycleViewModel
class (which extends androidx.lifecycle.ViewModel
on Android) that will automatically bind the builder to its lifecycle:
class HudViewModel(private val hudBuilder: HUD.Builder): BaseLifecycleViewModel(hudBuilder) {
suspend fun doWork() =
hudBuilder.presentDuring {
delay(1000)
}
}
More examples
Kaluga contains an example project that is used to test the developed modules.
Using Kaluga
For starting a new project based on Kaluga see the kaluga-starter repo, which shows how to do this step by step.
Kaluga is available on Maven Central. For example the Kaluga Alerts can be imported like this:
repositories {
mavenCentral()
}
dependencies {
implementation("com.splendo.kaluga:alerts:$kalugaVersion")
}
You can also use the SNAPSHOT
version based on the latest in the develop
branch:
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("com.splendo.kaluga:alerts:$kalugaDevelopVersion-SNAPSHOT")
}
To use kaluga with SwiftUI and/or Combine we have a repo with Sourcery templates to generate some Swift code to help get you started.
Available Modules
Module | Usage | Artifact Name |
---|
alerts | Used for Showing Alert Dialogs | com.splendo.kaluga:alerts |
architecture | MVVM architecture | com.splendo.kaluga:architecture |
architecture-compose | Compose extensions for architecture | com.splendo.kaluga:architecture-compose |
base | Core components of Kaluga. Contains threading, flowables and localization features | com.splendo.kaluga:base |
beacons | Tracking the availability of Beacons using the Eddystone protocol | com.splendo.kaluga:beacons |
bluetooth | Scanning for and communicating with BLE devices | com.splendo.kaluga:bluetooth |
date-time | Contains multiplatform classes to work with date and time | com.splendo.kaluga:date-time |
date-timepicker | Used for showing a Date or Time Picker | com.splendo.kaluga:date-time-picker |
hud | Used for showing a Loading indicator HUD | com.splendo.kaluga:hud |
keyboard | Used for showing and hiding the keyboard | com.splendo.kaluga:keyboard |
keyboard-compose | Compose extensions for keyboard | com.splendo.kaluga:keyboard-compose |
links | Used for decoding url into an object | com.splendo.kaluga:links |
location | Provides the User' geolocation | com.splendo.kaluga:location |
logging | Shared console logging | com.splendo.kaluga:logging |
media | Playing audio/video | com.splendo.kaluga:media |
base-permissions | Managing permissions, used in conjunction with modules below | com.splendo.kaluga:base-permissions |
bluetooth-permissions | Managing bluetooth permissions | com.splendo.kaluga:bluetooth-permissions |
calendar-permissions | Managing calendar permissions | com.splendo.kaluga:calendar-permissions |
camera-permissions | Managing camera permissions | com.splendo.kaluga:camera-permissions |
contacts-permissions | Managing contacts permissions | com.splendo.kaluga:contacts-permissions |
location-permissions | Managing location permissions | com.splendo.kaluga:location-permissions |
microphone-permissions | Managing microphone permissions | com.splendo.kaluga:microphone-permissions |
notifications-permissions | Managing notifications permissions | com.splendo.kaluga:notifications-permissions |
storage-permissions | Managing storage permissions | com.splendo.kaluga:storage-permissions |
resources | Provides shared Strings, Images, Colors and Fonts | com.splendo.kaluga:resources |
resources-compose | Compose extensions for resources | com.splendo.kaluga:resources-compose |
resources-databinding | Data Binding extensions for resources | com.splendo.kaluga:resources-databinding |
review | Used for requesting the user to review the app | com.splendo.kaluga:review |
scientific | Scientific units and conversions | com.splendo.kaluga:scientific |
service | Used for adding services to Kaluga | com.splendo.kaluga:service |
system | System APIs such as network, audio, battery | com.splendo.kaluga:system |
test-utils | Enables easier testing of Kaluga components | com.splendo.kaluga:test-utils |
test-utils-base | Enables easier testing of Kaluga components | com.splendo.kaluga:test-utils-base |
test-utils-alerts | Enables easier testing of Alerts module | com.splendo.kaluga:test-utils-alerts |
test-utils-architecture | Enables easier testing of Architecture module | com.splendo.kaluga:test-utils-architecture |
test-utils-bluetooth | Enables easier testing of Bluetooth module | com.splendo.kaluga:test-utils-bluetooth |
test-utils-date-time-picker | Enables easier testing of Date Time Picker module | com.splendo.kaluga:test-utils-date-time-picker |
test-utils-hud | Enables easier testing of HUD module | com.splendo.kaluga:test-utils-hud |
test-utils-keyboard | Enables easier testing of Keyboard module | com.splendo.kaluga:test-utils-keyboard |
test-utils-koin | Enables easier testing with Koin | com.splendo:kaluga.test-utils-koin |
test-utils-location | Enables easier testing of Location module | com.splendo.kaluga:test-utils-location |
test-utils-permissions | Enables easier testing of Permissions modules | com.splendo.kaluga:test-utils-permissions |
test-utils-resources | Enables easier testing of Resources module | com.splendo.kaluga:test-utils-resources |
test-utils-service | Enables easier testing of Service module | com.splendo.kaluga:test-utils-service |
test-utils-system | Enables easier testing of System module | com.splendo.kaluga:test-utils-system |
Friends of kaluga
Of course not every possible functionality is provided by kaluga. However, this is often because other good multiplatform libraries that work nicely with kaluga already exist. These use similar patterns such as coroutines and Flow
, and include the following:
Kaluga also uses some multiplatform libraries itself, so our thanks to:
Project | Usage |
---|
Napier | powers the logging module |
Koin | dependency injection |
Developing Kaluga
see DEVELOP.