import 'package:diplomaticquarterapp/Constants.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/login/welcome.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class BottomNavPharmacyItem extends StatelessWidget {
  final String title;
  final IconData icon;

  final ValueChanged<int> changeIndex;
  final int index;
  final int currentIndex;
  final Function onTap;
  final bool isHome;

  final IconData activeIcon;
  BottomNavPharmacyItem(
      {this.icon,
      this.changeIndex,
      this.index,
      this.currentIndex,
      this.activeIcon,
      this.title,
      this.onTap,
      this.isHome = false});

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: SizedBox(
        // height: 72.0,
        child: Material(
          type: MaterialType.transparency,
          child: InkWell(
            highlightColor: Colors.transparent,
            splashColor: Colors.transparent,
            onTap: () {
              if(!Provider.of<ProjectViewModel>(context, listen: false).isLogin && (currentIndex == 2|| currentIndex == 3))
                Navigator.push(
                  context,
                  FadePage(page: WelcomeLogin()),
                );
              else
              changeIndex(currentIndex);

            },
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                SizedBox(
                  height: 15,
                ),
                currentIndex == index
                    ? Divider(
                        color: Color(0xff5AB145),
                        thickness: 3.5,
                      )
                    : Divider(
                        thickness: 0,
                      ),
                Container(
                  child: Icon(currentIndex == index ? activeIcon : icon,
                      color: isHome
                          ? Color(0xff5AB145)
                          : currentIndex == index
                              ? Colors.grey
                              : Colors.grey,
                      size: 22.0),
                ),
                SizedBox(
                  height: 11,
                ),

                // Added TextAlign Property
                Texts(
                  title,
                  textAlign: TextAlign.center,
                  color: currentIndex == index ? Colors.grey : Colors.grey,
                  fontWeight:
                      currentIndex == index ? FontWeight.bold : FontWeight.w400,
                  fontSize: currentIndex == index ? 13 : 11,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
