An open API service indexing awesome lists of open source software.

https://github.com/jyygithub/koonny-dialog

对DialogFragment进行封装
https://github.com/jyygithub/koonny-dialog

android dialog dialogfragment

Last synced: 2 months ago
JSON representation

对DialogFragment进行封装

Awesome Lists containing this project

README

        


对DialogFragment的封装使用




minSdk
Maven Central
GitHub
GitHub code size in bytes
GitHub top language

## Gradle

```groovy
implementation 'com.koonny.dialog:dialog:LATEST_VERSION'
```

## 使用文档

### 内置Dialog

- ConfirmDialog

```kotlin
ConfirmDialog()
.title("提示")
.message("确认退出当前账号?")
.positive("Go") {
dismiss()
}
.negative("YES")
.show(supportFragmentManager)
```

- BottomListDialog

```kotlin
BottomListDialog()
.title("提示")
.negative("Go") {
setTextColor(Color.RED)
setTypeface(null, Typeface.BOLD)
}
.items("Item1", "Item2", "Item3") { _, _ ->

}
.show(supportFragmentManager)
```

```kotlin
BottomListDialog()
.title("提示")
.negative("Go")
.bind { user -> user.name }
.items(User("张三"), User("李四")) { _, _ ->

}
.show(supportFragmentManager)
```

- BottomMenuDialog

```kotlin
BottomMenuDialog()
.title("提示")
.negative("Go")
.items("Item1" to R.mipmap.ic_launcher, "Item2" to R.mipmap.ic_launcher, "Item3" to R.mipmap.ic_launcher) {

}
.show(supportFragmentManager)
```

### 自定义Dialog

- 自定义

```kotlin
class CustomDialog : BaseDialogFragment(R.layout.dialog_custom) {

private lateinit var binding: DialogCustomBinding

override fun config(): DialogConfig {
return super.config().apply {
width = 0.7f
gravity = Gravity.CENTER
dismissOnBackPressed = false
dismissOnTouchOutside = false
}
}

override fun preView(rootView: View) {
binding = DialogCustomBinding.bind(rootView)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.image.load("https://s1.ax1x.com/2023/03/01/ppia5Wj.png")
binding.ivClose.setOnClickListener { dismiss() }
}

}
```

- 直接使用

```kotlin
CustomDialog().show(supportFragmentManager)
```

## Licenses

```
Copyright 2023 jyygithub

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.
```