import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:remever/common/resources.dart';
import 'package:remever/common/widgets/typography.dart';
import 'package:remever/common/widgets/wspace.dart';
import 'package:remever/components/extensions/context.dart';
import 'package:remever/components/extensions/state.dart';
import 'package:remever/widgets/debug/app_debug.dart';

class CollectionsFilters extends StatefulWidget {
  const CollectionsFilters({super.key});

  @override
  State<CollectionsFilters> createState() => _CollectionsFiltersState();
}

class _CollectionsFiltersState extends State<CollectionsFilters> {
  @override
  Widget build(BuildContext context) {
    return AppDebug(
      builder: (context, isDebug) {
        if (!isDebug) return HSpace(20);

        return Padding(
          padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 28).r,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              _buildFilterButton(AppColors.white, 'Все', () {
                safeSetState(() {});
              }),
              _buildFilterButton(AppColors.gray_bg, 'Публичные', () {
                safeSetState(() {});
              }),
              _buildFilterButton(AppColors.gray_bg, 'Подписки', () {
                safeSetState(() {});
              }),
            ],
          ),
        );
      },
    );
  }

  ///
  /// Построение кнопки фильтра
  ///
  Widget _buildFilterButton(Color color, String title, void Function()? onTap) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        width: 103.h,
        height: 36.h,
        decoration: BoxDecoration(
          borderRadius: const BorderRadius.all(Radius.circular(16)).r,
          color: color,
        ),
        child: Center(child: AppTypography(title, type: SemiBold14px())),
      ),
    );
  }
}
