Skip to content

Latest commit

 

History

History
91 lines (66 loc) · 1.95 KB

File metadata and controls

91 lines (66 loc) · 1.95 KB

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