You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App/lib/widgets/bottom_navigation/bottom_navigation_item.dart

157 lines
6.7 KiB
Dart

2 years ago
import 'package:badges/badges.dart' as badge_import;
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
4 years ago
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
4 years ago
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
5 years ago
import '../../Constants.dart';
class BottomNavigationItem extends StatelessWidget {
4 years ago
final String icon;
final String activeIcon;
final ValueChanged<int> changeIndex;
final int index;
final int currentIndex;
final String name;
final bool isDisabled;
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
BottomNavigationItem({this.icon, this.activeIcon, this.changeIndex, this.index, this.currentIndex, this.name, this.isDisabled = false});
@override
Widget build(BuildContext context) {
var model = Provider.of<ToDoCountProviderModel>(context);
4 years ago
ProjectViewModel projectViewModel = Provider.of(context);
return Expanded(
child: SizedBox(
6 years ago
// height: 72.0,
child: Material(
type: MaterialType.transparency,
child: InkWell(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onTap: () {
if (!isDisabled) changeIndex(currentIndex);
},
child: currentIndex != 4
? Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 15,
),
4 years ago
icon == "assets/images/new/bottom_nav/help.svg" ? Container(
child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover),
) : Container(
child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index
? Color(0xff333c45)
: Color(0xff989898)),
),
SizedBox(
5 years ago
height: 2,
),
Texts(
name,
textAlign: TextAlign.center,
color: currentIndex == index
4 years ago
? Color(0xff333c45)
: isDisabled
? Colors.grey[300]
: Colors.grey,
fontSize: 11,
),
5 years ago
SizedBox(
height: 7,
),
],
)
4 years ago
: (authenticatedUserObject.isLogin && model.isShowBadge)
? Stack(
alignment: AlignmentDirectional.center,
children: [
Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 15,
),
Container(
4 years ago
child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover, color: currentIndex == index
? Color(0xff333c45)
: Color(0xff989898)),
// Icon(currentIndex == index ? activeIcon : icon, color: currentIndex == index ? secondaryColor : Theme.of(context).dividerColor, size: 22.0),
),
SizedBox(
5 years ago
height: 2,
),
Texts(
name,
textAlign: TextAlign.center,
4 years ago
color: currentIndex == index ? Color(0xff333c45) : Colors.grey,
fontSize: 11,
),
5 years ago
SizedBox(
height: 7,
),
],
),
4 years ago
Positioned(
right: 18.0,
bottom: 28.0,
2 years ago
child: badge_import.Badge(
4 years ago
toAnimate: false,
2 years ago
position: badge_import.BadgePosition.topEnd(),
shape: badge_import.BadgeShape.circle,
4 years ago
badgeColor: secondaryColor.withOpacity(1.0),
borderRadius: BorderRadius.circular(8),
badgeContent: Container(
padding: EdgeInsets.all(2.0),
child: Text(model.count.toString(), style: TextStyle(color: Colors.white, fontSize: 14.0)),
),
),
),
],
)
: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 15,
),
Container(
4 years ago
child: SvgPicture.asset(icon, height: 20, width: 20, fit: BoxFit.cover),
),
SizedBox(
5 years ago
height: 2,
),
Texts(
name,
textAlign: TextAlign.center,
color: currentIndex == index
4 years ago
? Color(0xff333c45)
: isDisabled
? Colors.grey[300]
: Colors.grey,
fontSize: 11,
),
5 years ago
SizedBox(
height: 7,
),
],
),
),
),
),
);
}
}