alex-melnyk / flutter_advanced_drawer

https://pub.dev/packages/flutter_advanced_drawer
https://pub.dev/packages/flutter_advanced_drawer
BSD 3-Clause "New" or "Revised" License
71 stars 23 forks source link

add an optional opacity animation over the child. #36

Closed ekimia closed 1 year ago

ekimia commented 1 year ago

Adds an IgnorePointer widget to optionally animate the decoration as the drawer opens and closes, similar to the Twitter app on iOS:

https://user-images.githubusercontent.com/357513/210119394-63b64eda-53ea-4454-811d-dd6ba01fc850.MP4

alex-melnyk commented 1 year ago

This can be done by passing fade transition into the child and animationController properties of the drawer, so no sense to add this into the plugin.


return AdvancedDrawer(
      animationController: animationController,
      child: FadeTransition(
        opacity: Tween<double>(
          begin: 1.0,
          end: 0.25,
        ).animate(animationController),
        child: Scaffold(
          appBar: AppBar(
            title: const Text('Advanced Drawer Example'),
            leading: IconButton(
              onPressed: _handleMenuButtonPressed,
              icon: ValueListenableBuilder<AdvancedDrawerValue>(
                valueListenable: _advancedDrawerController,
                builder: (_, value, __) {
                  return AnimatedSwitcher(
                    duration: Duration(milliseconds: 250),
                    child: Icon(
                      value.visible ? Icons.clear : Icons.menu,
                      key: ValueKey<bool>(value.visible),
                    ),
                  );
                },
              ),
            ),
          ),
          body: Container(),
        ),
      ),
      drawer: SafeArea(
        child: Container(
          child: ListTileTheme(
            textColor: Colors.white,
            iconColor: Colors.white,
            child: Column(
              mainAxisSize: MainAxisSize.max,
              children: [
                Container(
                  width: 128.0,
                  height: 128.0,
                  margin: const EdgeInsets.only(
                    top: 24.0,
                    bottom: 64.0,
                  ),
                  clipBehavior: Clip.antiAlias,
                  decoration: BoxDecoration(
                    color: Colors.black26,
                    shape: BoxShape.circle,
                  ),
                  child: Image.asset(
                    'assets/images/flutter_logo.png',
                  ),
                ),
                ListTile(
                  onTap: () {},
                  leading: Icon(Icons.home),
                  title: Text('Home'),
                ),
                ListTile(
                  onTap: () {},
                  leading: Icon(Icons.account_circle_rounded),
                  title: Text('Profile'),
                ),
                ListTile(
                  onTap: () {},
                  leading: Icon(Icons.favorite),
                  title: Text('Favourites'),
                ),
                ListTile(
                  onTap: () {},
                  leading: Icon(Icons.settings),
                  title: Text('Settings'),
                ),
                Spacer(),
                DefaultTextStyle(
                  style: TextStyle(
                    fontSize: 12,
                    color: Colors.white54,
                  ),
                  child: Container(
                    margin: const EdgeInsets.symmetric(
                      vertical: 16.0,
                    ),
                    child: Text('Terms of Service | Privacy Policy'),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );