material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

Add new `List` component guidance

Open sfdexter opened this issue 8 years ago • 21 comments

https://material.io/go/design-lists

sfdexter avatar May 01 '18 18:05 sfdexter

How's the progress on this going?

Nemant avatar Jan 06 '19 05:01 Nemant

we're waiting!

wiesenklee avatar Jan 09 '19 21:01 wiesenklee

The Material Android team is starting to plan for this component for work to being in Q1. As lists are a fairly broad components we'd love for people to share (in this issue) specific use cases (design mocks are great) of how you hope to use the component. The use cases will also help us prioritize pieces of the spec.

ldjcmu avatar Jan 17 '19 18:01 ldjcmu

For our project, we would leverage gestures, subheaders, and list controls.

patrickpilch avatar Feb 21 '19 16:02 patrickpilch

you can dooo ittttt!!!!

osherifo avatar Mar 07 '19 15:03 osherifo

@ethanhsuhsu thanks for stopping by ADS and offering to contribute towards this feature request. Do I have permission to post the feedback you submitted here so we can start a discussion on this issue?

wcshi avatar Nov 18 '19 21:11 wcshi

@wcshi You do indeed have my permission, and I am glad to hear that you got my feedback. I was under pressure during that situation and after more time, have collected my thoughts better.

The current issue with lists is the sheer amount of boilerplate you need in order to make yourself a simple list:

  • A card item xml layout that takes up 100 lines (using ConstraintLayout at least) describing what each list item looks like
  • A RecyclerView adapter where you rewrite all of the ViewHolder recycling logic (also 100 line file)
  • And the list goes on and on for data changes, swipe animations, and item dragging

The material spec should be easily implementable and for those who do not prioritize UI, adding a list should not be hard. You could hear an applause when Jetpack Compose team announced easier list declarations without adapters (oof.)

Here is what our list component could look like (only an example for thought) :

Here is a method that initializes a RecyclerView and returns a View with the RecyclerView in it (Kotlin).

val list: View = MaterialList(context, MaterialList.single_line_fourth) 
{ cardholder, position -> cardholder.apply {
picture = mydata[position].picture
title = mydata[position].name
image = checkimage
}
}

Params: the activity/fragment context, an enum specifying which card layout to use (xml layouts from the spec will implemented in component library code) and a lambda that binds data to each list item

Notice: Potentially we can reduce a 200 line boilerplate implementation (and a good hour 🕐) to a few lines of code! (and a few seconds) 💥

I would be interested in hearing other ideas and I think with the combined power of type, shape and color theming we can make Material Lists way easier. Thanks for listening to my request and I would be excited to help out as much as possible.

@wcshi can you respond with the next steps or an update about how we can move further?

etlhsu avatar Nov 20 '19 00:11 etlhsu

I'm not sure that we need to totally abstract RecyclerView away, maybe we could do that eventually if it ends up reducing a lot of boiler plate, but I do see how not having to write ViewHolders and Adapters could be nice. What if we create those for use in a RecyclerView to start?

We have some view holders internally for a few of the list items which I think we could publish. We could also make Adapters that make it easy to set a specific list item type on a RecyclerView.

@ethanhsuhsu After I publish the view holders we have, would you be interested in working on more / creating Adapters that allow you to pass a method to bind the data?

cketcham avatar Nov 20 '19 15:11 cketcham

@cketcham I could help around that too if @ethanhsuhsu needs some help!

pavlospt avatar Nov 20 '19 15:11 pavlospt

@cketcham I am interested ✨ in creating more ViewHolders and adapters for Material lists. Thanks for the idea of doing ViewHolders first, since that will provide easy migration process and customizability for existing RecyclerView users.

I apologize if my initial thoughts were overwhelming, I was thinking about the end goal being a UI widget (or View) just like the other components. A simple start is preferable.

@cketcham After publishing the ViewHolders, I will look at the architecture and reply to you about how to proceed. Hopefully we (or the Material team) can work on a small design doc 📝 for better communication, since comments are time-consuming and ineffective 🕥.

etlhsu avatar Nov 21 '19 04:11 etlhsu

Trying to follow best practices of Material Design (which I'm a big fan of), I recently found an unspecified part of the list specification.

I had to implement an inline list with a border around it, that had to play nice with several Material TextInputLayouts (the inline list should resemble the TextInputLayout regarding border and shape). This turned out to become quite the challenge, where the rounded corners of the border were overlapped by the selected view-items (when the border was set using the android:background xml tag, using a ShapeDrawable) - see this SO question. A picture might show more exactly what I'm talking about (this is the final solution I ended up with):

Skærmbillede_2019-11-21_kl__12_38_03

So if the Material Design team is going to take a closer look at the list specification regarding this work, could they please take this usecase (borders around list components) into consideration as well. Would be nice if the implementation could offer some assistance to avoid such issues. Another pain point of lists is selection. This should definitely address this.

Will definitely hold an eye out for this and try and help as much as possible.

bohsen avatar Nov 21 '19 12:11 bohsen

@bohsen Currently, I believe that we are going to design & optimize for the simplest use case: displaying data in a list card template. After we finish that, we can add other features based on the Material spec and the community.

etlhsu avatar Nov 21 '19 14:11 etlhsu

@cketcham Can post the existing ViewHolders you have so I can take a look at them?

etlhsu avatar Nov 24 '19 01:11 etlhsu

It should be synced out soon. Probably Monday. I'll ping you when it is.

cketcham avatar Nov 24 '19 01:11 cketcham

@ethanhsuhsu Actually it was synced friday! Sorry! https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/lists

cketcham avatar Nov 25 '19 13:11 cketcham

@cketcham I am going to add adapters for the three ViewHolders provided. How will my contribution workflow go?

Should I write a comment here every time I want to do a PR? Can you provide me a list of tasks to do (in order to work with engineers working on Material Lists internally) or should I write-out tasks I want to do? The "guessing" on what to do is not effective for you and me and I am excited work on this project.

etlhsu avatar Nov 25 '19 20:11 etlhsu

@ethanhsuhsu How do you want to start? I think continuing to create ViewHolders for more cases, and creating Adapters for all of them seems useful. Which do you think would be most useful to make to start?

cketcham avatar Nov 25 '19 22:11 cketcham

@cketcham I submitted a pull request (#798) that adds adapters (as promised). I would like you (or the team) to review my contribution when convenient, so that I can address comments in a timely manner. This project is soo exciting.

Once merged... next steps?

  • [x] Add adapters for existing ViewHolders
  • [ ] Update the list item xml layouts to be more consistent with Material standards
  • [ ] Scale up to add ViewHolders/Adapters for all cases in the Material list spec

etlhsu avatar Nov 28 '19 06:11 etlhsu

@ethanhsuhsu You could also add selection support (as in SelectionTracker from the AndroidX RecyclerView Selection library) while you're at it.

EdricChan03 avatar Dec 01 '19 12:12 EdricChan03

Check out PR #1296 for the latest work on Material Lists! 🗒️

etlhsu avatar May 13 '20 04:05 etlhsu