import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/widgets/radio/show_radio.dart';

class SearchOptionsSheet extends StatelessWidget {
  String selectedType;
  Function(String) onSelection;

  SearchOptionsSheet(this.selectedType, {required this.onSelection});

  List<String> searchOptions = [
    "Workflow",
    "Favorites",
    "Employee ID",
    "Employee Email",
    "Employee Name",
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.only(left: 20, right: 20, top: 8, bottom: 8),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          LocaleKeys.searchBy.tr().toText16(),
          12.height,
          ListView.separated(
            itemBuilder: (context, index) {
              return Container(
                width: double.infinity,
                padding: EdgeInsets.only(top: 12, bottom: 12),
                child: ShowRadio(
                  title: searchOptions[index],
                  value: searchOptions[index],
                  groupValue: selectedType,
                  selectedColor: MyColors.gradiantStartColor,
                ),
              ).onPress(() {
                onSelection(searchOptions[index]);
                Navigator.pop(context);
              });
            },
            separatorBuilder: (context, index) {
              return 1.divider;
            },
            itemCount: searchOptions.length,
            physics: NeverScrollableScrollPhysics(),
            shrinkWrap: true,
          )
        ],
      ),
    );
  }
}
