From 6454df87a945e166eeec092e62cb3b6576ed1399 Mon Sep 17 00:00:00 2001 From: BataraSurya Date: Thu, 28 Sep 2023 23:26:22 +0800 Subject: [PATCH 1/4] experimental update --- lib/src/sidebar.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/sidebar.dart b/lib/src/sidebar.dart index c58553b..bfbc131 100644 --- a/lib/src/sidebar.dart +++ b/lib/src/sidebar.dart @@ -303,7 +303,7 @@ class _AnimatedSidebarState extends State return Container( padding: EdgeInsets.symmetric(horizontal: _calculateHeaderItemOffset()), height: 64, - child: Row( + child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ From cec651538cb9f2485a16110bfc070c8574e3891b Mon Sep 17 00:00:00 2001 From: BataraSurya Date: Fri, 29 Sep 2023 00:02:05 +0800 Subject: [PATCH 2/4] changed headerIcon to widget for customizability. added callBack to add functionality to header --- lib/src/sidebar.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/src/sidebar.dart b/lib/src/sidebar.dart index bfbc131..17e1c97 100644 --- a/lib/src/sidebar.dart +++ b/lib/src/sidebar.dart @@ -109,7 +109,7 @@ class AnimatedSidebar extends StatefulWidget { /// The [headerIcon] is displayed on the top of the sidebar. /// /// if null, only the [headerText] will be displayed. - final IconData? headerIcon; + final Widget? headerIcon; /// the size of the [headerIcon]. final double? headerIconSize; @@ -125,6 +125,10 @@ class AnimatedSidebar extends StatefulWidget { /// The [headerText] is displayed on the top of the sidebar. final String? headerText; + /// The [textCallback] is a callback function that can be passed + /// to the sidebar to be called when [headerText] is pressed + final VoidCallback? textCallback; + const AnimatedSidebar({ Key? key, required this.items, @@ -169,6 +173,7 @@ class AnimatedSidebar extends StatefulWidget { this.headerTextStyle = const TextStyle( fontSize: 22, fontWeight: FontWeight.w500, color: Colors.white), this.headerText, + this.textCallback, }) : assert((headerIcon != null && headerText != null) ^ (header != null)), super(key: key); @@ -307,13 +312,15 @@ class _AnimatedSidebarState extends State mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Icon( - widget.headerIcon, - color: widget.headerIconColor, - size: widget.headerIconSize, + SizedBox( + height: widget.headerIconSize, + width: widget.headerIconSize, + child: widget.headerIcon, ), _expanded || _inAnimation ? Flexible( + child: TextButton( + onPressed: widget.textCallback, child: Text( widget.headerText ?? 'missing', overflow: TextOverflow.fade, @@ -321,7 +328,7 @@ class _AnimatedSidebarState extends State softWrap: false, style: widget.headerTextStyle, ), - ) + )) : const SizedBox.shrink(), ], ), From 52016dee332cc12345acc2b3c32a3049e4bb743e Mon Sep 17 00:00:00 2001 From: BataraSurya Date: Fri, 29 Sep 2023 00:03:46 +0800 Subject: [PATCH 3/4] changed headerIcon to widget for customizability. added callBack to add functionality to header --- example/lib/main.dart | 4 +++- test/animated_sidebar_test.dart | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 28572e0..be4534e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -123,7 +123,9 @@ class _MyHomePageState extends State { ), itemMargin: 16, itemSpaceBetween: 10, - headerIcon: Icons.ac_unit_sharp, + headerIcon: const CircleAvatar( + child: Icon(Icons.hive_sharp), + ), headerIconSize: 30, headerIconColor: Colors.amberAccent, headerTextStyle: const TextStyle( diff --git a/test/animated_sidebar_test.dart b/test/animated_sidebar_test.dart index 30108a8..3a3b419 100644 --- a/test/animated_sidebar_test.dart +++ b/test/animated_sidebar_test.dart @@ -54,7 +54,7 @@ void main() { ), itemMargin: 16, itemSpaceBetween: 10, - headerIcon: Icons.menu, + headerIcon: const CircleAvatar(child: Icon(Icons.adb_sharp)), headerIconSize: 30, headerIconColor: Colors.deepPurple, headerTextStyle: const TextStyle( From d0344fbf4292a5dda0fe4b0385cb83cf4d7e23ff Mon Sep 17 00:00:00 2001 From: BataraSurya Date: Fri, 29 Sep 2023 00:18:43 +0800 Subject: [PATCH 4/4] removed _buildIconHeader container height --- lib/src/sidebar.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/sidebar.dart b/lib/src/sidebar.dart index 17e1c97..884ccce 100644 --- a/lib/src/sidebar.dart +++ b/lib/src/sidebar.dart @@ -307,7 +307,6 @@ class _AnimatedSidebarState extends State Widget _buildIconTextHeader() { return Container( padding: EdgeInsets.symmetric(horizontal: _calculateHeaderItemOffset()), - height: 64, child: Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min,