Displaying list of visits—ListView or Table? - mobile

I'm working on my first app in Flutter and running into a dilemma. I'd like to display a list of visits.
I would display the name of the client that's been visited on the left, and some statistics (hours worked for example) on the right.
With my knowledge of HTML/CSS I'd say put it in a table. But there seem to be some limitations for Table widgets in Flutter..
Not clickable
They don't scroll by default (as far as I know)
No support for headers
Frankly I'm confused. The Table widget seems to lack some functionality and I might be better off using the ListView widget. However, then I'd have to set fixed column-widths myself to align the cells properly..
What do you recommend I use for this now?

The way you're describing it makes it sound a lot more complicated than it is to implement in Flutter.
All you need is a list view with your items in a row. The container and the list will fill the screen. You don't have to set any fixed column widths.
If you use the following code you'll see a list of 10 children with text next to each other.
ListView.builder(
itemCount: 10,
itemBuilder: (buildContext, int) => Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('Sites visited'),
Text('Hours worked')
],),
height: 60.0,
margin: EdgeInsets.only(top: 10.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5.0))))
If you want touch functionality on any of the items wrap it in a GesureDetector and then listen to which ever gesture you want, tap, double tap, or any of the other options.

Related

Show icon across two rows in a mui table

I have a react mui table where sometimes two adjacent rows are related. I want to show a chain icon (or similar) between the two related rows. Crude mockup below:
Is there a straightforward way to achieve this?
I'm having trouble finding the correct terms to describe what I need, hence google search is failing me. "Overlay" seems to be within a row or cell, and most "Overflow" search hits are about preventing overflow rather than intentionally causing it. Here's a codesandbox starting point if it helps: https://codesandbox.io/s/basictable-material-demo-forked-jzb96?file=/demo.js
There are two possible ways to achieve this effect. One is to use an absolutely positioned chain icon element and then offset its coordinates so that it "floats" between the two table row elements. It may take some playing around with the attributes but it would look something like
.chain-icon {
position: absolute;
left: 100px;
top: 10px;
z-index: 100;
}
The other option that might work is to place the chain icon inside the row and offset it with negative margins margin-top: -50px; and make sure overflow attribute is set correctly. Since it's a table, for either approach I would suggest adding a new column next to dessert and adding the icon to that row cell.
I used plain old css transform - Unsure if this is a good idea.

React Beautiful DnD- set the drag handle to be ONLY the list item MARKER

I am using React Beautiful DnD to create a nested list. I know this is not supported by the library, but I've seen plenty of workarounds and my use-case is relatively simple (no dragging sub-list elements between parent lists; sub-list elements can only be dragged within their respective sub-list).
The issue is as follows: trying to drag elements from the nested list sometimes drags the parent list elements instead. (I just made a long post documenting my problem here.)
I haven't gotten any responses yet, so I stared thinking about other ways to potentially solve the problem. I realized one solution could be choosing only a specific area of each list element that can be clicked to drag, and making sure this area does not overlap between the parent/nested lists.
Seeing that this is possible here, I simply need to add {...provided.dragHandleProps} to the element that I want to serve as the drag handle.
However, my nested list is built using two instantiations of a reusable DnDList component that I wrote, so it gets a little more complicated. Rather than trying to figure out how to specify a drag handle as props, I'd like to just set the drag handle to be list item marker for each list item (the '1', '2', '3', etc next to each list item).
How can I add {...provided.dragHandleProps} to the li::marker elements of my list?
Here's how I figured it out:
I ultimately used CSS to turn off the list item marker (listStyle: "none"), then wrapped each DnDList item in a flex container with a clickable drag icon that I manually placed on the left of the list item (first sibling in the flex container).
I also overlayed an invisible div over the drag icon, and placed the {...provided.dragHandleProps} here. It looked like this:
<div className={classes.listItemWrapper}>
<div
className={invisibleDiv}
{...provided.dragHandleProps} // MUST CLICK THIS TO DRAG
>
<DragIndicatorIcon className={classes.dragIcon} />
</div>
{child}
</div>
Here is what the styling looked like (using material UI):
listItemWrapper: {
display: "flex",
position: "relative",
},
invisibleDiv: {
position: "absolute",
left: "-4%",
top: "36%",
width: "40px",
height: "40px",
textAlign: "center",
},
Hope this is useful for somone!
I could not see your DnD component. But the possible solution is to remove the DragDropContext component from the inner DnD component which must solve the problem. Meaning you must have only one DragDropContext for your entire Draggable and droppables.

Kendo React Grid : Reordering columns and save the new order

i'm working on Kendo react grid and a set reorderable={true} to make the columns reordering.
Now i want to save the new order and i don't found a solution what event should i use to detect when the column move
<Grid
pageable={paginationConfig}
reorderable={true}
sortable
filterable
resizable
style={{ height: '600px', overflow: 'auto' }}
>......</Grid>
can somebody help me please.
See onColumnReorder in the Documentation. Where you store it is the next question... State, store, local storage etc...

Fixed width columns in Antd?

I have read Antd's layout design documents and the docs on Grid and Layout. What I don't understand is how to accomplish the following design in Antd:
I'd like my app to have a single centered column.
On a wide screen (landscape clients), the center column should be fairly narrow. In terms of grid, maybe 8 units.
On a narrow screen (portrait clients), the center column should use a relatively large
width. In terms of grid up to 24 units in case of very narrow/small screen sizes.
Basically this sounds like I'm looking for the good old container with a max width. I could obviously come up with some custom CSS to style a custom <div>, but this makes me wonder:
Am I missing something, or is there really no way to achieve that with Antd's layout system natively?
If so, am I doing something wrong in terms of modern UI design philosophy?
We have done this. Not exactly via Ant Design, but used a lot of Ant Design inside this.
I am not sure what other solutions are, but this is how we did it. The container you talked about was the parent container of our website, with everything else rendered inside this.
We created a routing inside the main container (as bottom tabs, so was convenient for us) and set its max-width to 420px. Since everything was contained in the bottom tabs, our app was centered when on landscape clients, and looked to fill the width on portrait mode.
Code for clarity. (its a react app)
App Container CSS:
.App {
text-align: center;
height: 100vh !important;
}
Parent Container CSS:
.parentcontainer {
height: calc(100vh - 50px);
max-width: '100%';
display: inline-block;
width: 100vw;
}
Tab CSS:
position: 'fixed',
padding-bottom: '10px',
bottom: '0',
width: '100%',
max-width: '420px',
This worked for us, and the behavior is what you desire.

Change Size And Behavior of Text Field

I am working to build a screen in my app with several text fields in it. I wish the user to be able to enter a large amount of text in each of them.
There are two problems:
The standard TextField widget is only one line high. I would like it to be many lines high so the user can see all that they have typed.
The standard TextField's behavior seems to act like a typwriter, where the text scrolls infinitely from right to left as the user types. I would like the text to wrap when it hits the edge of the screen.
In short, what I am looking for is your standarrd issue text entry box just like you would be typing into if you were asking a question here.
How do I go about implementing one in Flutter?
TextField Widget has maxLines property.
You can use it like this.
new TextField(
maxLines: 5,
textAlign: TextAlign.left,
decoration: new InputDecoration(
hintText: "Enter Something",
),
)

Resources