From c82fdb8e8123fbab9cce8894425df41378c05dfe Mon Sep 17 00:00:00 2001 From: Mazen Rashed Date: Sat, 16 Jan 2021 22:05:34 +0200 Subject: [PATCH] Create README.md --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8db8cc --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# BottomSheetMenu +You can create awesome menus with bottom sheet experience in a few lines + +[![](https://jitpack.io/v/mazenrashed/BottomSheetMenu.svg)](https://jitpack.io/#mazenrashed/BottomSheetMenu) + +![](https://im2.ezgif.com/tmp/ezgif-2-1b238086a05a.gif) + + +### Add the JitPack repository to your build file +```groovy +allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } + } +} +``` +### Add dependency +```groovy +dependencies { + implementation 'com.github.mazenrashed:BottomSheetMenu:${LAST_VERSION}' +} +``` +# How to use + +### Create a menu +```xml + + + + +``` + +### Use BottomSheetMenu builder +```kotlin +val bottomSheet = MenuBottomSheet.Builder() + .setMenuRes(R.menu.test_menu) + .closeAfterSelect(true) + .build() +``` + +* You can add the menu items programmatically without menu file +```kotlin +val menuItems = arrayListOf( + MenuBottomSheetItem("Turn alarm on", R.drawable.ic_baseline_alarm_on_24), + MenuBottomSheetItem("Turn alarm off", R.drawable.ic_baseline_alarm_off_24) +) + +val bottomSheet = MenuBottomSheet.Builder() + .setMenuItems(menuItems) + .closeAfterSelect(true) + .build() + ``` + +### Show menu +```kotlin +bottomSheet.show(this) +``` + +### Listen to on item click +```kotlin +bottomSheet.onSelectMenuItemListener = { position: Int, id: Int? -> + when (id) { + R.id.option1 -> Toast.makeText(this, "On", Toast.LENGTH_SHORT).show() + R.id.option2 -> Toast.makeText(this, "Off", Toast.LENGTH_SHORT).show() + else -> Toast.makeText(this, "Nothing", Toast.LENGTH_SHORT).show() + } +} ``` +``` +## Contributing + +We welcome contributions ! +* ⇄ Pull requests and ★ Stars are always welcome.