Skip to content
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

Item design like Gmail #2616

Closed
goodibunakov opened this issue Jun 9, 2020 · 13 comments
Closed

Item design like Gmail #2616

goodibunakov opened this issue Jun 9, 2020 · 13 comments

Comments

@goodibunakov
Copy link

изображение
Hi Mike! How i can do something like this?

@mikepenz
Copy link
Owner

the default items look like the items according to the material design guidelines. but with some theming work like adjusting the corner radius and stuff you should be able to achieve the above :)

@mikepenz
Copy link
Owner

It would actually be a great thing for our sample if you'd love to contribute to the project :)

@goodibunakov
Copy link
Author

Oh, if i find how to do this... )))

@mikepenz
Copy link
Owner

All magic basically happens here. As you can see we make use of the new MaterialShapeDrawable which allows for shape theming :)

fun themeDrawerItem(ctx: Context, view: View, selected_color: Int, animate: Boolean, shapeAppearanceModel: ShapeAppearanceModel) {

and we support passing in a custom shapeAppearanceModel which get's constructed here:

protected fun getShapeAppearanceModel(ctx: Context): ShapeAppearanceModel {
val cornerRadius = ctx.resources.getDimensionPixelSize(R.dimen.material_drawer_item_corner_radius)
return ShapeAppearanceModel().withCornerSize(cornerRadius.toFloat())
}

So theoretically if you overwrite the PrimaryDrawerItem and modify that method (e.g. have a different shape appearance model defined. that should be it and magically work :D

@mikepenz
Copy link
Owner

Ok additionally the insets via material_drawer_item_background_padding_start_end have to be adjusted too it looks

@mikepenz
Copy link
Owner

photo_2020-06-11 19 49 04
photo_2020-06-11 19 50 59

So right now the best approach is to overwrite the PrimaryDrawerItem and then define your own getShapeAppearanceModel function. and possibly also define your own way of theming the item. adjusting the dimensions, paddings and such a bit :)

See the above sample how it's possibly looking like (with dark theme and light theme)

@mikepenz
Copy link
Owner

for the style I used a shape appearance model like this:

return ShapeAppearanceModel.builder()
                .setTopRightCorner(CornerFamily.ROUNDED, cornerRadius.toFloat())
                .setBottomRightCorner(CornerFamily.ROUNDED, cornerRadius.toFloat())
                .build()

@mikepenz
Copy link
Owner

so the next version will make theming this a bit easier :) also I will have a sample for you to see how it's done

@goodibunakov
Copy link
Author

Well, we are waiting for v8.1.2? ;)

@mikepenz
Copy link
Owner

Released v8.1.2 for you :) hope it helps

@goodibunakov
Copy link
Author

Unbelievable! Thanks a lot! )))

@goodibunakov
Copy link
Author

It works! Great!
I saw example app and i have to use GmailDrawerItem class (its ok) and ids.xml file inside my project?

@mikepenz
Copy link
Owner

Yes :)

You can use the sample GmailDrawerItem class in your project and the one id which is needed :)

And having this in your class allows you to finetune it to your exact needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants