Coder Social home page Coder Social logo

Comments (8)

jawwad-hassan89 avatar jawwad-hassan89 commented on September 26, 2024 1

hi @christianrowlands, thanks for the appreciation and your feedback.
I will look into this issue, and fix it.

from animated_tree_view.

jawwad-hassan89 avatar jawwad-hassan89 commented on September 26, 2024 1

@christianrowlands you can already use the TreeNode..expansionNotifier.value to set the initial expansion state, but right now it won't have any effect as the initial state is always collapsed for the TreeNode.
I will have to do some refactoring so that the initial expansion state is respected by the TreeNode.

onTreeReady callback will be easy to implement, this might take a little longer.

from animated_tree_view.

jawwad-hassan89 avatar jawwad-hassan89 commented on September 26, 2024 1

the fix for TreeViewController .expand and .expandAllChildren has been pushed to the fix/treeview-controller branch.
The onTreeReady callback has also been added.

You can use the updated code from this branch, it is working but not properly tested yet. The branch will be merged into main after testing and documentation changes.

from animated_tree_view.

berslen avatar berslen commented on September 26, 2024

hi @christianrowlands, thanks for the appreciation and your feedback. I will look into this issue, and fix it.

Same issue with expand as well, And please add example for best practice to get tree controller.

from animated_tree_view.

christianrowlands avatar christianrowlands commented on September 26, 2024

Yeah, that is another issue I am running into. I can get the controller, but it is not initialized until after the initState() and build() methods are called. As a result, I am not sure when to expand all the children. I am using your library to display comments on a post, and I want the comments to always be expanded. I have tried a variety of options but am unable to figure out how to expand all without adding some sort of delayed timer that is called so that the lazy initialized controller is ready.

from animated_tree_view.

jawwad-hassan89 avatar jawwad-hassan89 commented on September 26, 2024

@christianrowlands I didn't such a use case in mind when I designed the controller, and with the current implementation I don't see any way of getting to know when the controller will get initialized, so the a delayed seems like the best option.
Just an FYI, thee controller is initialized in the initState method of the TreeView, so it takes some time to initialize.

What I can do, is to add a onTreeReady callback to the TreeView which will provide the controller. This way the controller will also be more straight-forward to access rather than using the GlobalKey to get the controller.

Will this work for you @christianrowlands ?

from animated_tree_view.

jawwad-hassan89 avatar jawwad-hassan89 commented on September 26, 2024

@berslen I will look into the Expand method as well, will hopefully have a fix ready by tomorrow.

from animated_tree_view.

christianrowlands avatar christianrowlands commented on September 26, 2024

Yeah, an onTreeReady callback would be great.

Or maybe there is an even more straightforward approach for my specific use case. I am looking to mimic Reddit's behavior for comments on a post where all of the comments and child comments are expanded by default. Given the new expandAllChildren method that was added, I thought that was the best option. But if there were a way to set the default expansion state of a node, then I could override the TreeNode class and set the expansion state to true. Something like this?

/// Represents a Comment that is submitted to/received from the server backend.
class Comment extends TreeNode {
  final String commentId;
  final String? parentId; // Null indicates a top level comment
  final String postId;
  final String userId;
  final String comment;
  DateTime? createdAt;

  Comment({
    required this.commentId,
    this.parentId,
    required this.postId,
    required this.userId,
    required this.comment,
    this.createdAt,
  }) : super(key: commentId, initialExpansionState: true);
}

from animated_tree_view.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.