Skip to content

Repository files navigation

Kross

A comprehensive Kotlin Multiplatform library for Android and iOS.

License Maven Central Platforms


Kross is an "all-in-one" Kotlin Multiplatform library designed to simplify cross-platform development. It provides a suite of unified, type-safe APIs for common platform tasks, starting with robust clipboard management.

Installation

Add Maven Central to your repositories:

repositories {
    mavenCentral()
}

Option 1: Full Library (Recommended)

Access all Kross features (Clipboard, etc.) through a single dependency.

// In commonMain
implementation("io.github.amanbutnot:kross:<latest>")

Option 2: Specific Modules

If you only need a specific feature, you can include individual modules.

Clipboard

// In commonMain
implementation("io.github.amanbutnot:kross-clipboard:<latest>")

Intents

// In commonMain
implementation("io.github.amanbutnot:kross-intents:<latest>")

Features

Clipboard Management

Kross Clipboard provides a type-safe, unified API to interact with system clipboards. It abstracts away platform-specific implementations like ClipboardManager on Android and UIPasteboard on iOS.

  • Unified Interface: Single API for copying and retrieving data.
  • Content Types: Native support for Plain Text, HTML, and URLs.
  • Type Safety: Leverages Kotlin sealed classes for robust data handling.
  • Lightweight: Zero third-party dependencies.

Intent Management

Kross Intents allows you to easily trigger common system actions like opening emails, maps, or settings.

  • Email, Phone, SMS: Quick access to communication apps.
  • Maps: Open locations with coordinates.
  • System Settings: Navigate directly to General settings.

Usage (Clipboard)

1. Initialization

Klipboard is initialized without arguments on all platforms.

val klipboard = Klipboard()

2. Copying Content

Use saveData with a specific KlipData type.

klipboard.saveData(KlipData.TEXT("Hello Kross"))
klipboard.saveData(KlipData.HTML("<b>Rich Text</b>"))
klipboard.saveData(KlipData.URL("https://github.com/amanbutnot/kross"))

3. Retrieving Content

Query the clipboard by passing the desired KlipType.

val text = klipboard.getData(KlipType.TEXT) as? KlipData.TEXT
val html = klipboard.getData(KlipType.HTML) as? KlipData.HTML

Usage (Intents)

Trigger common system actions using the KrossIntents singleton.

// Open Email
KrossIntents.openEmail(recipient = "test@example.com", subject = "Hi", text = "Hello from Kross!")

// Open Maps
KrossIntents.openMaps(latitude = 37.7749, longitude = -122.4194)

// Open Settings
KrossIntents.openSettings()

License

Kross is available under the Apache License 2.0. See the LICENSE file for more info.

About

All in one compose multiplatform library

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages