Convert Figma logo to code with AI

kongzue logoDialogX

💬 DialogX dialog box component library, easy to use, more customizable, more scalable, easy to achieve a variety of dialog boxes. DialogX对话框组件库,更加方便易用,可自定义程度更高,扩展性更强,轻松实现各种对话框、菜单和提示效果,更有Material You、iOS、MIUI等主题扩展可选

2,162
228
2,162
7

Top Related Projects

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

SweetAlert for Android, a beautiful and clever alert dialog

Advanced dialog solution for android

Android下打造通用便捷的PopupWindow弹窗库

Quick Overview

DialogX is a powerful and customizable Android dialog library that provides a wide range of dialog types and styles. It offers a unified API for creating various dialogs, including message boxes, input dialogs, bottom sheets, and custom views, with support for both light and dark themes.

Pros

  • Extensive variety of dialog types and styles
  • Easy-to-use API with a fluent interface
  • Customizable appearance and animations
  • Supports both Kotlin and Java

Cons

  • Limited documentation in English
  • May have a steeper learning curve for complex customizations
  • Some features may require additional setup or dependencies

Code Examples

Creating a simple message dialog:

MessageDialog.show("Title", "This is a message", "OK")
    .setOkButton { dialog ->
        dialog.dismiss()
    }

Displaying an input dialog:

InputDialog.show("Input", "Please enter your name", "OK", "Cancel")
    .setOkButton { dialog, inputStr ->
        Toast.makeText(context, "You entered: $inputStr", Toast.LENGTH_SHORT).show()
        dialog.dismiss()
    }

Showing a bottom sheet dialog:

BottomDialog.show("Bottom Sheet Title")
    .setMessage("This is a bottom sheet dialog")
    .setOkButton("OK") { dialog ->
        dialog.dismiss()
    }

Getting Started

  1. Add the JitPack repository to your project's build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the DialogX dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.kongzue.DialogX:DialogX:0.0.47'
}
  1. Initialize DialogX in your application class:
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        DialogX.init(this)
    }
}

Now you can start using DialogX in your Android project to create various types of dialogs with ease.

Competitor Comparisons

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Pros of material-dialogs

  • More established and widely adopted in the Android community
  • Extensive documentation and examples available
  • Supports both Kotlin and Java

Cons of material-dialogs

  • Larger library size, potentially increasing app size
  • May require more setup and configuration for complex use cases

Code Comparison

material-dialogs:

MaterialDialog(this).show {
    title(R.string.your_title)
    message(R.string.your_message)
    positiveButton(R.string.agree)
    negativeButton(R.string.disagree)
}

DialogX:

MessageDialog.show("Title", "Message", "OK", "Cancel")
    .setOkButton { dialog ->
        // OK button clicked
    }
    .setCancelButton { dialog ->
        // Cancel button clicked
    }

Key Differences

  • DialogX offers a more straightforward API for basic dialog creation
  • material-dialogs provides more customization options out of the box
  • DialogX focuses on lightweight implementation and ease of use
  • material-dialogs adheres more closely to Material Design guidelines

Use Cases

  • Choose material-dialogs for projects requiring extensive customization and Material Design compliance
  • Opt for DialogX in scenarios where simplicity and minimal setup are priorities

Both libraries offer robust dialog solutions for Android development, with material-dialogs excelling in customization and DialogX in simplicity. The choice between them depends on specific project requirements and developer preferences.

SweetAlert for Android, a beautiful and clever alert dialog

Pros of sweet-alert-dialog

  • Simpler API with fewer options, making it easier to learn and use for basic dialog needs
  • Lightweight library with minimal dependencies
  • Well-established project with a long history and stable codebase

Cons of sweet-alert-dialog

  • Limited customization options compared to DialogX
  • Fewer dialog types and styles available out-of-the-box
  • Less frequent updates and maintenance

Code Comparison

sweet-alert-dialog:

new SweetAlertDialog(this)
    .setTitleText("Are you sure?")
    .setContentText("Won't be able to recover this file!")
    .setConfirmText("Yes,delete it!")
    .setConfirmClickListener(sDialog -> sDialog.dismissWithAnimation())
    .show();

DialogX:

MessageDialog.show("Title", "Content", "OK")
    .setOkButton("Yes", (baseDialog, v) -> {
        // Handle OK button click
        return false;
    })
    .setCancelButton("No")
    .setCustomView(R.layout.custom_view);

Both libraries offer easy-to-use dialog creation, but DialogX provides more extensive customization options and a wider range of dialog types. sweet-alert-dialog focuses on simplicity and ease of use for basic dialog needs, while DialogX offers greater flexibility and features for more complex dialog requirements.

Advanced dialog solution for android

Pros of DialogPlus

  • Simpler API and easier to implement for basic dialog needs
  • Lightweight library with minimal dependencies
  • Supports custom animations for dialog entry and exit

Cons of DialogPlus

  • Less customization options compared to DialogX
  • Limited built-in dialog types and styles
  • Lacks some advanced features like multi-language support and night mode

Code Comparison

DialogPlus:

new DialogPlus.Builder(this)
    .setContentHolder(new ViewHolder(R.layout.content))
    .setExpanded(true)
    .create()
    .show();

DialogX:

MessageDialog.show("Title", "Message", "OK")
    .setCustomView(R.layout.custom_view)
    .setOkButton("Confirm", (baseDialog, v) -> {
        // Handle OK button click
    });

DialogX offers a more comprehensive set of features and customization options, making it suitable for complex dialog requirements. It provides built-in support for various dialog types, themes, and animations. DialogX also includes advanced features like multi-language support and night mode.

DialogPlus, on the other hand, is a simpler library that focuses on basic dialog functionality. It's lightweight and easy to implement for straightforward use cases. While it lacks some of the advanced features of DialogX, it may be preferable for projects that require a minimal, no-frills dialog solution.

Android下打造通用便捷的PopupWindow弹窗库

Pros of BasePopup

  • More customizable and flexible, allowing for greater control over popup behavior and appearance
  • Extensive documentation and examples, making it easier for developers to implement and customize
  • Lighter weight and potentially better performance for simpler popup use cases

Cons of BasePopup

  • Steeper learning curve due to its more complex API and customization options
  • Less out-of-the-box styling and pre-built dialog types compared to DialogX
  • May require more code to achieve similar results for common dialog scenarios

Code Comparison

BasePopup:

QuickPopupBuilder.with(context)
    .contentView(R.layout.popup_content)
    .config(new QuickPopupConfig()
        .gravity(Gravity.CENTER)
        .withClick(R.id.btn_close, PopupWindow::dismiss))
    .show();

DialogX:

MessageDialog.show("Title", "Content", "OK")
    .setOkButton(new OnDialogButtonClickListener() {
        @Override
        public boolean onClick(BaseDialog baseDialog, View v) {
            return false;
        }
    });

Both libraries offer powerful dialog and popup functionality for Android applications. BasePopup provides more flexibility and customization options, making it suitable for complex scenarios, while DialogX offers a simpler API with pre-built dialog types for quicker implementation of common use cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

🌐 View English Document | 繁體中文文檔

Kongzue DialogX

一款简单易用的对话框组件,相比原生对话框使用体验更佳,可自定义程度更高,扩展性更强,轻松实现各种对话框、菜单和提示效果,更有iOS、MIUI、Material You等主题扩展可选。

DialogX

DialogX优势

对话框是软件与用户互动的关键部分,DialogX 让开发者轻松搞定这一切,我们致力于打造一款无论何时何地都能便捷使用的对话框组件,让开发者少操心、多做事,DialogX 不仅易用,还提供了丰富的个性化接口,比如自定义布局、日夜模式切换和专属 App 主题的创建

✅ DialogX 亮点

  • **多样实现**:DialogX 默认使用更轻便的 View 实现方式,也可选 Window 或 DialogFragment 等其他模式,灵活自由。
  • **线程无忧**:在任何线程启动DialogX,它都会自动在 UI 线程里运行,无需担心线程问题。
  • **一键启动**:无需 context 参数,简单一行代码就能启动对话框,超级方便。
  • 样式自定义:从标题到内容,文本、按钮、菜单和输入框或是插入自定义布局,所有组件样式都可自定义。
  • **主题多样**:自带Material主题,可选额外添加 Material You、iOS、Kongzue、MIUI 等主题风格,还支持自定义主题,减小 App 体积。
  • **低耦合度**:运行时关闭 Activity 也不怕,DialogX 能更自动销毁避免 WindowLeaked 等内存泄漏错误。
  • 动画丰富:采用非线性动画,还有流畅的等待到错误动画过渡,让APP更生动。
  • 亮暗模式:一键切换亮暗主题,自动适应系统亮暗模式,满足定制化需求。
  • 生命周期与沉浸式:轻松管理对话框生命周期,完美适配沉浸式体验。
  • 穿透能力:“临时储物柜”数据穿透和“快捷功能键”动作穿透,两大帮手助你轻松实现数据传递和灵活控制,安全又放心。

DialogX 对话框

DialogX 包含以下对话框组件:

  • 基础对话框 MessageDialog和 输入对话框 InputDialog

    基础对话框 MessageDialog和 输入对话框 InputDialog

    基础对话框组件可以实现基本的对话框业务逻辑,包含标题、消息文本、单/双/三按钮的提醒功能,三个按钮可以按照纵向/横向进行显示,满足绝大部分日常阻断式提醒需求。

    输入对话框 InputDialog 是基础对话框的扩展组件,除了包含基础的功能外还提供了输入框,可自定义输入提示文本、输入文字样式和点击按钮后的输入内容回调等。

  • 等待框 WaitDialog 和提示框 TipDialog

    等待框 WaitDialog 和提示框 TipDialog

    阻断式等待提示框,会显示基础的环形等待动画以及进度展示动画,它是单例的,这就意味着从等待状态 WaitDialog 切换到提示状态 TipDialog 是无缝的,你可以自由的选择在等待结束后显示成功/警告/错误三种状态的消息提示,动画的切换也会无缝衔接。

  • 底部对话框 BottomDialog 和底部菜单 BottomMenu

    底部对话框 BottomDialog 和底部菜单 BottomMenu

    底部对话框 BottomDialog 提供从底部弹出显示的对话框样式,可设置标题、提示文本和自定义布局,使用 Material 主题时还会提供向下滑动关闭和向上滑动展开的功能。

    底部菜单 BottomMenu 则是底部对话框 BottomDialog 的扩展组件,在底部对话框的基础上额外提供了菜单功能,菜单可设置菜单内容/菜单图标/单选功能,在不同的主题下还可以提供“取消”关闭按钮

  • 简单提示 PopTip

    简单提示 PopTip

    提供一个类似 Toast 的文本提示功能,但它拥有更强大的自定义属性。你可以设置文本提示、图标、以及一个控制按钮,并可以设置持续显示或定义自动消失的时长。PopTip 是非阻断式提示,也就是说,在 PopTip 显示时用户依然可以操作界面。

  • 简单通知提示 PopNotification

    简单通知提示 PopNotification

    提供一个类似 Notification 的通知样式提示功能,请注意,此组件并不能取代 Notification,默认不支持不能跨界面显示(可使用悬浮窗权限设置允许),仅用于应用内通知提示,拥有更强大的自定义属性。你可以设置文本提示、图标、以及一个控制按钮,并可以设置持续显示或定义自动消失的时长。PopNotification 是非阻断式提示,也就是说,在 PopNotification 显示时用户依然可以操作界面。

  • 全屏对话框 FullScreenDialog

    全屏对话框 FullScreenDialog

    全屏对话框 FullScreenDialog 提供从底部弹出的对话框效果,类似 BottomDialog 但相比 BottomDialog 的定制化自由度更高。全屏对话框 FullScreenDialog 将不提供任何基础实现,开发者可以自定义实现布局。默认只提供一个默认的下划关闭逻辑和 Activity 背景下沉的显示效果。

  • 自定义对话框 CustomDialog

    自定义对话框 CustomDialog

    根据定制化自由度的对话框组件,完全由用户自行实现布局内容。CustomDialog 提供了 ALIGN 选项可以轻松定制对话框弹出的方式,默认支持屏幕中央、屏幕底部、屏幕顶部、屏幕左侧、屏幕右侧多种弹出模式,也会提供相应的弹出动画效果,当然用户也可以自定义动画效果。

  • 引导对话框 GuideDialog

    引导对话框 GuideDialog

可以实现一个遮罩展示操作引导图,或者对按钮进行操作提示指引。GuideDialog 可以围绕一个界面上的组件显示,并实现舞台光的效果,舞台光可选圆形(外围、内侧)、方形(外围、内侧)和矩形模式,方形和矩形可设置圆角。

DialogX 主题

DialogX主题

DialogX 采用了主题分离结构,主框架仅包含 Material 设计风格的对话框组件,您可以通过额外引入主题包来实现主题的扩展。

额外的,每套主题都包含亮色/暗色两种显示风格,您可以通过 DialogX 的设置自由切换对话框的显示效果。

主题设计开发者也可以通过使用 DialogX 提供的主题定制接口来实现自定义主题,或者对现有主题进行样式调整和修改。

你还可以更深入的 了解如何使用 DialogX 主题

你还可以更深入的 了解如何开发 DialogX 主题

Demo

您可以先下载 Demo 进行尝试:http://beta.kongzue.com/DialogXDemo

下载Demo

开始使用 DialogX

因为依赖的关系,DialogX 目前仅支持 AndroidX 作为基础进行开发,若您正在使用最新版本的 Android Studio,那么默认创建的项目就是使用 AndroidX 作为底层框架的,老版本 Android Support 兼容库将在后续更新。

📥引入

请从以下两个源二选一引入项目。

MavenCentral 源(稳定版本更新)

最新版本: DialogX Release
  1. 在 project 的 build.gradle 文件中找到 allprojects{} 代码块添加以下代码:
allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()      //增加 mavenCentral 仓库
    }
}

[!TIP] 使用 Android Studio 北极狐版本(Arctic Fox)创建的项目,需要您前往 settings.gradle 添加上述 mavenCentral 仓库配置。

  1. 在 app 的 build.gradle 文件中找到 dependencies{} 代码块,并在其中加入以下语句:
def dialogx_version = "0.0.49"
implementation "com.kongzue.dialogx:DialogX:${dialogx_version}"

Jitpack 源(快速迭代测试版本更新)

最新版本: Jitpack.io 查看最新编译版本
  1. 在 project 的 build.gradle 文件中找到 allprojects{} 代码块添加以下代码:
allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }      //增加 jitPack Maven 仓库
    }
}

[!TIP] 使用 Android Studio 北极狐版本(Arctic Fox)创建的项目,需要您前往 settings.gradle 添加上述 mavenCentral 仓库配置。

  1. 在 app 的 build.gradle 文件中找到 dependencies{} 代码块,并在其中加入以下语句:
def dialogx_version = "0.0.49"
implementation "com.github.kongzue.DialogX:DialogX:${dialogx_version}"

▶️使用

如何使用

具体的使用说明,请参阅 DialogX Wiki

🧩 扩展包

目前 DialogX 依然仅提供最基础的对话框实现,不提供进阶的功能模块,这是为了避免是您的应用变得臃肿。

但为了保证一些常用功能,例如 地址选择、日期选择以及“分享到”对话框等较为通用且常见的功能更为简单的能够使用,我们提供了扩展包以满足这些需求。

扩展包中,各个模块是单独引入的,您无需担心引入不必要的功能和资源。

扩展包目前尚处于初步开发阶段,要预览或提出你的建议,请访问:DialogXSample

DialogXSample

ℹ️使用过程遇到问题?

查看 常见问题

技术支持和反馈建议可以加讨论群:590498789

反馈 DialogX

❤️Powered By DialogX

Powered By DialogX

🚀 更多 >

🔁如何从 DialogV3 迁移至 DialogX

请参考文章 从 DialogV3 迁移至 DialogX

⭐观星者

Stargazers over time

开源协议

DialogX 遵循 Apache License 2.0 开源协议。

Copyright Kongzue DialogX

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

贡献者

感谢所有为 DialogX 做出贡献的人!

如果 DialogX 帮助您更好的构建了您的软件,请为 DialogX 点一个小小的 Star,您的每一次点击对 DialogX 都是最大的支持!

Stargazers repo roster for @kongzue/DialogX

协助开发