From 839245f3d22cd51c5eec18393700548fcac22e53 Mon Sep 17 00:00:00 2001 From: begarudev Date: Fri, 26 Jul 2024 10:09:42 +0000 Subject: [PATCH 1/4] added option to add source package in svg assets --- lib/src/fluid_nav_bar.dart | 1 + lib/src/fluid_nav_bar_icon.dart | 4 + lib/src/fluid_nav_bar_item.dart | 6 ++ pubspec.lock | 161 +++++++++++++++++++++----------- 4 files changed, 115 insertions(+), 57 deletions(-) diff --git a/lib/src/fluid_nav_bar.dart b/lib/src/fluid_nav_bar.dart index 1c66040..4ae404c 100644 --- a/lib/src/fluid_nav_bar.dart +++ b/lib/src/fluid_nav_bar.dart @@ -174,6 +174,7 @@ class _FluidNavBarState extends State with TickerProviderStateMixin Colors.white, widget.scaleFactor, widget.animationFactor, + entry.value.package, ), ), ) diff --git a/lib/src/fluid_nav_bar_icon.dart b/lib/src/fluid_nav_bar_icon.dart index e122e0c..7967bd9 100644 --- a/lib/src/fluid_nav_bar_icon.dart +++ b/lib/src/fluid_nav_bar_icon.dart @@ -29,6 +29,9 @@ class FluidNavBarIcon { /// Extra information which can be used in [FluidNavBarItemBuilder] final Map? extras; + /// The Name of the Package the asset to be used from. + final String? package; + FluidNavBarIcon({ this.iconPath, this.svgPath, @@ -37,6 +40,7 @@ class FluidNavBarIcon { this.unselectedForegroundColor, this.backgroundColor, this.extras, + this.package, }) : assert(iconPath == null || svgPath == null || icon == null, 'Cannot provide both an svgPath and an icon.'), assert(iconPath != null || svgPath != null || icon != null, 'An svgPath or an icon must be provided.'); } diff --git a/lib/src/fluid_nav_bar_item.dart b/lib/src/fluid_nav_bar_item.dart index d6284a4..d4aef18 100644 --- a/lib/src/fluid_nav_bar_item.dart +++ b/lib/src/fluid_nav_bar_item.dart @@ -48,6 +48,9 @@ class FluidNavBarItem extends StatefulWidget { /// The delay factor of the animations ( < 1 is faster, > 1 is slower) final double animationFactor; + /// The Name of the Package the asset to be used from. + final String? package; + FluidNavBarItem( this.svgPath, this.icon, @@ -58,6 +61,7 @@ class FluidNavBarItem extends StatefulWidget { this.backgroundColor, this.scaleFactor, this.animationFactor, + this.package, ) : assert(scaleFactor >= 1.0), assert(svgPath == null || icon == null, 'Cannot provide both an iconPath and an icon.'), @@ -180,6 +184,7 @@ class _FluidNavBarItemState extends State width: _iconSize, height: _iconSize * scaleAnimation.value, colorBlendMode: BlendMode.srcIn, + package: widget.package, ) : Icon( widget.icon, @@ -199,6 +204,7 @@ class _FluidNavBarItemState extends State width: _iconSize, height: _iconSize * scaleAnimation.value, colorBlendMode: BlendMode.srcIn, + package: widget.package, ) : Icon( widget.icon, diff --git a/pubspec.lock b/pubspec.lock index 2582483..da59b5e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,51 +5,50 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -59,56 +58,95 @@ packages: dependency: "direct main" description: name: flutter_svg - url: "https://pub.dartlang.org" + sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" + url: "https://pub.dev" source: hosted - version: "0.22.0" + version: "1.1.6" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.12.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.0" path_drawing: dependency: transitive description: name: path_drawing - url: "https://pub.dartlang.org" + sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 + url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "1.0.1" path_parsing: dependency: transitive description: name: path_parsing - url: "https://pub.dartlang.org" + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "1.0.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.2" sky_engine: dependency: transitive description: flutter @@ -118,65 +156,74 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" source: hosted - version: "0.2.19" - typed_data: + version: "0.7.0" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.1.4" + vm_service: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "14.2.1" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "6.5.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.24.0-7.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" From 004b2368e68d24083b69471520962d2766e09613 Mon Sep 17 00:00:00 2001 From: begarudev Date: Sat, 27 Jul 2024 16:21:49 +0000 Subject: [PATCH 2/4] added option to change icon background colour depending upon state of the icon --- example/pubspec.lock | 166 ++++++++++++++++++++----------- lib/src/fluid_nav_bar.dart | 3 +- lib/src/fluid_nav_bar_item.dart | 10 +- lib/src/fluid_nav_bar_style.dart | 8 +- 4 files changed, 122 insertions(+), 65 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index c3b67db..7007af9 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,65 +5,65 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8" + url: "https://pub.dev" source: hosted version: "1.0.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.3.1" fluid_bottom_nav_bar: dependency: "direct main" description: path: ".." relative: true source: path - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -73,56 +73,95 @@ packages: dependency: transitive description: name: flutter_svg - url: "https://pub.dartlang.org" + sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" + url: "https://pub.dev" source: hosted - version: "0.22.0" + version: "1.1.6" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + url: "https://pub.dev" source: hosted - version: "0.12.10" + version: "0.8.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.12.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.0" path_drawing: dependency: transitive description: name: path_drawing - url: "https://pub.dartlang.org" + sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 + url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "1.0.1" path_parsing: dependency: transitive description: name: path_parsing - url: "https://pub.dartlang.org" + sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf + url: "https://pub.dev" source: hosted - version: "0.2.1" + version: "1.0.1" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.2" sky_engine: dependency: transitive description: flutter @@ -132,65 +171,74 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" source: hosted - version: "0.2.19" - typed_data: + version: "0.7.0" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "1.3.0" - vector_math: + version: "2.1.4" + vm_service: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "14.2.1" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" source: hosted - version: "5.1.0" + version: "6.5.0" sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.24.0-7.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/lib/src/fluid_nav_bar.dart b/lib/src/fluid_nav_bar.dart index 4ae404c..ab879ee 100644 --- a/lib/src/fluid_nav_bar.dart +++ b/lib/src/fluid_nav_bar.dart @@ -169,9 +169,10 @@ class _FluidNavBarState extends State with TickerProviderStateMixin entry.value.selectedForegroundColor ?? widget.style?.iconSelectedForegroundColor ?? Colors.black, entry.value.unselectedForegroundColor ?? widget.style?.iconUnselectedForegroundColor ?? Colors.grey, entry.value.backgroundColor ?? - widget.style?.iconBackgroundColor ?? + widget.style?.iconSelectedBackgroundColor ?? widget.style?.barBackgroundColor ?? Colors.white, + entry.value.unselectedForegroundColor ?? widget.style?.iconUnselectedBackgroundColor ?? Colors.white, widget.scaleFactor, widget.animationFactor, entry.value.package, diff --git a/lib/src/fluid_nav_bar_item.dart b/lib/src/fluid_nav_bar_item.dart index d4aef18..a7573f4 100644 --- a/lib/src/fluid_nav_bar_item.dart +++ b/lib/src/fluid_nav_bar_item.dart @@ -37,7 +37,10 @@ class FluidNavBarItem extends StatefulWidget { final Color unselectedForegroundColor; /// The background color of the item - final Color backgroundColor; + final Color selectedBackgroundColor; + + /// The background color of the item + final Color unselectedBackgroundColor; /// The temporary SVG scale used when the item pop final double scaleFactor; @@ -58,7 +61,8 @@ class FluidNavBarItem extends StatefulWidget { this.onTap, this.selectedForegroundColor, this.unselectedForegroundColor, - this.backgroundColor, + this.selectedBackgroundColor, + this.unselectedBackgroundColor, this.scaleFactor, this.animationFactor, this.package, @@ -170,7 +174,7 @@ class _FluidNavBarItemState extends State margin: EdgeInsets.all(ne.width / 2 - _iconSize), constraints: BoxConstraints.tight(Size.square(_iconSize * 2)), decoration: ShapeDecoration( - color: widget.backgroundColor, + color: _selected ? widget.selectedBackgroundColor : widget.unselectedBackgroundColor, shape: CircleBorder(), ), transform: Matrix4.translationValues(0, -_yOffsetAnimation.value, 0), diff --git a/lib/src/fluid_nav_bar_style.dart b/lib/src/fluid_nav_bar_style.dart index f0ff600..c43516c 100644 --- a/lib/src/fluid_nav_bar_style.dart +++ b/lib/src/fluid_nav_bar_style.dart @@ -24,7 +24,10 @@ class FluidNavBarStyle with Diagnosticable { final Color? barBackgroundColor; /// Icons background color - final Color? iconBackgroundColor; + final Color? iconSelectedBackgroundColor; + + /// Icons background color + final Color? iconUnselectedBackgroundColor; /// Icons color when activated final Color? iconSelectedForegroundColor; @@ -34,7 +37,8 @@ class FluidNavBarStyle with Diagnosticable { const FluidNavBarStyle({ this.barBackgroundColor, - this.iconBackgroundColor, + this.iconSelectedBackgroundColor, + this.iconUnselectedBackgroundColor, this.iconSelectedForegroundColor, this.iconUnselectedForegroundColor, }); From 5689f079c67cefd5ff0457724415fb99ba51dc04 Mon Sep 17 00:00:00 2001 From: begarudev Date: Sat, 10 Aug 2024 10:51:16 +0000 Subject: [PATCH 3/4] updated the constraint of the svg Image --- example/pubspec.lock | 4 +-- pubspec.lock | 78 +++++++++++++++++++++++++++++++++++++------- pubspec.yaml | 2 +- 3 files changed, 70 insertions(+), 14 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 7007af9..12e88bf 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8" + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.8" fake_async: dependency: transitive description: diff --git a/pubspec.lock b/pubspec.lock index da59b5e..432aec0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + args: + dependency: transitive + description: + name: args + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + url: "https://pub.dev" + source: hosted + version: "2.5.0" async: dependency: transitive description: @@ -58,15 +66,31 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "6ff9fa12892ae074092de2fa6a9938fb21dbabfdaa2ff57dc697ff912fc8d4b2" + sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "2.0.10+1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + http: + dependency: transitive + description: + name: http + sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + url: "https://pub.dev" + source: hosted + version: "1.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" leak_tracker: dependency: transitive description: @@ -123,14 +147,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" - path_drawing: - dependency: transitive - description: - name: path_drawing - sha256: bbb1934c0cbb03091af082a6389ca2080345291ef07a5fa6d6e078ba8682f977 - url: "https://pub.dev" - source: hosted - version: "1.0.1" path_parsing: dependency: transitive description: @@ -200,6 +216,38 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" + url: "https://pub.dev" + source: hosted + version: "1.1.11+1" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da + url: "https://pub.dev" + source: hosted + version: "1.1.11+1" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" + url: "https://pub.dev" + source: hosted + version: "1.1.11+1" vector_math: dependency: transitive description: @@ -216,6 +264,14 @@ packages: url: "https://pub.dev" source: hosted version: "14.2.1" + web: + dependency: transitive + description: + name: web + sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062 + url: "https://pub.dev" + source: hosted + version: "1.0.0" xml: dependency: transitive description: @@ -225,5 +281,5 @@ packages: source: hosted version: "6.5.0" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.4.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index 9ceb5d3..408970f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_svg: ^1.1.5 + flutter_svg: ^2.0.10 dev_dependencies: flutter_test: From b1fc84653574e69a98b4d3ec16f47957f8c27585 Mon Sep 17 00:00:00 2001 From: Garudev <144961613+Begarudev@users.noreply.github.com> Date: Tue, 13 Aug 2024 20:33:19 +0530 Subject: [PATCH 4/4] chore: made nav_bar background transparent --- lib/src/fluid_nav_bar.dart | 78 ++++++++++++++++++++++----------- lib/src/fluid_nav_bar_icon.dart | 6 ++- lib/src/fluid_nav_bar_item.dart | 6 +-- 3 files changed, 60 insertions(+), 30 deletions(-) diff --git a/lib/src/fluid_nav_bar.dart b/lib/src/fluid_nav_bar.dart index ab879ee..a694999 100644 --- a/lib/src/fluid_nav_bar.dart +++ b/lib/src/fluid_nav_bar.dart @@ -7,7 +7,8 @@ import './fluid_nav_bar_item.dart'; typedef void FluidNavBarChangeCallback(int selectedIndex); -typedef Widget FluidNavBarItemBuilder(FluidNavBarIcon icon, FluidNavBarItem item); +typedef Widget FluidNavBarItemBuilder( + FluidNavBarIcon icon, FluidNavBarItem item); /// A widget to display a fluid navigation bar with icon buttons. /// @@ -74,10 +75,12 @@ class FluidNavBar extends StatefulWidget { @override State createState() => _FluidNavBarState(); - static Widget _identityBuilder(FluidNavBarIcon icon, FluidNavBarItem item) => item; + static Widget _identityBuilder(FluidNavBarIcon icon, FluidNavBarItem item) => + item; } -class _FluidNavBarState extends State with TickerProviderStateMixin { +class _FluidNavBarState extends State + with TickerProviderStateMixin { int _currentIndex = 0; late final AnimationController _xController; @@ -89,8 +92,10 @@ class _FluidNavBarState extends State with TickerProviderStateMixin _currentIndex = widget.defaultIndex; - _xController = AnimationController(vsync: this, animationBehavior: AnimationBehavior.preserve); - _yController = AnimationController(vsync: this, animationBehavior: AnimationBehavior.preserve); + _xController = AnimationController( + vsync: this, animationBehavior: AnimationBehavior.preserve); + _yController = AnimationController( + vsync: this, animationBehavior: AnimationBehavior.preserve); Listenable.merge([_xController, _yController]).addListener(() { setState(() {}); @@ -99,7 +104,8 @@ class _FluidNavBarState extends State with TickerProviderStateMixin @override void didChangeDependencies() { - _xController.value = _indexToPosition(_currentIndex) / MediaQuery.of(context).size.width; + _xController.value = + _indexToPosition(_currentIndex) / MediaQuery.of(context).size.width; _yController.value = 1.0; super.didChangeDependencies(); @@ -118,6 +124,7 @@ class _FluidNavBarState extends State with TickerProviderStateMixin const height = FluidNavBar.nominalHeight; return Container( + color: Colors.transparent, width: appSize.width, height: FluidNavBar.nominalHeight, child: Stack( @@ -134,7 +141,9 @@ class _FluidNavBarState extends State with TickerProviderStateMixin top: 0, width: _getButtonContainerWidth(), height: height, - child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: _buildButtons()), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: _buildButtons()), ), ], ), @@ -166,13 +175,19 @@ class _FluidNavBarState extends State with TickerProviderStateMixin entry.value.icon, _currentIndex == entry.key, () => _handleTap(entry.key), - entry.value.selectedForegroundColor ?? widget.style?.iconSelectedForegroundColor ?? Colors.black, - entry.value.unselectedForegroundColor ?? widget.style?.iconUnselectedForegroundColor ?? Colors.grey, + entry.value.selectedForegroundColor ?? + widget.style?.iconSelectedForegroundColor ?? + Colors.black, + entry.value.unselectedForegroundColor ?? + widget.style?.iconUnselectedForegroundColor ?? + Colors.grey, entry.value.backgroundColor ?? widget.style?.iconSelectedBackgroundColor ?? widget.style?.barBackgroundColor ?? Colors.white, - entry.value.unselectedForegroundColor ?? widget.style?.iconUnselectedBackgroundColor ?? Colors.white, + entry.value.unselectedForegroundColor ?? + widget.style?.iconUnselectedBackgroundColor ?? + Colors.white, widget.scaleFactor, widget.animationFactor, entry.value.package, @@ -197,7 +212,9 @@ class _FluidNavBarState extends State with TickerProviderStateMixin final appWidth = MediaQuery.of(context).size.width; final buttonsWidth = _getButtonContainerWidth(); final startX = (appWidth - buttonsWidth) / 2; - return startX + index.toDouble() * buttonsWidth / buttonCount + buttonsWidth / (buttonCount * 2.0); + return startX + + index.toDouble() * buttonsWidth / buttonCount + + buttonsWidth / (buttonCount * 2.0); } void _handleTap(int index) { @@ -208,15 +225,18 @@ class _FluidNavBarState extends State with TickerProviderStateMixin }); _yController.value = 1.0; - _xController.animateTo(_indexToPosition(index) / MediaQuery.of(context).size.width, + _xController.animateTo( + _indexToPosition(index) / MediaQuery.of(context).size.width, duration: Duration(milliseconds: 620) * widget.animationFactor); Future.delayed( Duration(milliseconds: 500) * widget.animationFactor, () { - _yController.animateTo(1.0, duration: Duration(milliseconds: 1200) * widget.animationFactor); + _yController.animateTo(1.0, + duration: Duration(milliseconds: 1200) * widget.animationFactor); }, ); - _yController.animateTo(0.0, duration: Duration(milliseconds: 300) * widget.animationFactor); + _yController.animateTo(0.0, + duration: Duration(milliseconds: 300) * widget.animationFactor); if (widget.onChange != null) { widget.onChange!(index); @@ -253,26 +273,32 @@ class _BackgroundCurvePainter extends CustomPainter { // Paint two cubic bezier curves using various linear interpolations based off of the `_normalizedY` value final norm = LinearPointCurve(0.5, 2.0).transform(_normalizedY) / 2; - final radius = Tween(begin: _radiusTop, end: _radiusBottom).transform(norm); + final radius = + Tween(begin: _radiusTop, end: _radiusBottom).transform(norm); // Point colinear to the top edge of the background pane - final anchorControlOffset = - Tween(begin: radius * _horizontalControlTop, end: radius * _horizontalControlBottom) - .transform(LinearPointCurve(0.5, 0.75).transform(norm)); + final anchorControlOffset = Tween( + begin: radius * _horizontalControlTop, + end: radius * _horizontalControlBottom) + .transform(LinearPointCurve(0.5, 0.75).transform(norm)); // Point that slides up and down depending on distance for the target x position - final dipControlOffset = Tween(begin: radius * _pointControlTop, end: radius * _pointControlBottom) + final dipControlOffset = Tween( + begin: radius * _pointControlTop, end: radius * _pointControlBottom) .transform(LinearPointCurve(0.5, 0.8).transform(norm)); - final y = Tween(begin: _topY, end: _bottomY).transform(LinearPointCurve(0.2, 0.7).transform(norm)); - final dist = - Tween(begin: _topDistance, end: _bottomDistance).transform(LinearPointCurve(0.5, 0.0).transform(norm)); + final y = Tween(begin: _topY, end: _bottomY) + .transform(LinearPointCurve(0.2, 0.7).transform(norm)); + final dist = Tween(begin: _topDistance, end: _bottomDistance) + .transform(LinearPointCurve(0.5, 0.0).transform(norm)); final x0 = _x - dist / 2; final x1 = _x + dist / 2; final path = Path() ..moveTo(0, 0) ..lineTo(x0 - radius, 0) - ..cubicTo(x0 - radius + anchorControlOffset, 0, x0 - dipControlOffset, y, x0, y) + ..cubicTo( + x0 - radius + anchorControlOffset, 0, x0 - dipControlOffset, y, x0, y) ..lineTo(x1, y) - ..cubicTo(x1 + dipControlOffset, y, x1 + radius - anchorControlOffset, 0, x1 + radius, 0) + ..cubicTo(x1 + dipControlOffset, y, x1 + radius - anchorControlOffset, 0, + x1 + radius, 0) ..lineTo(size.width, 0) ..lineTo(size.width, size.height) ..lineTo(0, size.height); @@ -284,6 +310,8 @@ class _BackgroundCurvePainter extends CustomPainter { @override bool shouldRepaint(_BackgroundCurvePainter oldPainter) { - return _x != oldPainter._x || _normalizedY != oldPainter._normalizedY || _color != oldPainter._color; + return _x != oldPainter._x || + _normalizedY != oldPainter._normalizedY || + _color != oldPainter._color; } } diff --git a/lib/src/fluid_nav_bar_icon.dart b/lib/src/fluid_nav_bar_icon.dart index 7967bd9..a0cfaa4 100644 --- a/lib/src/fluid_nav_bar_icon.dart +++ b/lib/src/fluid_nav_bar_icon.dart @@ -41,6 +41,8 @@ class FluidNavBarIcon { this.backgroundColor, this.extras, this.package, - }) : assert(iconPath == null || svgPath == null || icon == null, 'Cannot provide both an svgPath and an icon.'), - assert(iconPath != null || svgPath != null || icon != null, 'An svgPath or an icon must be provided.'); + }) : assert(iconPath == null || svgPath == null || icon == null, + 'Cannot provide both an svgPath and an icon.'), + assert(iconPath != null || svgPath != null || icon != null, + 'An svgPath or an icon must be provided.'); } diff --git a/lib/src/fluid_nav_bar_item.dart b/lib/src/fluid_nav_bar_item.dart index a7573f4..23dfc58 100644 --- a/lib/src/fluid_nav_bar_item.dart +++ b/lib/src/fluid_nav_bar_item.dart @@ -1,6 +1,4 @@ import 'package:fluid_bottom_nav_bar/fluid_bottom_nav_bar.dart'; -import 'package:fluid_bottom_nav_bar/src/fluid_nav_bar_icon.dart'; -import 'package:flutter/animation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; @@ -174,7 +172,9 @@ class _FluidNavBarItemState extends State margin: EdgeInsets.all(ne.width / 2 - _iconSize), constraints: BoxConstraints.tight(Size.square(_iconSize * 2)), decoration: ShapeDecoration( - color: _selected ? widget.selectedBackgroundColor : widget.unselectedBackgroundColor, + color: _selected + ? widget.selectedBackgroundColor + : widget.unselectedBackgroundColor, shape: CircleBorder(), ), transform: Matrix4.translationValues(0, -_yOffsetAnimation.value, 0),