Code Monkey home page Code Monkey logo

sheetmenu's Introduction

sheetmenu

Library for speedy implementation menu with BottomSheet

Release

Screenshot

Usage

Use it in Kotlin

SheetMenu("Post", listOf("Send mail", "Send telegram", "Receive parcel")).show(this)

Apply not required params for more customization

SheetMenu(
    title = "Post",
    menu = R.menu.my_custom_menu, // you can just pass menu resource if you need static items
//  actions = listOf(ActionItem(id = 0, title = "Send mail", image = getDrawableIcon())), // or create ActionItem when you need dynamic titles of icons
//  actions = listOf("Send mail", "Send telegram", "Receive parcel"), // also, you can simplify it by passing strings for showing only text of items
    layoutProvider = LinearLayoutProvider(), // linear layout enabled by default
//  layoutProvider = GridLayoutProvider() // but if you need grid, you can do it
//  layoutProvider = object: LayoutProvider { ... } // also, you can define your own layout
    onClick = { item -> Toast.makeText(this, item.title, Toast.LENGTH_SHORT).show() }, // handle clicks on item
    onCancel = { Toast.makeText(this, "Closed", Toast.LENGTH_SHORT).show() } // handle close event
).show(this)

Install

Be sure, that you have Jitpack in your root gradle file

allprojects {
    repositories {
      jcenter()
+     maven { url "https://jitpack.io" }
    }
}

Include dependency with SheetMenu in your app.gradle file with:

implementation 'com.github.whalemare:sheetmenu:2.0.2'

Roadmap

[] Customization layout of ActionItem

License

Licensed 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 at

   http://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.

sheetmenu's People

Contributors

indrih17 avatar whalemare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sheetmenu's Issues

How to remove icon area?

Thank you for make useful library.

I want show just only title in sheet. But icon area show always. Is possible remove icon area?

This is my code.

<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item
    android:id="@+id/menu_choose_photo"
    android:title="Choose"/>
  <item
    android:id="@+id/menu_remove_photo"
    android:title="remove"/>
</menu>
 SheetMenu.with(ProfileInputActivity.this)
        .setMenu(R.menu.choose_photo_bottom_sheet_menu)
        .setAutoCancel(false)
        .setClick(item -> {
          Logg.i("###", "|" + item.getTitle() + "|" + item.getItemId());
          return false;
        }).show();

Not all items are displayed at once

Problem: Not all items are displayed at once, but if you swipe up-everything is visible.

Code:

SheetMenu().apply {
    menu = R.menu.delete_device_menu
    click = MenuItem.OnMenuItemClickListener {
        when (it.itemId) {
            ...
        }
        true
    }
}.show(mContext)

Menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:title="@string/sync_device"
        android:id="@+id/sync_device" />
    <item
        android:title="@string/delete"
        android:id="@+id/delete_device" />
</menu>

How can I display the grid menu with the description size below the icon?

Firstly, thank you for support a good program library.
I made a Grid style 4 * 2 menu with icons and descriptions. However, since one menu size is the same as the icon size, the description can not be displayed on one line.
How can I display the grid menu with the description size below the icon?

Thank you for advance.

screenshot_20170920-130556

Create Grid Style

Hi. Your library is too nice.
Can you please tell me how I can create Grid layout menu item?

Thanks

its resource menu only

you cant even create dynamic menu, as it only takes resource ID of a menu, pretty useless without dynamic items

Option to show bottomsheet fully

For showing short lists such as menus with 4-6 items, the BottomSheetBehavior.STATE_HALF_EXPANDED that the menu starts with is annoying for the user and they can't tell if there are more items in most cases. There needs to be a display option that allows other values.

Предложения по улучшению

"menu" переименовал бы на "menuId"
"click" на "clickListener"
fun processTitle(textTitle: TextView) на fun TextView.changeTitile()

var itemLayoutId = R.layout.item_linear`
if (layoutManager is GridLayoutManager) {
    itemLayoutId = R.layout.item_grid
}

Я бы поменял на

val itemLayoutId = when (layoutManager) {
    is GridLayoutManager -> R.layout.item_grid
    else -> R.layout.item_linear
}

Ещё бы из функции fun processRecycler(recycler: RecyclerView, dialog: BottomSheetDialog) вынес
if (menu > 0){}, и саму функцию вообще убрал бы. Например, вот так:

fun show(context: Context) {
    ...
    val recycler = root.findViewById(R.id.recycler_view) as RecyclerView
    if (menuId > 0) {
        if (layoutManager == null) {
            layoutManager = createVerticalLinearLayoutManager()
        }
        val itemLayoutId = when (layoutManager) {
            is GridLayoutManager -> R.layout.item_grid
            else -> R.layout.item_linear
        }
        if (adapter == null) {
            adapter = createAdapter(dialog, itemLayoutId)
        }
        recyclerView.adapter = adapter
        recyclerView.layoutManager = layoutManager
    }
    ...
}
MenuItem.OnMenuItemClickListener({
    click.onMenuItemClick(it)
    dialog.cancel()
    true
})

поменял бы на

MenuItem.OnMenuItemClickListener {
    click.onMenuItemClick(it)
    dialog.cancel()
    true
}
protected open fun processGrid(root: View) {
    if (root.findViewById<View>(R.id.text_title).visibility != View.VISIBLE) {
        if (layoutManager is GridLayoutManager) {
            root.marginTop(24)
        }
    }
}

изменил на

protected open fun GridLayoutManager.setTopMarginIfTitleIsVisible(root: View) {
    if (root.findViewById<View>(R.id.text_title).visibility != View.VISIBLE) {
        root.marginTop(24)
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.