Use BottomDialogs in React Native
masterreact-native-bottom-action-sheet module.repository·master·Indexed 20 days ago
https://github.com/javiersantos/bottomdialogsAn Android library for creating customizable, Material-based bottom sheet dialogs. It features a Builder pattern for implementing standard dialogs or custom layouts, support for icons, positive and negative buttons with callbacks, and the ability to set custom view resources.
react-native-bottom-action-sheet module.To use BottomDialogs in your Android project, add the JitPack repository to your project-level build.gradle and then add the library dependency to your module-level build.gradle.
// Project build.gradle
repositories {
maven {
url "https://jitpack.io"
}
}
// Module build.gradle
dependencies {
compile 'com.github.javiersantos:BottomDialogs:1.2.1'
}You can add positive and negative buttons with custom text, colors, and click listeners.
.setPositiveText(String) and .setNegativeText(String) to label buttons..setPositiveBackgroundColorResource(int) or .setPositiveTextColorResource(int) for styling via resources..onPositive(BottomDialog.ButtonCallback) and .onNegative(BottomDialog.ButtonCallback) to handle clicks.Note on Dismissal Behavior:
autoDismiss() is true. If you provide a callback, the dialog dismisses automatically when the button is tapped.autoDismiss(false), you must manually call dialog.dismiss() inside your callback.new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.setPositiveText("OK")
.setPositiveBackgroundColorResource(R.color.colorPrimary)
.setPositiveTextColorResource(android.R.color.white)
.onPositive(new BottomDialog.ButtonCallback() {
@Override
public void onClick(BottomDialog dialog) {
Log.d("BottomDialogs", "Do something!");
}
}).show();Instead of the standard title/content layout, you can provide your own layout resource using .setCustomView(int layoutResId).
new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.setCustomView(R.layout.my_custom_view)
.show();Use .setCancelable(false) to prevent the user from dismissing the dialog by tapping the area outside the bottom sheet.
new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.setCancelable(false)
.show();You can display an icon to the left of the title using the .setIcon() method. Pass a drawable resource ID.
new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.setIcon(R.drawable.ic_launcher)
.show();Use the BottomDialog.Builder to create and show a simple dialog with a title and content. You can either call .show() directly on the builder or .build() the instance first to manipulate it later.
// Quick way to show a dialog
new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.show();
// Way to build and then show later
BottomDialog bottomDialog = new BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.build();
bottomDialog.show();For advanced styling that goes beyond the Builder, you can access the underlying Android View objects after building the dialog. This allows you to use standard TextView methods like setTextColor() or setTypeface().
```Java
BottomDialog bottomDialog = BottomDialog.Builder(this)
.setTitle("Awesome!")
.setContent("What can we improve? Your feedback is always welcome.")
.build();
// Access views directly to apply custom styles
bottomDialog.getTitleTextView().setTextColor(Color.parseColor("#8f000000"));
bottomDialog.getTitleTextView().setTypeface(BaseActivity.getFont(Fonts.SEMI_BOLD));
bottomDialog.show();Available view accessors:
getIconImageView()getTitleTextView()getContentTextView()getNegativeButton()getPositiveButton()