https://github.com/jyygithub/koonny-dialog
对DialogFragment进行封装
https://github.com/jyygithub/koonny-dialog
android dialog dialogfragment
Last synced: 2 months ago
JSON representation
对DialogFragment进行封装
- Host: GitHub
- URL: https://github.com/jyygithub/koonny-dialog
- Owner: jyygithub
- License: apache-2.0
- Created: 2017-08-08T13:57:46.000Z (almost 8 years ago)
- Default Branch: dev
- Last Pushed: 2023-11-06T06:59:38.000Z (over 1 year ago)
- Last Synced: 2025-03-18T01:40:35.041Z (2 months ago)
- Topics: android, dialog, dialogfragment
- Language: Kotlin
- Homepage:
- Size: 2.01 MB
- Stars: 55
- Watchers: 0
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
对DialogFragment的封装使用
## 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 jyygithubLicensed 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 athttp://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.
```