import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hoshan/core/gen/assets.gen.dart';
import 'package:hoshan/ui/theme/colors.dart';
import 'package:hoshan/ui/theme/cubit/theme_mode_cubit.dart';
import 'package:hoshan/ui/theme/text.dart';

class TabBtn extends StatelessWidget {
  final String title;
  final SvgGenImage icon;
  final bool active;
  final Function()? click;
  const TabBtn(
      {super.key,
      required this.title,
      required this.icon,
      required this.active,
      this.click});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: click,
      child: Column(
        children: [
          icon.svg(
              color: active
                  ? Theme.of(context).colorScheme.secondary
                  : AppColors.gray[
                      context.read<ThemeModeCubit>().isDark() ? 400 : 700]),
          Text(
            title,
            style: AppTextStyles.body4.copyWith(
                fontWeight: FontWeight.bold,
                color: active
                    ? Theme.of(context).colorScheme.secondary
                    : AppColors.gray[
                        context.read<ThemeModeCubit>().isDark() ? 400 : 700]),
          ),
          Opacity(
            opacity: active ? 1 : 0,
            child: Container(
              width: double.infinity,
              height: 12,
              margin: const EdgeInsets.fromLTRB(12, 4, 12, 0),
              decoration: BoxDecoration(
                  color: Theme.of(context).colorScheme.secondary,
                  borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(16),
                      topRight: Radius.circular(16))),
            ),
          )
        ],
      ),
    );
  }
}
