Skip to content

Be able to configure the initial scroll position of WeekView #38

Description

@hnvn

I need to launch WeekView and immediately jump to a selected event. Something may be initialDate and we can calculate scroll position out from it instead of only scrolling to current time.

@override
  void scrollToCurrentTime() {
    super.scrollToCurrentTime();

    int index = 0;
    if (widget.dateCount != null) {
      for (; index < widget.dateCount; index++) {
        if (Utils.sameDay(widget.dateCreator(index))) {
          break;
        }
      }
    }

    double topOffset = calculateTopOffset(HourMinute.now());
    double leftOffset = dayViewWidth * index;

    widget.controller.verticalScrollController.jumpTo(math.min<double>(topOffset, widget.controller.verticalScrollController.position.maxScrollExtent));
    widget.controller.horizontalScrollController.jumpTo(math.min<double>(leftOffset, widget.controller.horizontalScrollController.position.maxScrollExtent));
  }

Activity

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions