import 'package:flutter/material.dart';
import 'package:initial_folder/providers/tab_provider.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:provider/provider.dart';

class TabBarItems extends StatelessWidget {
  final int index;
  final String title;

  const TabBarItems({
    Key? key,
    required this.index,
    required this.title,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    TabProvider tab = Provider.of<TabProvider>(context, listen: false);

    return GestureDetector(
      onTap: () {
        tab.currentIndex = index;
      },
      child: Container(
        child: Column(
          children: [
            Text(
              title,
              style: thirdTextStyle.copyWith(
                color: tab.currentIndex == index
                    ? Theme.of(context).brightness == Brightness.light
        ? primaryColorligtmode
        : primaryColor
                    : fifteenColor,
                fontSize: getProportionateScreenWidth(12),
                fontWeight: semiBold,
              ),
            ),
            SizedBox(height: getProportionateScreenHeight(2)),
            Container(
              width: getProportionateScreenWidth(58),
              height: getProportionateScreenHeight(2),
              decoration: BoxDecoration(
                color: tab.currentIndex == index
                    ? Theme.of(context).brightness == Brightness.light
        ? primaryColorligtmode
        : primaryColor
                    : Colors.transparent,
                borderRadius:
                    BorderRadius.circular(getProportionateScreenHeight(19)),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
