JindongJindong

Getting Started

Installation and setup guide for Jindong

Getting Started

This guide will help you add Jindong to your Kotlin Multiplatform project.

Module Architecture

Jindong is split into two modules to support different use cases:

ModuleDescriptionCompose Required
jindong-composeDeclarative DSL with Compose RuntimeYes
jindong-coreCore API without Compose dependencyNo

Which Module Should I Use?

  • Compose Multiplatform users: Use jindong-compose (recommended for most users)
  • Non-Compose projects: Use jindong-core
  • Both: Just add jindong-compose (it includes jindong-core transitively)
jindong-compose ──depends on──▶ jindong-core

Requirements

Platform Requirements

PlatformMinimum Version
AndroidAPI 26
iOSiOS 13

Project Requirements

  • Kotlin 2.0+
  • Compose Multiplatform (for jindong-compose)

Installation

Add jindong-compose to your build.gradle.kts:

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("io.github.compose-jindong:jindong-compose:<version>")
        }
    }
}

For Non-Compose Projects

If you don't use Compose Runtime, add jindong-core:

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("io.github.compose-jindong:jindong-core:<version>")
        }
    }
}

Migration from Previous Version

Breaking Change: The single jindong module has been split into jindong-compose and jindong-core.

Dependency Update

kotlin {
    sourceSets {
        commonMain.dependencies {
-           implementation("io.github.compose-jindong:jindong:<version>")
+           implementation("io.github.compose-jindong:jindong-compose:<version>")
        }
    }
}

Import Paths

Good news: Import paths remain unchanged for Compose users.

APIPackageChanged?
Compose APIio.github.compose.jindong.*No change
Compose DSLio.github.compose.jindong.dsl.*No change
Core APIio.github.compose.jindong.core.*New

Platform Setup

Android

Add the vibration permission to your AndroidManifest.xml:

<uses-permission android:name="android.permission.VIBRATE" />

iOS

No additional setup required. Core Haptics is available on iOS 13+.

Not all iOS devices support haptic feedback. Jindong gracefully handles devices without haptic capabilities.

Basic Setup (Compose)

1. Wrap with JindongProvider

Wrap your app content with JindongProvider to enable haptic feedback:

@Composable
fun App() {
    JindongProvider {
        // Your app content
        MainScreen()
    }
}

The provider:

  • Creates a platform-specific HapticExecutor
  • Makes it available throughout the composition tree
  • Handles resource cleanup automatically

2. Use Jindong

Now you can use Jindong anywhere in your composition:

@Composable
fun MainScreen() {
    var tapCount by remember { mutableStateOf(0) }
 
    Jindong(tapCount) {
        Haptic(100.ms)
    }
 
    Button(onClick = { tapCount++ }) {
        Text("Tap for haptic")
    }
}

Basic Setup (Core API)

For non-Compose projects, use HapticManager and buildHapticPattern:

import io.github.compose.jindong.core.*
import io.github.compose.jindong.core.dsl.*
import kotlin.time.Duration.Companion.ms
 
// Build a pattern
val pattern = buildHapticPattern {
    haptic(100.ms)
    delay(50.ms)
    haptic(100.ms)
}
 
// Execute (suspend function)
suspend fun triggerHaptic() {
    pattern.play()
}
 
// Or fire-and-forget
fun triggerHapticAsync() {
    pattern.playAsync()
}

See Core API Guide for more details.

Verifying Installation

Create a simple test to verify everything works:

@Composable
fun HapticTest() {
    var trigger by remember { mutableStateOf(0) }
 
    JindongProvider {
        Jindong(trigger) {
            Haptic(100.ms, HapticIntensity.STRONG)
        }
 
        Button(onClick = { trigger++ }) {
            Text("Test Haptic")
        }
    }
}

Run on a physical device (haptics don't work on emulators/simulators) and tap the button. You should feel a haptic pulse.

Troubleshooting

No haptic on Android

  • Ensure VIBRATE permission is declared
  • Test on a physical device
    • Check if device has vibration hardware

No haptic on iOS

  • Test on a physical device
    • Simulators don't support haptics
  • Verify iOS 13+ deployment target
  • Some older devices don't have haptic hardware

Compilation errors

  • Verify Kotlin version compatibility
  • Ensure Compose Runtime is not conflicting with other dependencies
  • Check that you're using the correct Gradle configuration

Next Steps