import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:habitrack_app/sembast/item_repository.dart';
import 'package:habitrack_app/sembast/sembast_item_repository.dart';

final homeControllerProvider = Provider(
  (ref) => HomeController(
    itemRepository: ref.watch(itemRepositoryProvider),
  ),
);

class HomeController {
  HomeController({required this.itemRepository});

  final ItemRepository itemRepository;

  Future<void> delete(int id) async {
    await itemRepository.deleteItem(id);
  }

  Future<void> edit(dynamic item) async {
    await itemRepository.updateItem(item);
  }

  Future<void> add(dynamic newItem) async {
    await itemRepository.insertItem(newItem);
  }
}
