import 'package:badges/badges.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:badges/badges.dart' as badge;

class BottomNavigationItem extends StatelessWidget {
  final IconData? icon;
  final IconData? activeIcon;
  final ValueChanged<int>? changeIndex;
  final int? index;
  final int? currentIndex;
  final String? name;
  final DashboardViewModel? dashboardViewModel;
  final String? svgPath;

  BottomNavigationItem(
      {this.icon,
      this.activeIcon,
      this.changeIndex,
      this.index,
      this.currentIndex,
      this.name,
      this.dashboardViewModel,
      this.svgPath});

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: SizedBox(
        height: 70.0,
        child: Material(
          type: MaterialType.transparency,
          child: InkWell(
            highlightColor: Colors.transparent,
            splashColor: Colors.transparent,
            onTap: () => changeIndex!(currentIndex!),
            child: Stack(
              alignment: AlignmentDirectional.center,
              children: [
                if (currentIndex == index)
                  Positioned(
                      top: 0,
                      child: Container(
                        color: AppGlobal.appRedColor,
                        width: 100,
                        height: 3,
                      )),
                Column(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      height: 15,
                    ),
                    Container(
                      child: SvgPicture.asset(
                        svgPath!,
                        width: SizeConfig.widthMultiplier! * (10),
                        height: SizeConfig.getHeightMultiplier(
                                height: SizeConfig.heightMultiplier! *
                                    (SizeConfig.isHeightVeryShort
                                        ? 10
                                        : SizeConfig.isHeightShort
                                            ? 8.5
                                            : 7)) *
                            40,
                      ),
                    ),
                    SizedBox(
                      height: 8,
                    ),
                    Expanded(
                        child: AppText(name ?? "",
                            textAlign: TextAlign.center,
                            fontSize:
                                SizeConfig.getTextMultiplierBasedOnWidth() *
                                    2.5,
                            letterSpacing: -0.24,
                            color: AppGlobal.appTextColor,
                            fontWeight: FontWeight.w600) //#989898,
                        ),
                  ],
                ),
                if (currentIndex == 3 &&
                    dashboardViewModel!.notRepliedCount != 0)
                  Positioned(
                    right: 18.0,
                    bottom: 40.0,
                    child: badge.Badge(
                      badgeAnimation:
                          badge.BadgeAnimation.fade(toAnimate: false),
                      position: BadgePosition.topEnd(),
                      badgeStyle: badge.BadgeStyle(
                        shape: BadgeShape.circle,
                        badgeColor: Colors.red[800]!,
                        borderRadius: BorderRadius.circular(8),
                      ),
                      badgeContent: Container(
                        // padding: EdgeInsets.all(2.0),
                        child: AppText(
                            dashboardViewModel!.notRepliedCount.toString(),
                            color: Colors.white,
                            fontSize: 12.0),
                      ),
                    ),
                  ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
