
import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';

class RoleTypeTab extends StatefulWidget {
  int selectedIndex;
  List<DropValue> dropList;
  Function(DropValue value) onSelect;

  RoleTypeTab(this.selectedIndex, this.dropList, {required this.onSelect});

  @override
  State<RoleTypeTab> createState() => _RoleTypeTabState();
}

class _RoleTypeTabState extends State<RoleTypeTab> {
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: double.infinity,
      height: 45,
      child: ListView.separated(
        itemBuilder: (context, index) {
          return InkWell(
            onTap: () {
              setState(() {
                widget.selectedIndex = index;
                widget.onSelect(widget.dropList[index]);
              });
            },
            child: Container(
              width: (MediaQuery.of(context).size.width / 2)-30,
              height: 45,
              decoration: BoxDecoration(
                color: widget.selectedIndex == index ? MyColors.darkPrimaryColor : Colors.grey[200],
                // border: Border.all(color: type == ClassType.NUMBER ? MyColors.darkPrimaryColor : Colors.transparent, width: 2),
                borderRadius: const BorderRadius.all(Radius.circular(0)),
              ),
              child: Center(
                child: Text(
                  widget.dropList[index].value,
                  style: TextStyle(
                    color: widget.selectedIndex == index ? MyColors.white : Colors.black,
                    fontSize: 10,
                  ),
                ),
              ),
            ),
          );
        },
        separatorBuilder: (context, index) {
          return 12.width;
        },
        itemCount: widget.dropList.length,
        scrollDirection: Axis.horizontal,
      ),
    );
  }
}
