woltapp / wolt_modal_sheet

This package provides a responsive modal with multiple pages, motion animation for page transitions, and scrollable content within each page.
MIT License
483 stars 65 forks source link

Basic Go_Router example #158

Closed kamami closed 4 months ago

kamami commented 7 months ago

I think it would be nice to have a basic example how to implement this package with go_router. I know there is a playground example with navigator 2.0, but it is very confusing and hard to follow.

Best Regards

schuberty commented 6 months ago

I also believe it would be good, I still have this issue #90 regarding the Navigator 2.0 and couldn't find time unfortunately to fix it.

hectorAguero commented 6 months ago

Just copy this file of the docs as a wrapper of your Page [SheetPage], change the cubit calls to a context.pop()(https://github.com/woltapp/wolt_modal_sheet/blob/main/playground_navigator2/lib/router/router_pages/sheet_page.dart)

And inside your go_router routes you can put like this

 GoRoute(
    path: 'my_nice_sheet_path',
    pageBuilder: (context, state) {
      return SheetPage(
        pageIndexNotifier: ValueNotifier(0),
        pageListBuilderNotifier: ValueNotifier(
          (context) => [
            WoltModalSheetPage(child: const MyNiceSheet()),
          ],
        ),
      );
    },
  );
dinko7 commented 5 months ago

If anyone still has a problem with this, I use the following solution:

I launch the sheet imperatively, but with 2 key points:

  1. Always pass the sheetContext to children
  2. If you need to pop, use context.pop() from GoRouter

This also works if you need to use the root navigator to display the bottom sheet over a ShellRoute (which was my main issue).

WoltModalSheet.show(
    pageIndexNotifier: controller.sheetIndex,
    context: context,
    useRootNavigator: true,
    pageListBuilder: (sheetContext) => [

    ],
    onModalDismissedWithBarrierTap: () {
      context.pop();
    },
    onModalDismissedWithDrag: () {
      context.pop();
    },
  );
ulusoyca commented 4 months ago

Hi @kamami ! We have a new example with Navigator 2.0.

I would appreciate if you can provide feedback about its complexity: https://github.com/woltapp/wolt_modal_sheet/tree/main/coffee_maker_navigator_2

Here is the video that explains it: https://drive.google.com/file/d/1vQOdEMUUNCj_XlEUaCil_kckctMz7JMu/view?usp=sharing

Fintasys commented 1 month ago

I'm not sure why this issue was closed. The author mentioned that example for Navigator 2.0 exists but not for GoRouter. I would also appreciate a working example with GoRouter, recently running into issues that Swipe-Back and Back-Button wouldn't pop the Modals.