import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:tm_app/core/constants/assets.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/views/liked_tenders/strings/liked_tenders_strings.dart';

import '../../shared/base_button.dart';

class LikedTendersFilterDrawer extends StatelessWidget {
  const LikedTendersFilterDrawer({required this.isTablet, super.key});

  final bool isTablet;

  @override
  Widget build(BuildContext context) {
    return isTablet
        ? IconButton(
          icon: SvgPicture.asset(
            AssetsManager.filter,
            height: 24.0.w(),
            width: 24.0.w(),
          ),
          onPressed: () {
            showModalBottomSheet(
              context: context,
              isScrollControlled: true,
              backgroundColor: AppColors.backgroundColor,
              shape: const RoundedRectangleBorder(
                borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
              ),
              constraints: BoxConstraints(
                maxWidth: MediaQuery.of(context).size.width,
                maxHeight: MediaQuery.of(context).size.height,
              ),
              builder: (context) {
                return SizedBox(
                  width: double.infinity,
                  child: Padding(
                    padding: const EdgeInsets.all(16.0),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        SizedBox(height: 10.0.h()),
                        Text(
                          LikedTendersStrings.filter,
                          style: TextStyle(
                            fontWeight: FontWeight.w600,
                            color: AppColors.grey70,
                            fontSize: 20.0.sp(),
                          ),
                        ),
                        SizedBox(height: 20.0.h()),
                        _buildFilterOption('Industry'),
                        _buildFilterOption('Finance'),
                        _buildFilterOption('Business'),
                        _buildFilterOption('IT'),
                        _buildFilterOption('Software'),
                        SizedBox(height: 20.0.h()),
                        BaseButton(
                          backgroundColor: AppColors.primary2,
                          borderRadius: 24,
                          isEnabled: true,
                          onPressed: () => Navigator.pop(context),
                          text: 'Apply',
                          textColor: AppColors.textBlue,
                        ),
                      ],
                    ),
                  ),
                );
              },
            );
          },
        )
        : Drawer(
          backgroundColor: AppColors.backgroundColor,
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                SizedBox(height: 30.0.h()),
                Text(
                  LikedTendersStrings.filter,
                  style: TextStyle(
                    fontWeight: FontWeight.w600,
                    color: AppColors.grey70,
                    fontSize: 20.0.sp(),
                  ),
                ),
                SizedBox(height: 20.0.h()),

                _buildFilterOption('Industry'),
                _buildFilterOption('Finance'),
                _buildFilterOption('Business'),
                _buildFilterOption('IT'),
                _buildFilterOption('Software'),

                const Spacer(),

                BaseButton(
                  backgroundColor: AppColors.primary2,
                  borderRadius: 24,
                  isEnabled: true,
                  onPressed: () {
                    Navigator.pop(context);
                  },
                  text: LikedTendersStrings.apply,
                  textColor: AppColors.textBlue,
                ),

                SizedBox(height: 20.0.h()),
              ],
            ),
          ),
        );
  }

  Widget _buildFilterOption(String title) {
    return Padding(
      padding: EdgeInsets.symmetric(vertical: 8.0.h()),
      child: Align(
        alignment: Alignment.centerLeft,
        child: Text(
          title,
          style: TextStyle(
            fontSize: 16.0.sp(),
            color: AppColors.grey80,
            fontWeight: FontWeight.w400,
          ),
        ),
      ),
    );
  }
}
