import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../../library/multi_selector/multi_select_bottom_sheet.dart';
import '../../../../../library/multi_selector/multi_select_item.dart';
import '../../../../data/models/models.dart';
import '../controller.dart';
import 'b_s_price_filter.dart';

class BSChooseFilter extends StatelessWidget {
  final FilterModel model;

  BSChooseFilter({required this.model});

  @override
  Widget build(BuildContext context) {
    debugPrint('model ${model.options.length}');
    return GetBuilder<FilterController>(
      // init: FilterController(),
      builder: (fc) => model.code != 'price'
          ? MultiSelectBottomSheet(
              initialValue: model.selectedOptions,
              title: model.name,
              items: model.options.map((option) => MultiSelectItem<FilterOption>(option, option.adminName)).toList(),
              onConfirm: (selectedItems) => fc.onMultipleSelectionConfirmed(model, selectedItems),
              onClear: (selectedItems) => fc.onMultipleSelectionCleared(model),
              separateSelectedItems: true,
            )
          : BSPriceFilter(title: model.name),
    );
  }
}
