Simple and convenient extention of the BottomSheetDialogFragment class. Use newinstance pattern for build dialog with:
- Title
- TextView body
- QR code ImageView
- Button for positive user reaction
- Button for negative user reaction
- Lamda functions for show/dismiss dialog, positive/negative action.
Like this
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.kuleshovdv:BottomFragment:0.05'
}
Example
BottomQuestionFragment.newInstance(
"Hello!",
"Click the button below",
"Positive",
"Negative",
"https://github.com/kuleshovdv/BottomFragment")
.setOnShowAction {
Log.d(TAG, "onShowAction")
binding.showAgain.visibility = View.GONE
}
.setDismissAction {
Log.d(TAG, "onDismissAction")
binding.showAgain.visibility = View.VISIBLE
}
.setPositiveAction {
Log.d(TAG, "Positive Action")
binding.lastAction.text = "Last action: POSITIVE"
}
.setNegativeAction {
Log.d(TAG, "Negative Action")
binding.lastAction.text = "Last action: NEGATIVE"
}
.show(supportFragmentManager, "test")
See more details in MainActivity.kt
If you need to start dialog from fragment
.show(childFragmentManager, "test")