Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect when page in MultiDateTimetable completes #110

Closed
ghost opened this issue Aug 30, 2021 · 1 comment
Closed

Detect when page in MultiDateTimetable completes #110

ghost opened this issue Aug 30, 2021 · 1 comment
Assignees
Labels
T: Feat Type: :tada: New Features

Comments

@ghost
Copy link

ghost commented Aug 30, 2021

How to detect when page completely changes? For example to get a callback not after you just begin with swiping, nor when you release a press while swiping, but when animation of page swipe ends? If you were to start swiping form one page to another and while on the middle between two pages you release a press, page will continue with animation to second page, and when it finishes animation i would like to get a callback.

Reason why I'm asking is because I would like to fetch events from server whenever user swipes to new page, and issue with _dateController.addListener() is because it triggers a callback somewhat good when you swipe to next page, but when you try to swipe to previous page listener is triggered almost instantly as you being to swipe to previous page.

I though to use NotificationListener, and it does work properly for horizontal swiping but issues with this approach is that it also detects when scrolling is active vertically, what i need is only to listen when horizontal page swiping ends

void handleScrollListener(ScrollNotification scrollNotification) {
  if (scrollNotification is ScrollStartNotification) {
    print("SCROLLING");
  } else if (scrollNotification is ScrollEndNotification) {
    print("STOPPED SCROLLING!");
  }
}

@override
Widget build(BuildContext context) {
  return NotificationListener<ScrollNotification>(
    onNotification: (scrollNotification) {
      SchedulerBinding.instance!.addPostFrameCallback(
          (_) => handleScrollListener(scrollNotification));
      return true;
    },
    child: Stack(
      children: [
        TimetableConfig<EventModel>(
@JonasWanke JonasWanke self-assigned this Jan 24, 2023
@JonasWanke JonasWanke added the T: Feat Type: :tada: New Features label Jan 24, 2023
@JonasWanke
Copy link
Owner

As part of v1.0.0-alpha.11, I've added dateController.value.activity, which is an instance of DateScrollActivity. The value can be from one of three subclasses: DragDateScrollActivity, DrivenDateScrollActivity, or IdleDateScrollActivity. Hence, you now have the option to, e.g., ignore updates that stem from an animation. But you can do even better: drivenDateScrollActivity exposes a field target, so you can prefetch events for the target range of an animation while it's still ongoing.

TruFelix added a commit to BettaSystems/timetable that referenced this issue Jan 24, 2023
commit 4815598
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 18:24:08 2023 +0100

    Release v1.0.0-alpha.11

commit e7bae6d
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 18:18:38 2023 +0100

    Add more linter rules

commit 40f1b67
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 18:16:46 2023 +0100

    Update black_hole_flutter to ^1.0.0

commit ed2d0a0
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 18:14:42 2023 +0100

    Upgrade Dart to v2.18.0, Flutter to v3.3.0

commit 59b0eb4
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 15:40:14 2023 +0100

    Add DateScrollActivity

    Closes: JonasWanke#110

commit 8855d85
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 15:39:34 2023 +0100

    Implement Diagnosticable for VisibleDateRange

commit 469a0de
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 15:38:46 2023 +0100

    Add DateDiagnosticsProperty

commit b35b240
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 15:38:31 2023 +0100

    Fix allDayEventBorder.toString()

commit 174387e
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 15:38:09 2023 +0100

    Fix formatting

commit 8e0315c
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 12:36:34 2023 +0100

    Honor maxWidth in WeekIndicator

    Closes: JonasWanke#131

commit b2f06cf
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 12:03:19 2023 +0100

    Remove superfluous num type arguments

commit 763661e
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 11:51:44 2023 +0100

    Fix MonthPageView's shrinkWrapped height when jumping to far-away date

commit c0167c2
Author: Jonas Wanke <contact@jonas-wanke.com>
Date:   Tue Jan 24 11:51:04 2023 +0100

    Cancel animation when jumping in Date-/TimeController

    Closes JonasWanke#135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Feat Type: :tada: New Features
Projects
None yet
Development

No branches or pull requests

1 participant