mt-akar / bottom_nav_layout

A quick and powerful Flutter layout with a bottom navbar.
https://pub.dev/packages/bottom_nav_layout
MIT License
34 stars 11 forks source link

Is it possible to have an overlay widget appear with bottom navigation button press? #14

Closed mark8044 closed 2 years ago

mark8044 commented 2 years ago

Is it possible to have an overlay widget appear with bottom navigation button press?

With my current implementation when I press a bottom navigation button, it will always present a new blank screen and place widgets on top of that, here is what Ive tried doing:

    return BottomNavLayout(
      // The app's destinations
      pages: [
                  (...)
                   (navKey5) => BottomNavigationMoreButton()
                 ]
class BottomNavigationMoreButton extends StatefulWidget {
  const BottomNavigationMoreButton({Key? key}) : super(key: key);

  @override
  _BottomNavigationMoreButtonState createState() => _BottomNavigationMoreButtonState();
}

class _BottomNavigationMoreButtonState extends State<BottomNavigationMoreButton> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: SizedBox.expand(
        child: DraggableScrollableSheet(
          key: UniqueKey(),
          minChildSize: 0.0,
          builder: (BuildContext context, ScrollController scrollController) {
            return Container(
              color: Colors.blue[100],
              child: ListView.builder(
                controller: scrollController,
                itemCount: 25,
                itemBuilder: (BuildContext context, int index) {
                  return ListTile(title: Text('Item $index'));
                },
              ),
            );
          },
        ),
      ),
    );
  }
}

The idea here being that a DraggableScrollableScreen would appear over whatever content you are already looking at when you press one of the bottom navigation icons.

Possible?

mt-akar commented 2 years ago

I don't see why it wouldn't be possible. Have you tried modifying the onTap method?

mark8044 commented 2 years ago

Im stupid, I never knew about onTap. Im such a n00b :). Thanks, I got it working now