Compare commits
1 Commits
43f95cb321
...
v1.0
Author | SHA1 | Date | |
---|---|---|---|
f4220d0851 |
23
README.md
23
README.md
@ -4,22 +4,16 @@ A Reminder based on todo.txt synced via nextcloud
|
||||
|
||||
## Current todos:
|
||||
|
||||
- [x] make repeat-datatype (like: daily, weekly on mo/th/fr, bi-monthly, etc.)
|
||||
- [x] define isomorphism for 'repeat:'-meta-tag
|
||||
- [x] add interface for repeat-datatype in addReminder.dart
|
||||
- [ ] make repeat-datatype (like: daily, weekly on mo/th/fr, bi-monthly, etc.)
|
||||
- [ ] define isomorphism for 'repeat:'-meta-tag
|
||||
- [ ] add interface for repeat-datatype in addReminder.dart
|
||||
- [x] save/load data to/from disk
|
||||
- [x] adding/removing tasks
|
||||
- [x] respect ordering that was used when starting the app when saving.
|
||||
- [ ] respect ordering that was used when starting the app when saving.
|
||||
- [ ] add Nextcloud-login for getting a Token
|
||||
- [ ] use webdav for synchronizing with Nextcloud using that token
|
||||
- [ ] sorting by "next up", "priority"
|
||||
- [ ] respect 'color:'-meta-tag (usual formats like "#aabbcc", html-colors like "red")
|
||||
- [ ] use color in rendering todos
|
||||
- [ ] make application-settings
|
||||
- [ ] store/load settings
|
||||
- [ ] setting for number of days into the future
|
||||
- [ ] theme (light/dark mode, system theme)
|
||||
- [ ] fancy pop-animation & sound for the checkbox
|
||||
|
||||
## Current looks:
|
||||
|
||||
@ -27,11 +21,4 @@ A Reminder based on todo.txt synced via nextcloud
|
||||

|
||||
|
||||
### Adding Tasks
|
||||

|
||||
(still missing repeat-options, currently defaults to daily.)
|
||||
|
||||
### Details/Removing tasks
|
||||

|
||||
|
||||
### Complex repeat patterns
|
||||

|
||||

|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB |
Binary file not shown.
Before Width: | Height: | Size: 44 KiB |
@ -1,10 +1,6 @@
|
||||
import 'package:date_field/date_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:nextcloud_reminder/repeating_task.dart';
|
||||
import 'package:nextcloud_reminder/types/repeat.dart';
|
||||
import 'package:nextcloud_reminder/types/tasks.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class AddTaskWidget extends StatefulWidget {
|
||||
const AddTaskWidget({super.key, this.restorationId, required this.onSave});
|
||||
@ -18,14 +14,11 @@ class AddTaskWidget extends StatefulWidget {
|
||||
|
||||
//TODO: make _repeat changeable.
|
||||
|
||||
class _AddTaskWidgetState extends State<AddTaskWidget> {
|
||||
class _AddTaskWidgetState extends State<AddTaskWidget> with RestorationMixin {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _titleController = TextEditingController();
|
||||
static _emptyRepetition() {
|
||||
return Tuple2(TextEditingController(text: "1"), ValueNotifier(DateInterval.daily));
|
||||
}
|
||||
final List<Tuple2<TextEditingController,ValueNotifier<DateInterval>>> _repeatEveryController = [_emptyRepetition()];
|
||||
DateTime _beginDate = DateTime.now();
|
||||
final int _repeat = 1;
|
||||
final RestorableDateTime _beginDate = RestorableDateTime(DateTime.now());
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@ -33,43 +26,51 @@ class _AddTaskWidgetState extends State<AddTaskWidget> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
String _prettyInterval(DateInterval d) {
|
||||
switch (d) {
|
||||
default:
|
||||
return d.toString();
|
||||
}
|
||||
@override
|
||||
String? get restorationId => widget.restorationId;
|
||||
|
||||
late final RestorableRouteFuture<DateTime?> _restorableDatePickerRouteFuture =
|
||||
RestorableRouteFuture<DateTime?>(
|
||||
onComplete: _selectDate,
|
||||
onPresent: (NavigatorState navigator, Object? arguments) {
|
||||
return navigator.restorablePush(
|
||||
_datePickerRoute,
|
||||
arguments: _beginDate.value.millisecondsSinceEpoch,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
static Route<DateTime> _datePickerRoute(
|
||||
BuildContext context,
|
||||
Object? arguments,
|
||||
) {
|
||||
return DialogRoute<DateTime>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return DatePickerDialog(
|
||||
restorationId: 'date_picker_dialog',
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
initialDate: DateTime.fromMillisecondsSinceEpoch(arguments! as int),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2100),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _repeatBuilder(BuildContext context, Tuple2<TextEditingController,ValueNotifier<DateInterval>> data) {
|
||||
return Row(
|
||||
children: [
|
||||
Text("Repeat every " ),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: TextFormField(
|
||||
controller: data.item1,
|
||||
decoration: const InputDecoration(
|
||||
hintText: "1",
|
||||
),
|
||||
keyboardType: const TextInputType.numberWithOptions(signed: false, decimal: false),
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: DropdownButton<DateInterval>(
|
||||
items: DateInterval.values.map((v) => DropdownMenuItem(value: v, child: Text(_prettyInterval(v)))).toList(),
|
||||
onChanged: (v) => setState(() {
|
||||
data.item2.value = v ?? data.item2.value;
|
||||
}),
|
||||
value: data.item2.value,
|
||||
),
|
||||
),
|
||||
IconButton(onPressed: () => setState(() {
|
||||
_repeatEveryController.remove(data);
|
||||
}), icon: Icon(Icons.remove, color: Theme.of(context).errorColor,)),
|
||||
],
|
||||
);
|
||||
@override
|
||||
void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
|
||||
registerForRestoration(_beginDate, 'selected_date');
|
||||
registerForRestoration(
|
||||
_restorableDatePickerRouteFuture, 'date_picker_route_future');
|
||||
}
|
||||
|
||||
void _selectDate(DateTime? newSelectedDate) {
|
||||
if (newSelectedDate != null) {
|
||||
setState(() {
|
||||
_beginDate.value = newSelectedDate;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -96,21 +97,21 @@ class _AddTaskWidgetState extends State<AddTaskWidget> {
|
||||
labelText: "Taskname"
|
||||
),
|
||||
),
|
||||
|
||||
DateTimeField(
|
||||
onDateSelected: (v) => setState(() { _beginDate = v; }),
|
||||
selectedDate: _beginDate,
|
||||
decoration: const InputDecoration(
|
||||
suffixIcon: Icon(Icons.event_note),
|
||||
labelText: "Begin"
|
||||
),
|
||||
mode: DateTimeFieldPickerMode.date,
|
||||
Container(
|
||||
decoration: const BoxDecoration(),
|
||||
child: Row(
|
||||
children: [
|
||||
Text("Begin: ", style: Theme.of(context).textTheme.labelLarge),
|
||||
Expanded(
|
||||
child: Text("${_beginDate.value.year}-${_beginDate.value.month.toString().padLeft(2,'0')}-${_beginDate.value.day.toString().padLeft(2,'0')}")
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => _restorableDatePickerRouteFuture.present(),
|
||||
icon: Icon(Icons.date_range,
|
||||
color: Theme.of(context).focusColor))
|
||||
]
|
||||
)
|
||||
),
|
||||
] + _repeatEveryController.map((c) => _repeatBuilder(context,c)).toList()
|
||||
+ [
|
||||
ElevatedButton(onPressed: () => setState(() {
|
||||
_repeatEveryController.add(_emptyRepetition());
|
||||
}), child: const Text("add repetition")),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: ElevatedButton(
|
||||
@ -122,16 +123,8 @@ class _AddTaskWidgetState extends State<AddTaskWidget> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Task added.')),
|
||||
);
|
||||
var repeats = _repeatEveryController.map((e) => RepeatInterval(interval: e.item2.value, every: int.parse(e.item1.text))).toList();
|
||||
var meta = repeats.map((e) => e.toString()).join("/");
|
||||
widget.onSave(RepeatingTask(
|
||||
task: TaskExtra(
|
||||
title: _titleController.text,
|
||||
begin: _beginDate,
|
||||
meta: {"repeat": meta},
|
||||
repeat: repeats,
|
||||
)
|
||||
));
|
||||
task: Task(title: _titleController.text, begin: _beginDate.value), repeat: _repeat,));
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
|
@ -1,14 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_window_close/flutter_window_close.dart';
|
||||
import 'package:nextcloud_reminder/addReminder.dart';
|
||||
import 'package:nextcloud_reminder/parser/todotxt.dart';
|
||||
import 'package:nextcloud_reminder/repeating_task.dart';
|
||||
import 'package:nextcloud_reminder/table.dart';
|
||||
import 'package:nextcloud_reminder/types/tasks.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
class HomeWidget extends StatefulWidget {
|
||||
const HomeWidget({super.key, required this.title});
|
||||
@ -30,10 +28,11 @@ class HomeWidget extends StatefulWidget {
|
||||
|
||||
class _HomeWidgetState extends State<HomeWidget> with WidgetsBindingObserver {
|
||||
|
||||
late final ScrollTable _checkboxes;
|
||||
final ScrollTable _checkboxes = ScrollTable(title: "TODOs");
|
||||
int _counter = 1;
|
||||
late final Directory appDocDirectory;
|
||||
late final File todotxt = File('${appDocDirectory.path}/todo.txt');
|
||||
final List<TaskExtra> tasks = [];
|
||||
final List<Task> tasks = [];
|
||||
|
||||
void _loadTodos() {
|
||||
for (var element in tasks) {
|
||||
@ -46,6 +45,7 @@ class _HomeWidgetState extends State<HomeWidget> with WidgetsBindingObserver {
|
||||
appDocDirectory = (await getApplicationDocumentsDirectory());
|
||||
if (await todotxt.exists()) {
|
||||
var data = await todotxt.readAsLines();
|
||||
debugPrint(data.toString());
|
||||
tasks.addAll(TodoParser.parse(data));
|
||||
_loadTodos();
|
||||
} else {
|
||||
@ -57,12 +57,7 @@ class _HomeWidgetState extends State<HomeWidget> with WidgetsBindingObserver {
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_checkboxes = ScrollTable(title: "TODOs", deleteCallback: _removeTask);
|
||||
initLazy();
|
||||
FlutterWindowClose.setWindowShouldCloseHandler(() async {
|
||||
saveData();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@ -81,26 +76,29 @@ class _HomeWidgetState extends State<HomeWidget> with WidgetsBindingObserver {
|
||||
}
|
||||
void saveData() async {
|
||||
//TODO: better update lines instead of blindly overwriting.
|
||||
List<TaskExtra> tmp = tasks;
|
||||
tmp.sort((a, b) => a.lineNumber != null && b.lineNumber != null ? a.lineNumber! - b.lineNumber! : -1,);
|
||||
String data = tmp.map((t) => t.formatAsTask()).join("\n");
|
||||
String data = tasks.map((t) => t.toString()).join("\n");
|
||||
debugPrint("Saving:\n$data");
|
||||
await todotxt.writeAsString(data);
|
||||
}
|
||||
|
||||
void _addDummyTask() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// stuff without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
_checkboxes.addTask(RepeatingTask(task: Task(title: "Dummy Task #$_counter", begin: DateTime.now()), repeat: _counter++));
|
||||
});
|
||||
}
|
||||
void _addTask(RepeatingTask? t) {
|
||||
if (t != null) {
|
||||
setState(() {
|
||||
_checkboxes.addTask(t!);
|
||||
tasks.add(TaskExtra.fromTask(t.task));
|
||||
tasks.add(t.task);
|
||||
});
|
||||
}
|
||||
}
|
||||
void _removeTask(RepeatingTask t) {
|
||||
setState(() {
|
||||
tasks.remove(t.task);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -9,18 +9,16 @@ abstract class TodoParser {
|
||||
|
||||
static final _todoParser = _definition.build();
|
||||
|
||||
static List<TaskExtra> parse(List<String> input) {
|
||||
final List<TaskExtra> ret = [];
|
||||
var line=1;
|
||||
static List<Task> parse(List<String> input) {
|
||||
final List<Task> ret = [];
|
||||
for (var element in input) {
|
||||
var parsed = _todoParser.parse(element);
|
||||
if (parsed.isSuccess) {
|
||||
ret.add(TaskExtra.fromTask(parsed.value, lineNumber: line));
|
||||
ret.add(parsed.value);
|
||||
} else {
|
||||
debugPrint(parsed.message);
|
||||
debugPrint(element);
|
||||
}
|
||||
line++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ 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});
|
||||
const RepeatingTask({super.key, required this.task, this.repeat=1});
|
||||
|
||||
final TaskExtra task;
|
||||
final Task task;
|
||||
final int repeat;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _RepeatingTaskState();
|
||||
@ -17,28 +18,14 @@ class _RepeatingTaskState extends State<RepeatingTask> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_occurrences = List<TaskItem>.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);
|
||||
});
|
||||
_occurrences = List<TaskItem>.generate(10, (index) => TaskItem(done: index % widget.repeat == 0 ? false : null));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(border: Border(bottom: BorderSide(),)),
|
||||
margin: const EdgeInsets.all(0.0),
|
||||
child: Row(
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _occurrences,
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nextcloud_reminder/repeating_task.dart';
|
||||
import 'package:nextcloud_reminder/types/tasks.dart';
|
||||
|
||||
class ScrollTable extends StatefulWidget {
|
||||
ScrollTable({super.key, required this.title, required this.deleteCallback});
|
||||
ScrollTable({super.key, required this.title});
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
@ -12,7 +11,6 @@ class ScrollTable extends StatefulWidget {
|
||||
|
||||
final String title;
|
||||
final _ScrollTableState _internalState = _ScrollTableState();
|
||||
final ValueChanged<RepeatingTask> deleteCallback;
|
||||
|
||||
@override
|
||||
State<ScrollTable> createState() => _internalState;
|
||||
@ -33,64 +31,19 @@ class _ScrollTableState extends State<ScrollTable> {
|
||||
});
|
||||
}
|
||||
|
||||
removeTask(RepeatingTask task) {
|
||||
setState(() {
|
||||
_content.remove(task);
|
||||
});
|
||||
widget.deleteCallback(task);
|
||||
}
|
||||
|
||||
Future<void> _showDetailsAndRemoveTask(BuildContext context, RepeatingTask t) {
|
||||
return showDialog(context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (BuildContext context)
|
||||
{
|
||||
return AlertDialog(
|
||||
title: const Text("Task details"),
|
||||
content: SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: [ Text(t.task.title),
|
||||
Text("Projects: ${t.task.projects.isEmpty ? "none" : t.task.projects.join(", ")}"),
|
||||
Text("Contexts: ${t.task.contexts.isEmpty ? "none" : t.task.contexts.join(", ")}"),
|
||||
Padding(padding: EdgeInsets.only(top: 16),
|
||||
child: Text(t.task.meta.isEmpty ? "" : "Meta:", style: Theme.of(context).textTheme.bodyLarge,)
|
||||
),
|
||||
] + List.of(t.task.meta.entries.map((e) => Text("${e.key}: ${e.value}"))),
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(onPressed: () {
|
||||
removeTask(t);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
style: TextButton.styleFrom(foregroundColor: Theme
|
||||
.of(context)
|
||||
.errorColor),
|
||||
child: const Text("remove"),),
|
||||
TextButton(onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text("close")),
|
||||
]
|
||||
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
List<Widget> _buildTitles(BuildContext context) {
|
||||
List<Widget> _buildTitles() {
|
||||
return List<Widget>.from(_content.map((RepeatingTask t) =>
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
width: 150.0,
|
||||
alignment: Alignment.center,
|
||||
width: 120.0,
|
||||
height: 60.0,
|
||||
margin: const EdgeInsets.only(left: 4, top: 1),
|
||||
decoration: const BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(),)),
|
||||
child: TextButton(
|
||||
onPressed: () => _showDetailsAndRemoveTask(context,t),
|
||||
child: Text(t.task.title,
|
||||
style: Theme.of(context).textTheme.labelMedium),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
color: Colors.white,
|
||||
margin: const EdgeInsets.all(4.0),
|
||||
child: Text(t.task.title, style: Theme
|
||||
.of(context)
|
||||
.textTheme
|
||||
.labelMedium),
|
||||
)));
|
||||
}
|
||||
|
||||
@override
|
||||
@ -101,15 +54,14 @@ class _ScrollTableState extends State<ScrollTable> {
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
//TODO: Text in container wie bei _buildTitles oben und width/height/margin/etc. festnageln.
|
||||
children: List<Widget>.from([Text("Todo", style: Theme.of(context).dataTableTheme.headingTextStyle,)]) + _buildTitles(context),
|
||||
children: _buildTitles(),
|
||||
),
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List<Widget>.from([Text("header ... date, date, date .. fancy turned 60 degrees", style: Theme.of(context).dataTableTheme.headingTextStyle)]) + List<Widget>.from(_content),
|
||||
children: _content,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -27,7 +27,7 @@ class _TaskItemState extends State<TaskItem>{
|
||||
width: 60.0,
|
||||
height: 60.0,
|
||||
color: Colors.white,
|
||||
margin: const EdgeInsets.all(0.0),
|
||||
margin: const EdgeInsets.all(4.0),
|
||||
child: _done == null ? null : Checkbox(value: _done, onChanged: (newState) => setState(() {
|
||||
_done = newState!;
|
||||
})),
|
||||
|
@ -1,97 +0,0 @@
|
||||
class RepeatInterval {
|
||||
int every;
|
||||
DateInterval interval;
|
||||
|
||||
RepeatInterval({required this.interval, this.every=1});
|
||||
|
||||
static RepeatInterval? fromString(String input) {
|
||||
RegExpMatch? m = RegExp(r'(\d*)(\D+)').firstMatch(input);
|
||||
if (m != null) {
|
||||
DateInterval? di = _stringToInterval(m!.group(2)!);
|
||||
if (di != null) {
|
||||
return RepeatInterval(interval: di, every: m?.group(1) == "" ? 1 : int.parse(m!.group(1)!));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Does the RepeatInterval referencing from a hit b?
|
||||
bool repeatHit(DateTime a, DateTime b) {
|
||||
var daydiff = a.difference(b).inDays;
|
||||
var weeks = (daydiff / 7).floor();
|
||||
switch (interval) {
|
||||
case DateInterval.daily: return daydiff % every == 0;
|
||||
case DateInterval.weekly: return daydiff % (every*7) == 0;
|
||||
case DateInterval.monthly: return a.day == b.day;
|
||||
case DateInterval.monday: return weeks % every == 0 && b.weekday == DateTime.monday;
|
||||
case DateInterval.tuesday: return weeks % every == 0 && b.weekday == DateTime.tuesday;
|
||||
case DateInterval.wednesday: return weeks % every == 0 && b.weekday == DateTime.wednesday;
|
||||
case DateInterval.thursday: return weeks % every == 0 && b.weekday == DateTime.thursday;
|
||||
case DateInterval.friday: return weeks % every == 0 && b.weekday == DateTime.friday;
|
||||
case DateInterval.saturday: return weeks % every == 0 && b.weekday == DateTime.saturday;
|
||||
case DateInterval.sunday: return weeks % every == 0 && b.weekday == DateTime.sunday;
|
||||
case DateInterval.dayOfMonth: return b.day == every;
|
||||
case DateInterval.dayOfYear: return DateTime.now().difference(b).inDays == every;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
toString() {
|
||||
return "$every${_intervalToString(interval)}";
|
||||
}
|
||||
|
||||
static DateInterval? _stringToInterval(String input) {
|
||||
switch (input) {
|
||||
case "daily":
|
||||
case "day": return DateInterval.daily;
|
||||
case "weekly":
|
||||
case "week": return DateInterval.weekly;
|
||||
case "monthly":
|
||||
case "month": return DateInterval.monthly;
|
||||
case "mon": return DateInterval.monday;
|
||||
case "tue": return DateInterval.tuesday;
|
||||
case "wed": return DateInterval.wednesday;
|
||||
case "thu": return DateInterval.thursday;
|
||||
case "fri": return DateInterval.friday;
|
||||
case "sat": return DateInterval.saturday;
|
||||
case "sun": return DateInterval.sunday;
|
||||
case "ofMonth": return DateInterval.dayOfMonth;
|
||||
case "ofYear": return DateInterval.dayOfYear;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String _intervalToString(DateInterval di) {
|
||||
switch (di) {
|
||||
case DateInterval.daily: return "day";
|
||||
case DateInterval.weekly: return "week";
|
||||
case DateInterval.monthly: return "month";
|
||||
case DateInterval.monday: return "mon";
|
||||
case DateInterval.tuesday: return "tue";
|
||||
case DateInterval.wednesday: return "wed";
|
||||
case DateInterval.thursday: return "thu";
|
||||
case DateInterval.friday: return "fri";
|
||||
case DateInterval.saturday: return "sat";
|
||||
case DateInterval.sunday: return "sun";
|
||||
case DateInterval.dayOfMonth: return "ofMonth";
|
||||
case DateInterval.dayOfYear: return "ofYear";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum DateInterval {
|
||||
daily,
|
||||
weekly,
|
||||
monthly,
|
||||
monday,
|
||||
tuesday,
|
||||
wednesday,
|
||||
thursday,
|
||||
friday,
|
||||
saturday,
|
||||
sunday,
|
||||
dayOfMonth,
|
||||
dayOfYear,
|
||||
}
|
||||
|
@ -1,45 +1,3 @@
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:nextcloud_reminder/types/repeat.dart';
|
||||
|
||||
class TaskExtra extends Task {
|
||||
TaskExtra({required super.title,
|
||||
super.done = false,
|
||||
super.contexts = const [],
|
||||
super.projects = const [],
|
||||
super.meta = const {},
|
||||
super.priority,
|
||||
super.begin,
|
||||
super.end,
|
||||
this.lineNumber,
|
||||
this.repeat = const [],
|
||||
});
|
||||
|
||||
TaskExtra.fromTask(Task t, {this.lineNumber})
|
||||
: repeat = t.meta["repeat"]?.split("/").map(RepeatInterval.fromString).whereNotNull().toList() ?? []
|
||||
, super(title: t.title,
|
||||
done: t.done,
|
||||
contexts: t.contexts,
|
||||
projects: t.projects,
|
||||
meta: t.meta,
|
||||
priority: t.priority,
|
||||
begin: t.begin,
|
||||
end: t.end,
|
||||
);
|
||||
|
||||
final int? lineNumber;
|
||||
final List<RepeatInterval> repeat;
|
||||
|
||||
formatAsTask() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "$lineNumber: ${super.toString()}";
|
||||
}
|
||||
}
|
||||
|
||||
class Task {
|
||||
final bool done;
|
||||
final DateTime? begin;
|
||||
@ -61,16 +19,12 @@ class Task {
|
||||
this.end,
|
||||
});
|
||||
|
||||
static String formatDate(DateTime dt) {
|
||||
return "${dt!.year}-${dt!.month.toString().padLeft(2,'0')}-${dt!.day.toString().padLeft(2,'0')}";
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (done ? "x " : "")
|
||||
+ (priority == null ? "" : "(${priority!}) ")
|
||||
+ (begin == null ? "" : "${Task.formatDate(begin!)} ")
|
||||
+ (end == null ? "" : "${Task.formatDate(end!)} ")
|
||||
+ (begin == null ? "" : "${begin!.year}-${begin!.month}-${begin!.day} ")
|
||||
+ (end == null ? "" : "${end!.year}-${end!.month}-${end!.day} ")
|
||||
+ ("$title ")
|
||||
+ meta.entries.map((entry) => "${entry.key}:${entry.value}").join(" ")
|
||||
;
|
||||
|
@ -6,10 +6,6 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_window_close/flutter_window_close_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) flutter_window_close_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWindowClosePlugin");
|
||||
flutter_window_close_plugin_register_with_registrar(flutter_window_close_registrar);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_window_close
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
@ -5,10 +5,8 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import flutter_window_close
|
||||
import path_provider_macos
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterWindowClosePlugin.register(with: registry.registrar(forPlugin: "FlutterWindowClosePlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
}
|
||||
|
35
pubspec.lock
35
pubspec.lock
@ -30,7 +30,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
@ -43,13 +43,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
date_field:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: date_field
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -88,32 +81,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_window_close:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_window_close
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.17.0"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.4"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -3,7 +3,7 @@ description: A Reminder based on todo.txt synced via nextcloud
|
||||
|
||||
# The following line prevents the package from being accidentally published to
|
||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
||||
publish_to: 'https://gitea.dresselhaus.cloud/api/packages/drezil/pub' # Remove this line if you wish to publish to pub.dev
|
||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
|
||||
# The following defines the version and build number for your application.
|
||||
# A version number is three numbers separated by dots, like 1.2.43
|
||||
@ -39,9 +39,6 @@ dependencies:
|
||||
path_provider: ^2.0.11
|
||||
petitparser: ^5.1.0
|
||||
tuple: ^2.0.1
|
||||
flutter_window_close: ^0.2.2
|
||||
collection: ^1.16.0
|
||||
date_field: ^3.0.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -6,9 +6,6 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_window_close/flutter_window_close_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FlutterWindowClosePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterWindowClosePlugin"));
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_window_close
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
Reference in New Issue
Block a user