import '../api/garden_api.service.dart'; import '../constance.dart'; import '../entities/beet.dart'; import '../entities/beet_row.dart'; import '../entities/plant.dart'; import '../logic/beet.service.dart'; import '../logic/beet_row.service.dart'; import '../logic/plant.service.dart'; class BeetRepository { late Beet beet; final BeetService beetService; final BeetRowService beetRowService; final PlantService plantService; final GardenApiService apiService; late String _messages; BeetRepository(this.beetRowService, this.plantService, this.apiService, this.beetService) { beet = Beet(); _messages = "Keine Meldungen"; } String get messages => _messages; bool get newRowAllowed => beet.beetRows.length < Constance.maxNumberOfRows; void addPlantToRowById(int rowId, Plant plant) { beetService.addPlantToRowById(beet, beetRowService, rowId, plant); } void addNewRowToBeet() { beetService.addNewRow(beet); } double getMaxHorizontalSpace() { return beetService.getMaxHorizontalSpaceOfRows(beetRowService, beet); } bool isActionNeeded(DateTime date) { return beetService.isActionNeeded(beetRowService, plantService, beet, date); } List getVerticalSpaceValue() { return beetService.getVerticalPlantingSpace(beetRowService, beet); } void removePlantFromRowById(int rowId, int plantInRowId) { var row = beetRowService.getRowById(beet, rowId); beetRowService.removePlantFromRowById(row, plantInRowId); } Future saveBeet() async { _messages = await beetService.saveBeet(apiService, beet); } Future> getAllPlants() async { return apiService.getAllAvailablePlants(); } getBackgroundColorOfPlant(Plant plant, DateTime date) { return plantService.getColor(plant, date); } String getTimeDescription(Plant plant, DateTime date) { return plantService.getTimeDescription(plant, date); } Future loadBeet() async { await beetService.loadBeet(apiService, beetRowService, beet); _messages = "Beet geladen"; } List getHorizontalPlantingPositionForRow(BeetRow beetRow) { return beetRowService.getHorizontalPlantingPosition(beetRow); } BeetRow getRow(int index) { return beet.beetRows[index]; } }