-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow customizing default popup style via theme attribute #53
Conversation
For example the users could set `<item name="materialPopupMenuStyle">@style/Widget.MPM.Menu.Dark</item>` in their theme which would make all popups default to that style instead of `Widget.MPM.Menu`.
*/ | ||
var style: Int = R.style.Widget_MPM_Menu | ||
var style: Int? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if it wouldn't be better to use var style: Int = 0
and check against 0 instead. I always find a bit icky to use Int?
or a nullable Integer
in Java. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. I'll change that later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I'll review the rest of PR today/tomorrow. I would like to test this a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked the rest and it looks good to me! Thanks for cleaning up ContextThemeWrapper
stuff as well - looks better now.
So the only change I would ask is that Int? = null
-> Int = 0
(plus relevant KDoc/test updated according to that change)
This pull request adds
materialPopupStyle
attribute which allows customizing the default style that will be used by all of the popups created by this library (unless overridden in the builder viastyle
property)Example
Here I've applied the below change. Notice how all of the popups except for these that define custom style have changed to that dark style with dimmed background.
Additional change
I've also cleaned a bit usage of
ContextThemeWrapper
. Now it's created only once and passed toMaterialRecyclerViewPopupWindow
directly as aContext
. Also I've removed the context fromPopupMenuAdapter
and instead made all views inherit from their parent view context which in turn makes them use the context fromMaterialRecyclerViewPopupWindow
. (Unless I'm somehow mistaken 😏). You can ignore that second commit if you don't want that change. It shouldn't affect the topic of this pull request but I found it related enough to keep here.