Skip to content

Library for creating global floating windows based on jetpack compose on Android.

License

Notifications You must be signed in to change notification settings

ArthurKun21/compose-overlay-window

 
 

Repository files navigation

compose-floating-window

Release License

Global Floating Window Framework based on Jetpack Compose

Preview

Preview

Features

  • Using Compose code to describe the floating window interface.
  • ViewModel support.
  • Support for draggable floating windows.
  • Dialog components based on the Application Context.

Basic Usage

Import Dependencies

  • Add on settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        maven { url = uri("https://jitpack.io") }
    }
}
  • Add compose-floating-window Dependency
dependencies {
    implementation("com.github.ArthurKun21:compose-overlay-window:<tag>")
}

Grant Floating Window Permission

Add to AndroidManifest.xml

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

Activity

When you want to show the floating window while on the Activity, you can use the following code:

val floatingWindow = ComposeFloatingWindow(applicationContext)
floatingWindow.setContent {
    FloatingActionButton(
        modifier = Modifier.dragFloatingWindow(),
        onClick = {
            Log.i("")
        }) {
        Icon(Icons.Filled.Call, "Call")
    }
}
floatingWindow.show()

Service

When you want to show the floating window while on the Service, you can use the following code:

val floatingWindow = ComposeServiceFloatingWindow(applicationContext)
floatingWindow.setContent {
    FloatingActionButton(
        modifier = Modifier.dragFloatingWindow(),
        onClick = {
            Log.i("")
        }) {
        Icon(Icons.Filled.Call, "Call")
    }
}
floatingWindow.show()

Advanced Usage

See Sample Apps.

License

Apache 2.0 License

About

Library for creating global floating windows based on jetpack compose on Android.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages

  • Kotlin 98.0%
  • Dockerfile 2.0%