whalemare / sheetmenu Goto Github PK
View Code? Open in Web Editor NEWLibrary for speedy implementation menu with BottomSheet
Library for speedy implementation menu with BottomSheet
Add the ability to delete a some items from the menu programmatically
Does it support grid layout for menu items
Hello, I think you shouldn't use androidx.constraintlayout:constraintlayout:2.0.0-beta for this library , because it's not stable for now.
Hi. Your library is too nice.
Can you please tell me how I can create Grid layout menu item?
Thanks
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)
}
}
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.
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>
you cant even create dynamic menu, as it only takes resource ID of a menu, pretty useless without dynamic items
It is bug on jitpack.io
Be careful, issue is opened on their tracked
jitpack/jitpack.io#1197
Maybe and option like
setDismissWhenItemClicked(boolean isDismissAllowed)
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();
sheet and menu titles are not showing
How do I hide a menu item programmatically? For example, the menu item for purchasing "No Ads"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.