Skip to content

swatikulkarni123/QuickNotify

Repository files navigation

Compose Multiplatform Toast, Snackbar, Dialog & Custom Alert Library

QuickNotify is a Kotlin Multiplatform library (powered by Compose Multiplatform) for showing Toast messages, Snackbars, Dialogs, and custom alerts across Android, iOS, Desktop, and Web with zero setup on every platform.


Supported Platforms

Platform Support Setup required
Android Full None — auto-attaches via App Startup
iOS Full None — auto-attaches via UIKit overlay
Desktop (JVM) Full None — auto-attaches via Swing glass pane
Web (WasmJS) Full None — auto-attaches via canvas overlay

Features

  • Zero setup on all platforms — just call QuickNotify.showToast(...) anywhere
  • Global overlay auto-attaches on first use — same pattern as Android on every platform
  • Toast with text + icon + custom duration
  • Snackbar with icon + custom duration
  • Dialog with header image, title, body, up to 3 customizable buttons, optional close icon
  • Custom Overlay — show any Composable UI globally with full control over alignment and appearance
  • Coroutine-based auto-dismiss

How the auto-attach overlay works

Platform Mechanism
Android ComposeView added to the first Activity window via ActivityLifecycleCallbacks (App Startup)
Desktop ComposePanel set as the glassPane of the active JFrame
iOS ComposeUIViewController added as a child view controller on the key UIWindow's root VC
Web A full-screen <canvas> element appended above existing page content

Installation

Step 1: Add JitPack

// settings.gradle.kts
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

Step 2: Add dependency

dependencies {
    implementation("com.github.swatikulkarni123:QuickNotify:2.0.0")
}

Important — projects without a WasmJS target

QuickNotify is a Kotlin Multiplatform library that also publishes a QuickNotify-wasm-js artifact. If your project does not declare a wasmJs target, Gradle will fail with a variant resolution error similar to:

No matching variant of com.github.swatikulkarni123.QuickNotify:QuickNotify-wasm-js:x.x.x

Fix: exclude the wasm-js artifact on the dependency declaration:

implementation("com.github.swatikulkarni123:QuickNotify:2.0.0") {
    exclude(group = "com.github.swatikulkarni123.QuickNotify", module = "QuickNotify-wasm-js")
}

Usage

No setup. No wrapping. Just call it.


1. Toast

QuickNotify.showToast("Hello world!")
QuickNotify.showToast(
    message = "Saved successfully",
    duration = 2500L,
    icon = Icons.Default.Check
)

2. Snackbar

QuickNotify.showSnackbar(message = "No internet connection")
QuickNotify.showSnackbar(
    message = "Message sent",
    icon = Icons.Default.Send
)

3. Dialog

QuickNotify.showDialog(
    title = "Delete Item?",
    body = "This action cannot be undone.",

    btn1Text = "Cancel",
    btn1Color = Color.Gray,
    onBtn1Click = { },

    btn2Text = "Delete",
    btn2Color = Color.Red,
    onBtn2Click = { /* Delete logic */ }
)

Dialog with close button only

QuickNotify.showDialog(
    title = "Info",
    body = "This is a message-only dialog."
)

4. Custom Overlay

QuickNotify.showOverlay(
    overlayAlignment = Alignment.Center,
    autoCancel = false,
    content = { dismiss ->
        Card(shape = RoundedCornerShape(20.dp)) {
            Row {
                Text("Operation complete!")
                Icon(
                    imageVector = Icons.Default.Close,
                    contentDescription = null,
                    modifier = Modifier.clickable { dismiss() }
                )
            }
        }
    }
)

Manual dismiss

QuickNotifyController.clear()

License

MIT


Keywords

Compose Multiplatform Toast Compose Multiplatform Snackbar Compose Multiplatform Dialog Kotlin Multiplatform Notification Android iOS Desktop Web Compose Alert