import 'package:flutter/cupertino.dart';
import 'package:rasadyar_core/core.dart';

class BaseLogic extends GetxController {
  final RxBool isFilterSelected = false.obs;
  final RxBool isSearchSelected = false.obs;
  final TextEditingController searchTextController = TextEditingController();
  final RxnString searchValue = RxnString();

  void setSearchCallback(void Function(String)? onSearchChanged) {
    debounce<String?>(searchValue, (val) {
      if (val != null && val.trim().isNotEmpty) {
        onSearchChanged?.call(val);
      }
    }, time: const Duration(milliseconds: 600));
  }

  void toggleFilter() {
    isFilterSelected.value = !isFilterSelected.value;
  }

  void toggleSearch() {
    isSearchSelected.value = !isSearchSelected.value;
  }
}
