import 'package:flutter/material.dart'; import 'package:nextcloud_reminder/task_item.dart'; import 'package:nextcloud_reminder/types/tasks.dart'; class RepeatingTask extends StatefulWidget { const RepeatingTask({super.key, required this.task}); final TaskExtra task; @override State createState() => _RepeatingTaskState(); } class _RepeatingTaskState extends State { late List _occurrences; @override void initState() { super.initState(); _occurrences = List.generate(10, (index) { var start = widget.task.begin ?? DateTime.now(); var comparator = DateTime.now().add(Duration(days: index)); for (var r in widget.task.repeat) { if (r.repeatHit(start, comparator)) return TaskItem(done: widget.task.done,); } if (widget.task.repeat.isEmpty && start.day == comparator.day && start.month == comparator.month && start.year == comparator.year) { return TaskItem(done: widget.task.done,); } return const TaskItem(done: null); }); } @override Widget build(BuildContext context) { return Container( decoration: const BoxDecoration(border: Border(bottom: BorderSide(),)), margin: const EdgeInsets.all(0.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: _occurrences, ) ); } }