Skip to content

Android library to implement iOS's UIActionSheet-like popup using BottomSheetDialog

License

Notifications You must be signed in to change notification settings

AungThiha/BottomActionDialog

Repository files navigation

BottomActionDialog

BottomSheetDialog with iOS UIActionSheet design. Inspiration taken from ActionSheet. The difference is when the ActionSheet is invoked from a FragmentDialog, it's shown beneath the FragmentDialog and won't be visible to users. This library solves that problem by using BottomSheetDialog from support design library.

Demo Gif

Usage

Add dependency

dependencies {
    implementation 'thiha.aung.bottomactiondialog:bottomactiondialog:1.0.1'
}

Create BottomActionDialog and show

new BottomActionDialog.Builder(this)
    .setCancelButtonTitle("Cancel")
    .setOtherButtonTitles("Item1", "Item2", "Item3", "Item4")
    .setOnOtherButtonClickedListener(new BottomActionDialog.OnOtherButtonClickedListener() {
        @Override
        public void onClick(DialogInterface dialog, int position) {
        }
    })
    .setCancelable(true)
    .show();

Methods

  • setCancelButtonTitle() Cancel button title, (CharSequence)
  • setOtherButtonTitles() Item buttons title,(CharSequence[])
  • setCancelable() Touch outside or tap back key to close, (boolean)
  • setOnOtherButtonClickedListener() set a Listener to listen button click event
  • show() Show BottomActionDialog, return BottomActionDialog Object

Listen event

implementing OnOtherButtonClickedListener interface.

  • onClick() Click item event,dialog is the DialogInterface and position is item index.
@Override
public void onClick(DialogInterface dialog, int position) {
    Toast.makeText(getApplicationContext(), "click item index = " + position,
            0).show();
}

Style

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="bottomActionDialogStyle">@style/DemoBottomActionDialogStyle</item>
</style>
 <style name="DemoBottomActionDialogStyle" parent="BottomActionDialogStyle">
    <item name="bottomActionDialogBackground">@android:color/transparent</item>
    <item name="cancelButtonBackground">@drawable/slt_as_ios7_cancel_bt</item>
    <item name="otherButtonTopBackground">@drawable/slt_as_ios7_other_bt_top</item>
    <item name="otherButtonMiddleBackground">@drawable/slt_as_ios7_other_bt_middle</item>
    <item name="otherButtonBottomBackground">@drawable/slt_as_ios7_other_bt_bottom</item>
    <item name="otherButtonSingleBackground">@drawable/slt_as_ios7_other_bt_single</item>
    <item name="cancelButtonTextColor">#1E82FF</item>
    <item name="otherButtonTextColor">#1E82FF</item>
    <item name="bottomActionDialogPadding">10dp</item>
    <item name="otherButtonSpacing">0dp</item>
    <item name="cancelButtonMarginTop">10dp</item>
    <item name="bottomActionDialogTextSize">16sp</item>
</style>

Style attributes

  • bottomActionDialogBackground
  • cancelButtonBackground
  • otherButtonTopBackground
  • otherButtonMiddleBackground
  • otherButtonBottomBackground
  • otherButtonSingleBackground
  • cancelButtonTextColor
  • otherButtonTextColor
  • bottomActionDialogPadding
  • otherButtonSpacing
  • cancelButtonMarginTop
  • bottomActionDialogTextSize

About

Android library to implement iOS's UIActionSheet-like popup using BottomSheetDialog

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages