From c1fa85ab9494696d7d68407ba6c831ca6e175050 Mon Sep 17 00:00:00 2001 From: aroxu <30624945+aroxu@users.noreply.github.com> Date: Thu, 23 Nov 2023 17:03:01 +0900 Subject: [PATCH 1/3] Add onLongPress --- example/pubspec.lock | 28 ++++++++++++++-------------- lib/src/models/sidebarx_item.dart | 2 ++ lib/src/sidebarx_base.dart | 11 +++++++++++ lib/src/widgets/sidebarx_cell.dart | 3 +++ 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index fab1abe..177f0d7 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" fake_async: dependency: transitive description: @@ -95,10 +95,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -113,7 +113,7 @@ packages: path: ".." relative: true source: path - version: "0.16.1" + version: "0.16.2" sky_engine: dependency: transitive description: flutter @@ -131,18 +131,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -163,10 +163,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" vector_math: dependency: transitive description: @@ -179,10 +179,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=1.17.0" diff --git a/lib/src/models/sidebarx_item.dart b/lib/src/models/sidebarx_item.dart index f237a0f..7c82131 100644 --- a/lib/src/models/sidebarx_item.dart +++ b/lib/src/models/sidebarx_item.dart @@ -6,6 +6,7 @@ class SidebarXItem { this.icon, this.iconWidget, this.onTap, + this.onLongPress, }) : assert( (icon != null || iconWidget != null) && (icon == null || iconWidget == null), @@ -16,4 +17,5 @@ class SidebarXItem { final IconData? icon; final Widget? iconWidget; final Function()? onTap; + final Function()? onLongPress; } diff --git a/lib/src/sidebarx_base.dart b/lib/src/sidebarx_base.dart index a558f89..44ef59e 100644 --- a/lib/src/sidebarx_base.dart +++ b/lib/src/sidebarx_base.dart @@ -136,6 +136,7 @@ class _SidebarXState extends State extended: widget.controller.extended, selected: widget.controller.selectedIndex == index, onTap: () => _onItemSelected(item, index), + onLongPress: () => _onItemLongPressSelected(item, index), ); }, ), @@ -163,6 +164,8 @@ class _SidebarXState extends State index - 1, onTap: () => _onFooterItemSelected(item, index), + onLongPress: () => + _onFooterItemLongPressSelected(item, index), ); }, ), @@ -182,11 +185,19 @@ class _SidebarXState extends State widget.items.length + widget.footerItems.length - index - 1); } + void _onFooterItemLongPressSelected(SidebarXItem item, int index) { + item.onLongPress?.call(); + } + void _onItemSelected(SidebarXItem item, int index) { item.onTap?.call(); widget.controller.selectIndex(index); } + void _onItemLongPressSelected(SidebarXItem item, int index) { + item.onLongPress?.call(); + } + Widget _buildToggleButton( SidebarXTheme sidebarXTheme, IconData collapseIcon, diff --git a/lib/src/widgets/sidebarx_cell.dart b/lib/src/widgets/sidebarx_cell.dart index 13c1c20..690feaa 100644 --- a/lib/src/widgets/sidebarx_cell.dart +++ b/lib/src/widgets/sidebarx_cell.dart @@ -9,6 +9,7 @@ class SidebarXCell extends StatefulWidget { required this.selected, required this.theme, required this.onTap, + required this.onLongPress, required this.animationController, }) : super(key: key); @@ -17,6 +18,7 @@ class SidebarXCell extends StatefulWidget { final SidebarXItem item; final SidebarXTheme theme; final VoidCallback onTap; + final VoidCallback onLongPress; final AnimationController animationController; @override @@ -61,6 +63,7 @@ class _SidebarXCellState extends State { cursor: SystemMouseCursors.click, child: GestureDetector( onTap: widget.onTap, + onLongPress: widget.onLongPress, behavior: HitTestBehavior.opaque, child: Container( decoration: decoration?.copyWith( From 691b0ca1865cb9dc56310255d6f6881d35133fa9 Mon Sep 17 00:00:00 2001 From: aroxu <30624945+aroxu@users.noreply.github.com> Date: Thu, 23 Nov 2023 17:11:24 +0900 Subject: [PATCH 2/3] Add onSecondaryTap --- lib/src/models/sidebarx_item.dart | 2 ++ lib/src/sidebarx_base.dart | 12 ++++++++++++ lib/src/widgets/sidebarx_cell.dart | 3 +++ 3 files changed, 17 insertions(+) diff --git a/lib/src/models/sidebarx_item.dart b/lib/src/models/sidebarx_item.dart index 7c82131..c389f93 100644 --- a/lib/src/models/sidebarx_item.dart +++ b/lib/src/models/sidebarx_item.dart @@ -7,6 +7,7 @@ class SidebarXItem { this.iconWidget, this.onTap, this.onLongPress, + this.onSecondaryTap, }) : assert( (icon != null || iconWidget != null) && (icon == null || iconWidget == null), @@ -18,4 +19,5 @@ class SidebarXItem { final Widget? iconWidget; final Function()? onTap; final Function()? onLongPress; + final Function()? onSecondaryTap; } diff --git a/lib/src/sidebarx_base.dart b/lib/src/sidebarx_base.dart index 44ef59e..656a411 100644 --- a/lib/src/sidebarx_base.dart +++ b/lib/src/sidebarx_base.dart @@ -137,6 +137,8 @@ class _SidebarXState extends State selected: widget.controller.selectedIndex == index, onTap: () => _onItemSelected(item, index), onLongPress: () => _onItemLongPressSelected(item, index), + onSecondaryTap: () => + _onItemSecondaryTapSelected(item, index), ); }, ), @@ -166,6 +168,8 @@ class _SidebarXState extends State onTap: () => _onFooterItemSelected(item, index), onLongPress: () => _onFooterItemLongPressSelected(item, index), + onSecondaryTap: () => + _onFooterItemSecondaryTapSelected(item, index), ); }, ), @@ -189,6 +193,10 @@ class _SidebarXState extends State item.onLongPress?.call(); } + void _onFooterItemSecondaryTapSelected(SidebarXItem item, int index) { + item.onSecondaryTap?.call(); + } + void _onItemSelected(SidebarXItem item, int index) { item.onTap?.call(); widget.controller.selectIndex(index); @@ -198,6 +206,10 @@ class _SidebarXState extends State item.onLongPress?.call(); } + void _onItemSecondaryTapSelected(SidebarXItem item, int index) { + item.onSecondaryTap?.call(); + } + Widget _buildToggleButton( SidebarXTheme sidebarXTheme, IconData collapseIcon, diff --git a/lib/src/widgets/sidebarx_cell.dart b/lib/src/widgets/sidebarx_cell.dart index 690feaa..1db2825 100644 --- a/lib/src/widgets/sidebarx_cell.dart +++ b/lib/src/widgets/sidebarx_cell.dart @@ -10,6 +10,7 @@ class SidebarXCell extends StatefulWidget { required this.theme, required this.onTap, required this.onLongPress, + required this.onSecondaryTap, required this.animationController, }) : super(key: key); @@ -19,6 +20,7 @@ class SidebarXCell extends StatefulWidget { final SidebarXTheme theme; final VoidCallback onTap; final VoidCallback onLongPress; + final VoidCallback onSecondaryTap; final AnimationController animationController; @override @@ -64,6 +66,7 @@ class _SidebarXCellState extends State { child: GestureDetector( onTap: widget.onTap, onLongPress: widget.onLongPress, + onSecondaryTap: widget.onSecondaryTap, behavior: HitTestBehavior.opaque, child: Container( decoration: decoration?.copyWith( From 7c741b97d97940e37ecbaeb7310240dc7bb3d17f Mon Sep 17 00:00:00 2001 From: aroxu <30624945+aroxu@users.noreply.github.com> Date: Thu, 23 Nov 2023 17:11:53 +0900 Subject: [PATCH 3/3] Version 0.16.3 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 852cb00..3472d31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: sidebarx description: flutter multiplatform navigation sidebar / side navigationbar / drawer widget -version: 0.16.2 +version: 0.16.3 homepage: https://github.com/Frezyx/sidebarx repository: https://github.com/Frezyx/sidebarx