Untitled

mail@pastecode.io avatar
unknown
dart
a year ago
7.0 kB
1
Indexable
Never
part of persistent_bottom_nav_bar; class BottomNavStyle15 extends StatelessWidget { final NavBarEssentials? navBarEssentials; final NavBarDecoration? navBarDecoration; BottomNavStyle15({ Key? key, this.navBarEssentials = const NavBarEssentials(items: null), this.navBarDecoration = const NavBarDecoration(), }); Widget _buildItem(BuildContext context, PersistentBottomNavBarItem item, bool isSelected, double? height) { return this.navBarEssentials!.navBarHeight == 0 ? SizedBox.shrink() : Container( width: 150.0, height: height, color: Colors.transparent, padding: EdgeInsets.only( top: this.navBarEssentials!.padding?.top ?? this.navBarEssentials!.navBarHeight! * 0.15, bottom: this.navBarEssentials!.padding?.bottom ?? this.navBarEssentials!.navBarHeight! * 0.12), child: Container( alignment: Alignment.center, height: height, child: ListView( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), scrollDirection: Axis.horizontal, children: <Widget>[ Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( child: IconTheme( data: IconThemeData( size: item.iconSize, color: isSelected ? (item.activeColorSecondary == null ? item.activeColorPrimary : item.activeColorSecondary) : item.inactiveColorPrimary == null ? item.activeColorPrimary : item.inactiveColorPrimary), child: isSelected ? item.icon : item.inactiveIcon ?? item.icon, ), ), item.title == null ? SizedBox.shrink() : Padding( padding: const EdgeInsets.only(top: 15.0), child: Material( type: MaterialType.transparency, child: FittedBox( child: Text( item.title!, style: item.textStyle != null ? (item.textStyle!.apply( color: isSelected ? (item.activeColorSecondary == null ? item.activeColorPrimary : item.activeColorSecondary) : item.inactiveColorPrimary)) : TextStyle( color: isSelected ? (item.activeColorSecondary == null ? item.activeColorPrimary : item.activeColorSecondary) : item.inactiveColorPrimary, fontWeight: FontWeight.w400, fontSize: 12.0), )), ), ) ], ) ], ), ), ); } Widget _buildMiddleItem( PersistentBottomNavBarItem item, bool isSelected, double? height) { return this.navBarEssentials!.navBarHeight == 0 ? SizedBox.shrink() : Padding( padding: EdgeInsets.only( top: this.navBarEssentials!.padding?.top ?? 0.0, bottom: this.navBarEssentials!.padding?.bottom ?? 0.0), child: Stack( children: <Widget>[ Transform.translate( offset: Offset(0, -23), child: Center( child: Container( width: 150.0, height: height, margin: EdgeInsets.only(top: 2.0), decoration: BoxDecoration( shape: BoxShape.circle, color: item.activeColorPrimary, border: Border.all(color: Colors.transparent, width: 5.0), boxShadow: this.navBarDecoration!.boxShadow, ), child: Container( alignment: Alignment.center, height: height, child: ListView( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), scrollDirection: Axis.horizontal, children: <Widget>[ Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( child: IconTheme( data: IconThemeData( size: item.iconSize, color: item.activeColorSecondary == null ? item.activeColorPrimary : item.activeColorSecondary), child: isSelected ? item.icon : item.inactiveIcon ?? item.icon, ), ), ], ) ], ), ), ), ), ), item.title == null ? SizedBox.shrink() : Padding( padding: const EdgeInsets.only(bottom: 5.0), child: Align( alignment: Alignment.bottomCenter, child: Material( type: MaterialType.transparency, child: FittedBox( child: Text( item.title!, style: item.textStyle != null ? (item.textStyle!.apply( color: isSelected ? (item.activeColorSecondary == null ? item.activeColorPrimary : item.activeColorSecondary) : item.inactiveColorPrimary)) : TextStyle( color: isSelected ? (item.activeColorPrimary) : item.inactiveColorPrimary, fontWeight: FontWeight.w400, fontSize: 12.0), )), ), ), ) ], ), ); } @override Widget build(BuildContext context) { final midIndex = (this.navBarEssentials!.items!.length / 2).floor(); return Container( width: double.infinity, height: this.navBarEssentials!.navBarHeight, color: Colors.transparent, child: Stack( children: <Widget>[ ClipRRect( borderRadius: this.navBarDecoration!.borderRadius ?? BorderRadius.zero, child: BackdropFilter( filter: this .navBarEssentials! .items![this.navBarEssentials!.selectedIndex!] .filter ?? ImageFilter.blur(sigmaX: 0.5, sigmaY: 0.5), child:ClipPath(clipper: TriangleClipper(),child: Container(color: Colors.white,child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.center, children: this.navBarEssentials!.items!.map((item) { int index = this.navBarEssentials!.items!.indexOf(item); return Flexible( child: GestureDetector( onTap: () { if (this.navBarEssentials!.items![index].onPressed != null) { this.navBarEssentials!.items![index].onPressed!(this .navBarEssentials! .selectedScreenBuildContext); } else { this.navBarEssentials!.onItemSelected!(index); } }, child: index == midIndex ? ClipPath(clipper: TriangleClipper(),child: Container(width: 150, color: Colors.transparent),) : _buildItem( context, item, this.navBarEssentials!.selectedIndex == index, this.navBarEssentials!.navBarHeight), ), ); }).toList(), ),),), ), ), this.navBarEssentials!.navBarHeight == 0 ? SizedBox.shrink() : Center( child: GestureDetector( onTap: () { if (this.navBarEssentials!.items![midIndex].onPressed != null) { this.navBarEssentials!.items![midIndex].onPressed!( this .navBarEssentials! .selectedScreenBuildContext); } else { this.navBarEssentials!.onItemSelected!(midIndex); } }, child: _buildMiddleItem( this.navBarEssentials!.items![midIndex], this.navBarEssentials!.selectedIndex == midIndex, this.navBarEssentials!.navBarHeight)), ) ], ), ); } } class TriangleClipper extends CustomClipper<Path> { @override Path getClip(Size size) { Path path_0 = Path(); path_0.moveTo(0, size.height); path_0.lineTo(0, 0); path_0.lineTo(size.width * 0.3750000, 0); // path_0.quadraticBezierTo(size.width * 0.4018750, size.height * -0.0017500, // size.width * 0.4000000, size.height * 0.0550000); path_0.quadraticBezierTo(size.width * 0.4018750, size.height * -0.0017500, size.width * 0.4020125, size.height * 0.0100000); // path_0.cubicTo( // size.width * 0.4449625, // size.height -6, // size.width * 0.5557750, // size.height -6, // size.width * 0.5908875, // size.height * 0.0550000); // path_0.cubicTo( // size.width * 0.4449625, // size.height +2, // size.width * 0.5557750, // size.height +2, // size.width * 0.6008875, // size.height * 0.0550000); path_0.cubicTo( size.width * 0.4039625, size.height , size.width * 0.5957750, size.height , size.width * 0.6008875, size.height * 0.0550000); // 0.6059999 // path_0.quadraticBezierTo( // size.width * 0.6090125, 0, size.width * 0.6050000, 0); path_0.quadraticBezierTo( size.width * 0.6010125, 0, size.width * 0.6000000, 0); path_0.lineTo(size.width, 0); path_0.lineTo(size.width, size.height); path_0.lineTo(0, size.height); path_0.close(); return path_0; } @override bool shouldReclip(TriangleClipper oldClipper) => false; }