import 'package:flutter/widgets.dart';

enum DietRecordSwipeAction { edit, delete }

DietRecordSwipeAction dietRecordSwipeAction(DismissDirection direction) =>
    direction == DismissDirection.startToEnd
    ? DietRecordSwipeAction.edit
    : DietRecordSwipeAction.delete;

List<DateTime> recentDietDates(DateTime now, {int count = 7}) {
  final today = DateTime(now.year, now.month, now.day);
  return List.generate(
    count,
    (index) => today.subtract(Duration(days: count - 1 - index)),
  );
}

bool isSavableFood({
  required String name,
  required String portion,
  required int calories,
}) {
  return name.trim().isNotEmpty && portion.trim().isNotEmpty && calories > 0;
}
