import 'package:flutter/material.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/views/your_tenders/strings/your_tenders_strings.dart';

import 'your_tenders_filter_dialog.dart';

enum PlatformType { mobile, tabletDesktop }

class FilterButton extends StatelessWidget {
  final PlatformType platformType;
  const FilterButton({required this.platformType, super.key});

  void _openFilter(BuildContext context) {
    if (platformType == PlatformType.mobile) {
      showModalBottomSheet(
        context: context,
        isScrollControlled: true,
        backgroundColor: AppColors.backgroundColor,
        shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
        ),
        builder: (_) => const YourTendersFilterDialog(),
      );
    } else {
      showDialog(
        context: context,
        builder:
            (_) => Dialog(
              backgroundColor: AppColors.backgroundColor,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16),
              ),
              child: const YourTendersFilterDialog(),
            ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    // Mobile style: container with icon and text
    return Padding(
      padding: const EdgeInsets.all(12),
      child: InkWell(
        onTap: () => _openFilter(context),
        borderRadius: BorderRadius.circular(12),

        child: Container(
          padding: const EdgeInsets.symmetric(vertical: 12),
          decoration: BoxDecoration(
            color: AppColors.primary20,
            borderRadius: BorderRadius.circular(12),
          ),
          child: Center(
            child: Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                const Icon(Icons.filter_list, color: Colors.blue),
                const SizedBox(width: 8),
                Text(
                  YourTendersStrings.filter,
                  style: TextStyle(
                    color: AppColors.textBlue,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
