ammaratef45 / hydroponics-garden

A flutter app that can be used to track important dates and service your hydroponically grown plants.
GNU General Public License v3.0
1 stars 1 forks source link

add events to important care events for plants #30

Open github-actions[bot] opened 12 months ago

github-actions[bot] commented 12 months ago

for example: pruning, trimming, health check ... etc

https://api.github.com/ammaratef45/hydroponics-garden/blob/0ac6306e1e14c8b7435f61e4a7462f1f0e9abe59/lib/model/plant_events.dart#L5


import 'package:calendar_view/calendar_view.dart';
import 'package:flutter/material.dart';
import 'package:hydroponic_garden/model/plant.dart';

// TODO: add events to important care events for plants
//  for example: pruning, trimming, health check ... etc
class PlantEvents {
  final Plant _plant;

  PlantEvents(this._plant);

  List<CalendarEventData> harvestEvents() {
    List<CalendarEventData> res = [];
    for (int i = 0;
        i < _plant.harvestDate.getDayDifference(_plant.endHarvestDate);
        i++) {
      DateTime date = _plant.harvestDate.add(Duration(days: i));
      res.add(CalendarEventData(
        title: 'harvest ${_plant.description.name} - Day $i',
        date: date,
        endDate: date,
        startTime: date,
        color: Colors.green,
      ));
    }
    return res;
  }
}
bibekpanda55 commented 11 months ago

I would like to work on this. Could you assign this to me?

ammaratef45 commented 11 months ago

@bibekpanda55 thanks for contributing, assigning to you

bibekpanda55 commented 11 months ago

Could you describe the issue a bit more please?

ammaratef45 commented 11 months ago

besides harvestEvents we can add another method (ex careEvents) a list of CalendarEventData would be returned as follows (this is just an idea, we can tune later):

bibekpanda55 commented 11 months ago

So you just want to me to add an extra event where the logic will be the same as the harvestEvents() method?

ammaratef45 commented 11 months ago

@bibekpanda55 as a start, yes

bibekpanda55 commented 11 months ago

Below is the code that I have added to plant_events.dart as asked.Correct me if I am wrong otherwise I will make a PR.

List<CalendarEventData> careEvents() {
    List<CalendarEventData> res = [];
    for (int i = 0;
        i < _plant.plantedDate.getDayDifference(_plant.sproutDate);
        i++) {
      DateTime date = _plant.plantedDate.add(Duration(days: i));
      res.add(CalendarEventData(
        title: 'care ${_plant.description.name} - Day $i',
        date: date,
        endDate: date,
        startTime: date,
        color: Colors.green,
      ));
    }
    return res;
  }
ammaratef45 commented 11 months ago

hard to read with the current formatting, hint (use `` instead of to show the code in better formatting)

but seems about right, you can submit the PR

bibekpanda55 commented 11 months ago

Sorry forgot to do that. Have added that and now you can check the code.

ammaratef45 commented 11 months ago

looks good, instead of i++ I would use i+=3

bibekpanda55 commented 11 months ago

Got it.Have created a PR as per requirement. You can check the same and merge if you don't find any other issues. Thanks for helping out