flutter_tree_view icon indicating copy to clipboard operation
flutter_tree_view copied to clipboard

Drag and Drop functionality

Open Talgat777 opened this issue 3 years ago • 4 comments

Is there a way to implement drag and drop functionality? Maybe just reordering?

Talgat777 avatar Dec 22 '21 13:12 Talgat777

Hey @Talgat777!

I'm currently working on this feature for version 1.0 but its beeing really tough to find the right API implementation for drag & drop of hierarchical data, dealing with levels and such...

I can't promise anything, neither give a release date.

baumths avatar Dec 22 '21 16:12 baumths

@mbaumgartenbr This package may help for drag-drop https://github.com/knopp/flutter_reorderable_list. It's also a list. But we need to deal with the levels.

devon avatar May 14 '22 14:05 devon

Hey @devon!

Thank you for the suggestion, I appreciate it!

I have already looked through all packages on pub to decide upon the APIs, none of them are quite easy to add nesting level handling.

However, I have already found an API that works fine. Although it's very opinionated and not as customizable as I would want it to be, but it works. I just haven't had time to work on the package lately.

You can track the progress of the new APIs on the wip-1.0 branch. I just didn't start writing the drag and drop logic there yet, although it is complete and ready in a private repo (missing docs and polishing, not very customizable atm.).

I'll resume working at v1.0 as soon as this other thing is done. (can't promise anything, but I'd expect to be done in about a week or so).

baumths avatar May 14 '22 16:05 baumths

@mbaumgartenbr That's great news. I will help to test the feature 😁.

devon avatar May 15 '22 01:05 devon

I'm currently working on this as well. I got the drag/drop to work. I have "lines" which are just nodes with no children between my nodes that only show when you've dragged a node over it to give the user an idea of where to drop, and where the node's new location will be in the tree. I came here looking for the best way to reorder the list after dropping. It looks like I can track the location outside the library, take the drop targets location as a point for where the new node should be, and recreate the entire tree's data/repaint. This should work, but I'm not sure about the performance. Ideas?

tes735 avatar Mar 28 '23 13:03 tes735

I'm currently working on this as well. I got the drag/drop to work. I have "lines" which are just nodes with no children between my nodes that only show when you've dragged a node over it to give the user an idea of where to drop, and where the node's new location will be in the tree. I came here looking for the best way to reorder the list after dropping. It looks like I can track the location outside the library, take the drop targets location as a point for where the new node should be, and recreate the entire tree's data/repaint. This should work, but I'm not sure about the performance. Ideas?

I have a semi finished Drag and Drop implementation based on Draggable + DragTarget that should've got released along with version 1.0 but I made some modifications to the tree API that changed how that DnD implementation works and I haven't had time to work on it since then, but it is my top priority and I'm planning to catch up on it in the following days/weeks (depending on how difficult it would be to adapt and how well I can manage my spare time).

baumths avatar Mar 28 '23 13:03 baumths

Gotcha. Yeah, it's a bear to get going. I hadn't even gotten to making it droppable on top of another item so that it could become a child of that "folder." There's a lot to it.

Appreciate the hard work on this. It's an excellent lib.

tes735 avatar Mar 28 '23 15:03 tes735

Just curious where this is at! Would love to have this functionality, but totally realize it's a lot....thanks for the great lib!

JerContact avatar Jul 18 '23 19:07 JerContact

@baumths version 1.x works great! Well done! Looking forward checking drag & drop! Any ETA?

Talgat777 avatar Jul 25 '23 16:07 Talgat777

Yeah, about that... 😅

My life is currently upside-down. The "almost no spare time" became "no spare time at all" quite quickly. I haven't touched my computer in a month or so.

Unfortunately there are no updates on this, the state is the same: I have a new working implementation that needs polishing and docs. I may find time to just push that branch to gh to let people use it with a git ref on pubspec in its current state, but I'm not sure about that. (It might be cool to get some feedback, though)

baumths avatar Jul 25 '23 16:07 baumths

Please do! Someone might finish it and create PR for you to review.

Hopefully, "no spare time at all" in a good way :) Good luck and thanks for the library!

Talgat777 avatar Jul 25 '23 18:07 Talgat777

Update:

I finally found the time to finish this feature, if anyone is interested in testing it (and maybe provide feedback) I would really appreciate it! The code can be found in #63.

You could also try out the feature in your own project using the following dependency on your pubspec.yaml:

dependencies:
  flutter_fancy_tree_view:
    git:
      url: https://github.com/baumths/flutter_tree_view.git
      ref: dev/drag-and-drop

There are also some basic usage instructions in the README that should get you going.

Thanks a lot and sorry for the wait.

baumths avatar Aug 16 '23 14:08 baumths

I'm getting this when putting that in the dependencies:

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
exit code: 128
exit code 69

JerContact avatar Aug 17 '23 02:08 JerContact

I'm getting this when putting that in the dependencies:

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
exit code: 128
exit code 69

Sorry, my bad. You probably have to use the http url instead of the ssh one:

https://github.com/baumths/flutter_tree_view.git

I have updated the above comment with the hopefully correct url.

baumths avatar Aug 17 '23 02:08 baumths

that worked!

JerContact avatar Aug 17 '23 02:08 JerContact