You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0KB

  1. import 'package:farm_tpf/custom_model/SuppliesUsing.dart';
  2. import 'package:get/get.dart';
  3. class ChangeSupplyUsing extends GetxController {
  4. List<SuppliesUsing> currentItems;
  5. SuppliesUsing currentSupplyUsing;
  6. int currentIndex;
  7. void init(List<SuppliesUsing> initItems) {
  8. currentItems = initItems;
  9. currentSupplyUsing = SuppliesUsing();
  10. currentIndex = -1;
  11. update();
  12. }
  13. void changeIndexEdit(int index) {
  14. currentIndex = index;
  15. update();
  16. }
  17. void changeInitList(List<SuppliesUsing> sups) {
  18. currentItems = sups;
  19. update();
  20. }
  21. void addSupply(SuppliesUsing supplyUsing) {
  22. currentItems.insert(0, supplyUsing);
  23. currentSupplyUsing = SuppliesUsing();
  24. update();
  25. }
  26. void deleteSupply(int index) {
  27. currentItems.removeAt(index);
  28. currentSupplyUsing = SuppliesUsing();
  29. update();
  30. }
  31. void editSupply(int index, SuppliesUsing supplyUsing) {
  32. var newSup = supplyUsing;
  33. newSup.id = currentItems[index].id;
  34. currentItems[index] = newSup;
  35. currentSupplyUsing = SuppliesUsing();
  36. update();
  37. }
  38. }