diff --git a/.editorconfig b/.editorconfig
index b00acaa..913b1a0 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -11,6 +11,10 @@ trim_trailing_whitespace = true
indent_size = 2
indent_style = space
+[*.md]
+indent_size = 4
+indent_style = space
+
# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
max_line_length = 120
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d234a14..c25bfa0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,6 +10,8 @@ on:
- '.gitignore'
- 'renovate.json'
- 'FUNDING.yml'
+ - 'docs/**'
+ - 'mkdocs.yaml'
workflow_dispatch:
env:
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..17c196d
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,47 @@
+name: Publish Docs
+on:
+ push:
+ branches:
+ - master
+ - docs/**
+ paths:
+ - 'docs/**'
+ - mkdocs.yml
+ - '.github/workflows/docs.yml'
+ # Manual triggers
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+concurrency:
+ group: ${{ github.ref }}
+ cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
+
+jobs:
+ publish-docs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v5
+ with:
+ fetch-depth: 0
+
+ - name: Configure Git Credentials
+ run: |
+ git config user.name github-actions[bot]
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.11'
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
+
+ - uses: actions/cache@v4
+ with:
+ key: mkdocs-material-${{ env.cache_id }}
+ path: ~/.cache
+ restore-keys: |
+ mkdocs-material-
+ - run: pip install -r .github/workflows/requirements.txt
+
+ - run: mkdocs gh-deploy --force
+
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 1960a9d..cb09e17 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -11,6 +11,8 @@ on:
- '.github/**'
- '!.github/workflows/**'
- 'renovate.json'
+ - 'docs/**'
+ - 'mkdocs.yaml'
env:
JAVA_VERSION: 17
diff --git a/.github/workflows/requirements.txt b/.github/workflows/requirements.txt
new file mode 100644
index 0000000..43ae21a
--- /dev/null
+++ b/.github/workflows/requirements.txt
@@ -0,0 +1,9 @@
+mkdocs-material
+mkdocs-git-revision-date-localized-plugin
+mkdocs-awesome-nav
+pymdown-extensions
+
+# Imaging dependencies for mkdocs-material social plugin
+# https://squidfunk.github.io/mkdocs-material/plugins/requirements/image-processing/
+cairosvg==2.8.2
+pillow==11.3.0
\ No newline at end of file
diff --git a/README.md b/README.md
index 56db4e4..d127945 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,13 @@
# compose-floating-window
-[](https://jitpack.io/#User/Repo)
+[](https://jitpack.io/#ArthurKun21/compose-overlay-window)
[](https://opensource.org/licenses/Apache-2.0)
Global Floating Window Framework based on Jetpack Compose
-[简体中文](README_CN.md)
-
## Preview
-
+
## Features
@@ -18,117 +16,6 @@ Global Floating Window Framework based on Jetpack Compose
- Support for draggable floating windows.
- Dialog components based on the Application Context.
-## Basic Usage
-
-### Import Dependencies
-
-- If the Gradle version is less than 7.0, add the Jitpack repository in the `build.gradle` of your app.
-
-```groovy
-repositories {
- maven { url 'https://jitpack.io' }
-}
-```
-
-- If the Gradle version is greater than or equal to 7.0, add it in the settings.gradle file.
-```groovy
-dependencyResolutionManagement {
- repositories {
- maven { url 'https://jitpack.io' }
- }
-}
-```
-
-- Add `compose-floating-window` Dependency
-```groovy
-dependencies {
- implementation "com.github.only52607:compose-floating-window:1.0"
-}
-```
-
-### Grant Floating Window Permission
-
-Add to `AndroidManifest.xml`
-```xml
-
-```
-
-### Create Floating Window and Show
-
-```kotlin
-val floatingWindow = ComposeFloatingWindow(applicationContext)
-floatingWindow.setContent {
- FloatingActionButton(
- modifier = Modifier.dragFloatingWindow(),
- onClick = {
- Log.i("")
- }) {
- Icon(Icons.Filled.Call, "Call")
- }
-}
-floatingWindow.show()
-```
-
-> See [Sample App](https://github.com/only52607/compose-floating-window/tree/master/app).
-
-## Advanced Usage
-
-### Make Floating Window Draggable
-
-Use the `Modifier.dragFloatingWindow()` modifier on the component you want to make draggable. Example:
-
-```kotlin
-FloatingActionButton(
- modifier = Modifier.dragFloatingWindow()
-) {
- Icon(Icons.Filled.Call, "Call")
-}
-```
-
-### Get the current instance of `ComposeFloatingWindow`
-
-Using LocalComposeFloatingWindow to retrieve, here's an example:
-
-```kotlin
-val floatingWindow = LocalComposeFloatingWindow.current
-```
-
-### Show Dialog
-
-When the Context of the floating window is set to Application, using AlertDialog and Dialog in the Compose interface of the floating window may result in a 'token is null' exception. In such cases, you can use the SystemAlertDialog or SystemDialog components, which can be used in the same way as the built-in AlertDialog and Dialog components.
-
-Example:
-```kotlin
-SystemAlertDialog(
- onDismissRequest = { showDialog = false },
- confirmButton = {
- TextButton(onClick = { showDialog = false }) {
- Text(text = "OK")
- }
- },
- text = {
- Text(text = "This is a system dialog")
- }
-)
-```
-
-### ViewModel
-
-You can access the ViewModel from any Composable by calling the viewModel() function.
-
-```kotlin
-class MyViewModel : ViewModel() { /*...*/ }
-
-@Composable
-fun MyScreen(
- viewModel: MyViewModel = viewModel()
-) {
- // use viewModel here
-}
-```
-
-> See https://developer.android.com/jetpack/compose/libraries#viewmodel
-
## License
-Apache 2.0 License
\ No newline at end of file
+Apache 2.0 License
diff --git a/README_CN.md b/README_CN.md
deleted file mode 100644
index eeec8fa..0000000
--- a/README_CN.md
+++ /dev/null
@@ -1,132 +0,0 @@
-# compose-floating-window
-
-[](https://jitpack.io/#User/Repo)
-[](https://opensource.org/licenses/Apache-2.0)
-
-基于Jetpack Compose的全局悬浮窗框架
-
-## 效果预览
-
-
-
-## 特性
-
-- 使用Compose代码描述悬浮窗界面
-- ViewModel支持
-- 可拖拽悬浮窗支持
-- 基于Application Context的对话框组件
-
-## 基本使用
-
-### 导入依赖
-
-- 如果Gradle版本小于7.0,在应用的`build.gradle`中,添加Jitpack仓库
-
-```groovy
-repositories {
- maven { url 'https://jitpack.io' }
-}
-```
-
-- 如果Gradle版本大于等于7.0,在 settings.gradle 文件中加入
-```groovy
-dependencyResolutionManagement {
- repositories {
- maven { url 'https://jitpack.io' }
- }
-}
-```
-
-- 添加ComposeFloatingWindow依赖
-```groovy
-dependencies {
- implementation "com.github.only52607:ComposeFloatingWindow:1.0"
-}
-```
-
-### 增加悬浮窗权限
-
-在`AndroidManifest.xml`中添加
-```xml
-
-```
-
-### 创建悬浮窗并显示
-
-```kotlin
-val floatingWindow = ComposeFloatingWindow(applicationContext)
-floatingWindow.setContent {
- FloatingActionButton(
- modifier = Modifier.dragFloatingWindow(),
- onClick = {
- Log.i("")
- }) {
- Icon(Icons.Filled.Call, "Call")
- }
-}
-floatingWindow.show()
-```
-
-> 查看[示例程序](https://github.com/only52607/compose-floating-window/tree/master/app),了解详细用法。
-
-## 高级用法
-
-### 创建可拖拽的悬浮窗
-
-在需要拖拽的组件上使用`Modifier.dragFloatingWindow()`修饰符,示例:
-
-```kotlin
-FloatingActionButton(
- modifier = Modifier.dragFloatingWindow()
-) {
- Icon(Icons.Filled.Call, "Call")
-}
-```
-
-### 获取当前ComposeFloatingWindow实例
-
-使用`LocalComposeFloatingWindow`获取,示例:
-
-```kotlin
-val floatingWindow = LocalComposeFloatingWindow.current
-```
-
-### 显示对话框
-
-当悬浮窗的Context为Application时,在悬浮窗的Compose界面中使用`AlertDialog`和`Dialog`会出现token is null异常,这时可使用`SystemAlertDialog`或`SystemDialog`组件,用法与自带的`AlertDialog`和`Dialog`一致。
-
-示例:
-```kotlin
-SystemAlertDialog(
- onDismissRequest = { showDialog = false },
- confirmButton = {
- TextButton(onClick = { showDialog = false }) {
- Text(text = "OK")
- }
- },
- text = {
- Text(text = "This is a system dialog")
- }
-)
-```
-
-### 使用ViewModel
-
-通过调用 viewModel() 函数,从任何可组合项访问 ViewModel。
-
-```kotlin
-class MyViewModel : ViewModel() { /*...*/ }
-
-@Composable
-fun MyScreen(
- viewModel: MyViewModel = viewModel()
-) {
- // use viewModel here
-}
-```
-
-> 详情请参照[Android文档](https://developer.android.com/jetpack/compose/libraries#viewmodel)
-
-## License
-
-Apache 2.0 License
\ No newline at end of file
diff --git a/docs/.nav.yml b/docs/.nav.yml
new file mode 100644
index 0000000..d921fbc
--- /dev/null
+++ b/docs/.nav.yml
@@ -0,0 +1,2 @@
+nav:
+ - Overview: index.md
\ No newline at end of file
diff --git a/preview/example.gif b/docs/assets/example.gif
similarity index 100%
rename from preview/example.gif
rename to docs/assets/example.gif
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..d6b54c9
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,37 @@
+# Compose Floating Window
+
+Compose Floating Window is a global floating window framework based on Jetpack Compose.
+
+
+
+## Download
+
+[](https://jitpack.io/#ArthurKun21/compose-overlay-window)
+
+``` kotlin
+dependencyResolutionManagement {
+ repositories {
+ maven { url 'https://jitpack.io' }
+ }
+}
+
+dependencies {
+ implementation("com.github.ArthurKun21:compose-floating-window:")
+}
+```
+
+## Permissions
+
+Add to `AndroidManifest.xml`
+
+```xml
+
+```
+
+## Acknowledgements
+
+The initial implementation of this library is based on [https://github.com/only52607/compose-floating-window](https://github.com/only52607/compose-floating-window)
+
+## License
+
+[](https://opensource.org/licenses/Apache-2.0)
\ No newline at end of file
diff --git a/mkdocs.yaml b/mkdocs.yaml
new file mode 100644
index 0000000..b005869
--- /dev/null
+++ b/mkdocs.yaml
@@ -0,0 +1,59 @@
+site_name: Compose Floating Window
+site_url: https://arthurkun21.github.io/compose-overlay-window
+site_description: Global Floating Window Framework based on Jetpack Compose
+repo_name: Compose Floating Window
+repo_url: https://github.com/ArthurKun21/compose-overlay-window
+use_directory_urls: true
+theme:
+ name: material
+ palette:
+ # Palette toggle for light mode
+ - scheme: default
+ primary: red
+ toggle:
+ icon: material/brightness-7
+ name: Switch to dark mode
+
+ # Palette toggle for dark mode
+ - scheme: slate
+ primary: red
+ toggle:
+ icon: material/brightness-4
+ name: Switch to light mode
+
+ features:
+ - navigation.tabs
+ - navigation.tabs.sticky
+ - navigation.top
+ - navigation.footer
+ - navigation.sections
+ - navigation.expand
+ - navigation.path
+ - toc.follow
+ - toc.integrate
+ - search.suggest
+ - search.share
+ - search.highlight
+ - content.tabs.link
+ - content.code.copy
+plugins:
+ - search
+ - awesome-nav
+ - tags
+ - git-revision-date-localized:
+ type: date
+ enable_creation_date: true
+ - social
+ - meta
+markdown_extensions:
+ - admonition
+ - def_list
+ - toc:
+ permalink: true
+ - footnotes
+ - tables
+ - pymdownx.details
+ - pymdownx.superfences
+ - pymdownx.betterem
+ - pymdownx.tasklist:
+ custom_checkbox: true