forked from vikunja/app
Compare commits
76 Commits
master
...
feature/ed
Author | SHA1 | Date |
---|---|---|
kolaente | 0ceb870964 | |
kolaente | 780ee537f6 | |
kolaente | fbd8efa2b2 | |
kolaente | 67e055d9cb | |
kolaente | 26a55bb247 | |
kolaente | 2be74c5883 | |
konrad | 53d932dcff | |
kolaente | a977524755 | |
kolaente | eab23b6e72 | |
kolaente | 974c3c1774 | |
kolaente | 629db81c22 | |
kolaente | 3387fc8500 | |
kolaente | f75b047a54 | |
kolaente | e5bc2d07b4 | |
kolaente | 30a0797931 | |
konrad | 9274715972 | |
konrad | d184b0e47c | |
konrad | e9c70eade7 | |
konrad | aeb7a445a4 | |
konrad | e97cd9a2f9 | |
konrad | d9a7378814 | |
konrad | 8c4d1c8b89 | |
konrad | b666c85b0e | |
kolaente | 6515afdd64 | |
kolaente | 70bec87d50 | |
kolaente | dc83fc74c4 | |
kolaente | dfdd6bbd36 | |
kolaente | 068060ace5 | |
kolaente | 3f634065ca | |
kolaente | 4d6390331b | |
kolaente | 24ffef1aef | |
kolaente | f1f3be6d36 | |
kolaente | 3a4ca08201 | |
kolaente | 009c303460 | |
kolaente | a400d7cf88 | |
kolaente | 7b142d5e65 | |
konrad | 19917aa171 | |
konrad | 61b3deb5d1 | |
konrad | f6d500f45e | |
konrad | d4b3a01a60 | |
kolaente | 714aed4603 | |
kolaente | 45eb087228 | |
kolaente | 8a091c9828 | |
kolaente | f30958f33c | |
kolaente | 9f289cf11e | |
kolaente | 45bb3c2c8c | |
kolaente | 822b1d5d8e | |
konrad | 456b8ca15f | |
konrad | e5da5b921a | |
konrad | 5b0c94a5c7 | |
konrad | 44e7e8fd71 | |
konrad | c1677396c1 | |
konrad | 98b518df9d | |
konrad | b6b113c106 | |
konrad | 078c756fb6 | |
konrad | 678250bbcf | |
konrad | f4798abbe1 | |
konrad | d572c2a5e3 | |
konrad | 2437270031 | |
konrad | 94d5691e1e | |
konrad | ee9728c756 | |
konrad | 9bc5f30345 | |
konrad | 76149c315e | |
konrad | c3d699d7f1 | |
konrad | ab67a5fb4c | |
konrad | 29a9545cd4 | |
konrad | 0b06fc3beb | |
konrad | 521ac1bae0 | |
konrad | 7cc767b337 | |
konrad | c038ebe521 | |
konrad | 55686ae25e | |
konrad | f5c2c486d7 | |
konrad | e732927e75 | |
konrad | e6f789af0f | |
konrad | fcfca5dfff | |
konrad | 9606fe4ad6 |
|
@ -28,7 +28,7 @@ steps:
|
||||||
- make build-debug
|
- make build-debug
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: vikunja/flutter-build
|
image: cirrusci/flutter:stable
|
||||||
pull: true
|
pull: true
|
||||||
commands:
|
commands:
|
||||||
- flutter packages get
|
- flutter packages get
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import 'package:vikunja_app/api/client.dart';
|
||||||
|
import 'package:vikunja_app/api/service.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/labelTask.dart';
|
||||||
|
import 'package:vikunja_app/service/services.dart';
|
||||||
|
|
||||||
|
class LabelTaskAPIService extends APIService implements LabelTaskService {
|
||||||
|
LabelTaskAPIService(Client client) : super(client);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Label> create(LabelTask lt) async {
|
||||||
|
return client
|
||||||
|
.put('/tasks/${lt.task.id}/labels', body: lt.toJSON())
|
||||||
|
.then((result) => Label.fromJson(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Label> delete(LabelTask lt) async {
|
||||||
|
return client.delete('/tasks/${lt.task.id}/labels/${lt.label.id}');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Label>> getAll(LabelTask lt, {String query}) async {
|
||||||
|
String params =
|
||||||
|
query == '' ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||||
|
return client.get('/tasks/${lt.task.id}/labels$params').then(
|
||||||
|
(label) => convertList(label, (result) => Label.fromJson(result)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
import 'package:vikunja_app/api/client.dart';
|
||||||
|
import 'package:vikunja_app/api/service.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/labelTaskBulk.dart';
|
||||||
|
import 'package:vikunja_app/models/task.dart';
|
||||||
|
import 'package:vikunja_app/service/services.dart';
|
||||||
|
|
||||||
|
class LabelTaskBulkAPIService extends APIService
|
||||||
|
implements LabelTaskBulkService {
|
||||||
|
LabelTaskBulkAPIService(Client client) : super(client);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Label>> update(Task task, List<Label> labels) {
|
||||||
|
return client
|
||||||
|
.post('/tasks/${task.id}/labels/bulk',
|
||||||
|
body: LabelTaskBulk(labels: labels).toJSON())
|
||||||
|
.then((map) =>
|
||||||
|
convertList(map['labels'], (result) => Label.fromJson(result)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
import 'package:vikunja_app/api/client.dart';
|
||||||
|
import 'package:vikunja_app/api/service.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/service/services.dart';
|
||||||
|
|
||||||
|
class LabelAPIService extends APIService implements LabelService {
|
||||||
|
LabelAPIService(Client client) : super(client);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Label> create(Label label) {
|
||||||
|
return client
|
||||||
|
.put('/labels', body: label.toJSON())
|
||||||
|
.then((result) => Label.fromJson(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Label> delete(Label label) {
|
||||||
|
return client.delete('/labels/${label.id}');
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Label> get(int labelID) {
|
||||||
|
return client.get('/labels/$labelID').then((map) => Label.fromJson(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<Label>> getAll({String query}) {
|
||||||
|
String params =
|
||||||
|
query == '' ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||||
|
return client.get('/labels$params').then(
|
||||||
|
(label) => convertList(label, (result) => Label.fromJson(result)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Label> update(Label label) {
|
||||||
|
return client
|
||||||
|
.post('/labels/${label.id}', body: label)
|
||||||
|
.then((map) => Label.fromJson(map));
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,26 +7,28 @@ import 'package:vikunja_app/models/task.dart';
|
||||||
class TaskTile extends StatefulWidget {
|
class TaskTile extends StatefulWidget {
|
||||||
final Task task;
|
final Task task;
|
||||||
final VoidCallback onEdit;
|
final VoidCallback onEdit;
|
||||||
|
final ValueSetter<bool> onMarkedAsDone;
|
||||||
final bool loading;
|
final bool loading;
|
||||||
|
|
||||||
const TaskTile(
|
const TaskTile(
|
||||||
{Key key, @required this.task, this.onEdit, this.loading = false})
|
{Key key,
|
||||||
|
@required this.task,
|
||||||
|
this.onEdit,
|
||||||
|
this.loading = false,
|
||||||
|
this.onMarkedAsDone})
|
||||||
: assert(task != null),
|
: assert(task != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TaskTileState createState() {
|
TaskTileState createState() {
|
||||||
return new TaskTileState(this.task, this.loading);
|
return new TaskTileState(this.loading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TaskTileState extends State<TaskTile> {
|
class TaskTileState extends State<TaskTile> {
|
||||||
bool _loading;
|
bool _loading;
|
||||||
Task _currentTask;
|
|
||||||
|
|
||||||
TaskTileState(this._currentTask, this._loading)
|
TaskTileState(this._loading) : assert(_loading != null);
|
||||||
: assert(_currentTask != null),
|
|
||||||
assert(_loading != null);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -41,29 +43,30 @@ class TaskTileState extends State<TaskTile> {
|
||||||
strokeWidth: 2.0,
|
strokeWidth: 2.0,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
title: Text(_currentTask.text),
|
title: Text(widget.task.text),
|
||||||
subtitle:
|
subtitle:
|
||||||
_currentTask.description == null || _currentTask.description.isEmpty
|
widget.task.description == null || widget.task.description.isEmpty
|
||||||
? null
|
? null
|
||||||
: Text(_currentTask.description),
|
: Text(widget.task.description),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: Icon(Icons.settings),
|
icon: Icon(Icons.settings),
|
||||||
onPressed: () {
|
onPressed: () => widget.onEdit,
|
||||||
null; // TODO: implement edit task
|
),
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
title: Text(_currentTask.text),
|
title: Text(widget.task.text),
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
value: _currentTask.done ?? false,
|
value: widget.task.done ?? false,
|
||||||
subtitle:
|
subtitle:
|
||||||
_currentTask.description == null || _currentTask.description.isEmpty
|
widget.task.description == null || widget.task.description.isEmpty
|
||||||
? null
|
? null
|
||||||
: Text(_currentTask.description),
|
: Text(widget.task.description),
|
||||||
secondary:
|
secondary: IconButton(
|
||||||
IconButton(icon: Icon(Icons.settings), onPressed: widget.onEdit),
|
icon: Icon(Icons.settings),
|
||||||
onChanged: _change,
|
onPressed: widget.onEdit,
|
||||||
|
),
|
||||||
|
onChanged: widget.onMarkedAsDone,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +74,9 @@ class TaskTileState extends State<TaskTile> {
|
||||||
setState(() {
|
setState(() {
|
||||||
this._loading = true;
|
this._loading = true;
|
||||||
});
|
});
|
||||||
Task newTask = await _updateTask(_currentTask, value);
|
Task newTask = await _updateTask(widget.task, value);
|
||||||
setState(() {
|
setState(() {
|
||||||
this._currentTask = newTask;
|
//this.widget.task = newTask;
|
||||||
this._loading = false;
|
this._loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -83,9 +86,6 @@ class TaskTileState extends State<TaskTile> {
|
||||||
return VikunjaGlobal.of(context).taskService.update(Task(
|
return VikunjaGlobal.of(context).taskService.update(Task(
|
||||||
id: task.id,
|
id: task.id,
|
||||||
done: checked,
|
done: checked,
|
||||||
text: task.text,
|
|
||||||
description: task.description,
|
|
||||||
owner: null,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
import 'package:datetime_picker_formfield/datetime_picker_formfield.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:vikunja_app/theme/constants.dart';
|
||||||
|
|
||||||
|
class VikunjaDateTimePicker extends StatelessWidget {
|
||||||
|
final String label;
|
||||||
|
final Function onSaved;
|
||||||
|
final Function onChanged;
|
||||||
|
final DateTime initialValue;
|
||||||
|
final EdgeInsetsGeometry padding;
|
||||||
|
final Icon icon;
|
||||||
|
final InputBorder border;
|
||||||
|
|
||||||
|
const VikunjaDateTimePicker({
|
||||||
|
Key key,
|
||||||
|
@required this.label,
|
||||||
|
this.onSaved,
|
||||||
|
this.onChanged,
|
||||||
|
this.initialValue,
|
||||||
|
this.padding = const EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
this.icon = const Icon(Icons.date_range),
|
||||||
|
this.border = InputBorder.none,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DateTimePickerFormField(
|
||||||
|
dateOnly: false,
|
||||||
|
editable:
|
||||||
|
false, // Otherwise editing the date is not possible, this setting affects the underlying text field.
|
||||||
|
initialValue: initialValue == DateTime.fromMillisecondsSinceEpoch(0)
|
||||||
|
? null
|
||||||
|
: initialValue,
|
||||||
|
format: vDateFormatLong,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: label,
|
||||||
|
border: border,
|
||||||
|
icon: icon,
|
||||||
|
),
|
||||||
|
onSaved: onSaved,
|
||||||
|
onChanged: onChanged,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/theme/constants.dart';
|
||||||
|
|
||||||
|
class LabelComponent extends StatefulWidget {
|
||||||
|
final Label label;
|
||||||
|
final VoidCallback onDelete;
|
||||||
|
|
||||||
|
const LabelComponent({Key key, @required this.label, this.onDelete})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return new LabelComponentState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LabelComponentState extends State<LabelComponent> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Color backgroundColor = widget.label.color ?? vLabelDefaultColor;
|
||||||
|
Color textColor =
|
||||||
|
backgroundColor.computeLuminance() > 0.5 ? vLabelDark : vLabelLight;
|
||||||
|
|
||||||
|
return Chip(
|
||||||
|
label: Text(
|
||||||
|
widget.label.title,
|
||||||
|
style: TextStyle(
|
||||||
|
color: textColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(3)),
|
||||||
|
),
|
||||||
|
onDeleted: widget.onDelete,
|
||||||
|
deleteIconColor: textColor,
|
||||||
|
deleteIcon: Container(
|
||||||
|
padding: EdgeInsets.all(3),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color.fromARGB(50, 0, 0, 0),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: textColor,
|
||||||
|
size: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:vikunja_app/api/client.dart';
|
import 'package:vikunja_app/api/client.dart';
|
||||||
|
import 'package:vikunja_app/api/label_task.dart';
|
||||||
|
import 'package:vikunja_app/api/label_task_bulk.dart';
|
||||||
|
import 'package:vikunja_app/api/labels.dart';
|
||||||
import 'package:vikunja_app/api/list_implementation.dart';
|
import 'package:vikunja_app/api/list_implementation.dart';
|
||||||
import 'package:vikunja_app/api/namespace_implementation.dart';
|
import 'package:vikunja_app/api/namespace_implementation.dart';
|
||||||
import 'package:vikunja_app/api/task_implementation.dart';
|
import 'package:vikunja_app/api/task_implementation.dart';
|
||||||
|
@ -46,6 +49,13 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
|
||||||
|
|
||||||
ListService get listService => new ListAPIService(client);
|
ListService get listService => new ListAPIService(client);
|
||||||
|
|
||||||
|
LabelService get labelService => new LabelAPIService(client);
|
||||||
|
|
||||||
|
LabelTaskService get labelTaskService => new LabelTaskAPIService(client);
|
||||||
|
|
||||||
|
LabelTaskBulkAPIService get labelTaskBulkService =>
|
||||||
|
new LabelTaskBulkAPIService(client);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:vikunja_app/models/user.dart';
|
||||||
|
|
||||||
|
class Label {
|
||||||
|
final int id;
|
||||||
|
final String title, description;
|
||||||
|
final DateTime created, updated;
|
||||||
|
final User createdBy;
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
Label(
|
||||||
|
{this.id,
|
||||||
|
this.title,
|
||||||
|
this.description,
|
||||||
|
this.color,
|
||||||
|
this.created,
|
||||||
|
this.updated,
|
||||||
|
this.createdBy});
|
||||||
|
|
||||||
|
Label.fromJson(Map<String, dynamic> json)
|
||||||
|
: id = json['id'],
|
||||||
|
title = json['title'],
|
||||||
|
description = json['description'],
|
||||||
|
color = json['hex_color'] == ''
|
||||||
|
? null
|
||||||
|
: new Color(int.parse(json['hex_color'], radix: 16) + 0xFF000000),
|
||||||
|
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||||
|
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||||
|
createdBy = User.fromJson(json['created_by']);
|
||||||
|
|
||||||
|
toJSON() => {
|
||||||
|
'id': id,
|
||||||
|
'title': title,
|
||||||
|
'description': description,
|
||||||
|
'hex_color':
|
||||||
|
color?.value?.toRadixString(16)?.padLeft(8, '0')?.substring(2),
|
||||||
|
'created_by': createdBy?.toJSON(),
|
||||||
|
'updated': updated?.millisecondsSinceEpoch,
|
||||||
|
'created': created?.millisecondsSinceEpoch,
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/task.dart';
|
||||||
|
|
||||||
|
class LabelTask {
|
||||||
|
final Label label;
|
||||||
|
final Task task;
|
||||||
|
|
||||||
|
LabelTask({@required this.label, @required this.task});
|
||||||
|
|
||||||
|
LabelTask.fromJson(Map<String, dynamic> json)
|
||||||
|
: label = new Label(id: json['label_id']),
|
||||||
|
task = null;
|
||||||
|
|
||||||
|
toJSON() => {
|
||||||
|
'label_id': label.id,
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
|
||||||
|
class LabelTaskBulk {
|
||||||
|
final List<Label> labels;
|
||||||
|
|
||||||
|
LabelTaskBulk({@required this.labels});
|
||||||
|
|
||||||
|
LabelTaskBulk.fromJson(Map<String, dynamic> json)
|
||||||
|
: labels = json['labels']?.map((label) => Label.fromJson(label));
|
||||||
|
|
||||||
|
toJSON() => {
|
||||||
|
'labels': labels.map((label) => label.toJSON()).toList(),
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,48 +1,82 @@
|
||||||
import 'package:vikunja_app/models/user.dart';
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/user.dart';
|
||||||
|
import 'package:vikunja_app/utils/datetime_to_unix.dart';
|
||||||
|
|
||||||
class Task {
|
class Task {
|
||||||
final int id;
|
final int id, parentTaskId, priority;
|
||||||
final DateTime created, updated, due;
|
final DateTime created, updated, dueDate, startDate, endDate;
|
||||||
final List<DateTime> reminders;
|
final List<DateTime> reminderDates;
|
||||||
final String text, description;
|
final String text, description;
|
||||||
final bool done;
|
final bool done;
|
||||||
final User owner;
|
final User createdBy;
|
||||||
|
final Duration repeatAfter;
|
||||||
|
final List<Task> subtasks;
|
||||||
|
final List<Label> labels;
|
||||||
|
|
||||||
Task(
|
Task(
|
||||||
{@required this.id,
|
{@required this.id,
|
||||||
|
this.text,
|
||||||
|
this.description,
|
||||||
|
this.done,
|
||||||
|
this.reminderDates,
|
||||||
|
this.dueDate,
|
||||||
|
this.startDate,
|
||||||
|
this.endDate,
|
||||||
|
this.parentTaskId,
|
||||||
|
this.priority,
|
||||||
|
this.repeatAfter,
|
||||||
|
this.subtasks,
|
||||||
|
this.labels,
|
||||||
this.created,
|
this.created,
|
||||||
this.updated,
|
this.updated,
|
||||||
this.reminders,
|
this.createdBy});
|
||||||
this.due,
|
|
||||||
@required this.text,
|
|
||||||
this.description,
|
|
||||||
@required this.done,
|
|
||||||
@required this.owner});
|
|
||||||
|
|
||||||
Task.fromJson(Map<String, dynamic> json)
|
Task.fromJson(Map<String, dynamic> json)
|
||||||
: id = json['id'],
|
: id = json['id'],
|
||||||
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
|
||||||
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
|
||||||
reminders = (json['reminderDates'] as List<dynamic>)
|
|
||||||
?.map((milli) => DateTime.fromMillisecondsSinceEpoch(milli))
|
|
||||||
?.toList(),
|
|
||||||
due = DateTime.fromMillisecondsSinceEpoch(json['dueDate']),
|
|
||||||
description = json['description'],
|
|
||||||
text = json['text'],
|
text = json['text'],
|
||||||
|
description = json['description'],
|
||||||
done = json['done'],
|
done = json['done'],
|
||||||
owner = User.fromJson(json['createdBy']);
|
reminderDates = (json['reminderDates'] as List<dynamic>)
|
||||||
|
?.map((ts) => dateTimeFromUnixTimestamp(ts))
|
||||||
|
?.cast<DateTime>()
|
||||||
|
?.toList(),
|
||||||
|
dueDate = dateTimeFromUnixTimestamp(json['dueDate']),
|
||||||
|
startDate = dateTimeFromUnixTimestamp(json['startDate']),
|
||||||
|
endDate = dateTimeFromUnixTimestamp(json['endDate']),
|
||||||
|
parentTaskId = json['parentTaskID'],
|
||||||
|
priority = json['priority'],
|
||||||
|
repeatAfter = Duration(seconds: json['repeatAfter']),
|
||||||
|
labels = (json['labels'] as List<dynamic>)
|
||||||
|
?.map((label) => Label.fromJson(label))
|
||||||
|
?.cast<Label>()
|
||||||
|
?.toList(),
|
||||||
|
subtasks = (json['subtasks'] as List<dynamic>)
|
||||||
|
?.map((subtask) => Task.fromJson(subtask))
|
||||||
|
?.cast<Task>()
|
||||||
|
?.toList(),
|
||||||
|
updated = dateTimeFromUnixTimestamp(json['updated']),
|
||||||
|
created = dateTimeFromUnixTimestamp(json['created']),
|
||||||
|
createdBy = User.fromJson(json['createdBy']);
|
||||||
|
|
||||||
toJSON() => {
|
toJSON() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
'updated': updated?.millisecondsSinceEpoch,
|
|
||||||
'created': created?.millisecondsSinceEpoch,
|
|
||||||
'reminderDates':
|
|
||||||
reminders?.map((date) => date.millisecondsSinceEpoch)?.toList(),
|
|
||||||
'dueDate': due?.millisecondsSinceEpoch,
|
|
||||||
'description': description,
|
|
||||||
'text': text,
|
'text': text,
|
||||||
|
'description': description,
|
||||||
'done': done ?? false,
|
'done': done ?? false,
|
||||||
'createdBy': owner?.toJSON()
|
'reminderDates': reminderDates
|
||||||
|
?.map((date) => datetimeToUnixTimestamp(date))
|
||||||
|
?.toList(),
|
||||||
|
'dueDate': datetimeToUnixTimestamp(dueDate),
|
||||||
|
'startDate': datetimeToUnixTimestamp(startDate),
|
||||||
|
'endDate': datetimeToUnixTimestamp(endDate),
|
||||||
|
'priority': priority,
|
||||||
|
'repeatAfter': repeatAfter?.inSeconds,
|
||||||
|
'labels': labels?.map((label) => label.toJSON())?.toList(),
|
||||||
|
'subtasks': subtasks?.map((subtask) => subtask.toJSON())?.toList(),
|
||||||
|
'createdBy': createdBy?.toJSON(),
|
||||||
|
'updated': datetimeToUnixTimestamp(updated),
|
||||||
|
'created': datetimeToUnixTimestamp(created),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,9 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
||||||
drawer: new Drawer(
|
drawer: new Drawer(
|
||||||
child: new Column(children: <Widget>[
|
child: new Column(children: <Widget>[
|
||||||
new UserAccountsDrawerHeader(
|
new UserAccountsDrawerHeader(
|
||||||
accountEmail:
|
// Removed until we find a way to disable the user email only for some occasions and not everywhere
|
||||||
currentUser?.email == null ? null : Text(currentUser.email),
|
//accountEmail:
|
||||||
|
// currentUser?.email == null ? null : Text(currentUser.email),
|
||||||
accountName:
|
accountName:
|
||||||
currentUser?.username == null ? null : Text(currentUser.username),
|
currentUser?.username == null ? null : Text(currentUser.username),
|
||||||
onDetailsPressed: () {
|
onDetailsPressed: () {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:vikunja_app/global.dart';
|
||||||
import 'package:vikunja_app/models/list.dart';
|
import 'package:vikunja_app/models/list.dart';
|
||||||
import 'package:vikunja_app/models/task.dart';
|
import 'package:vikunja_app/models/task.dart';
|
||||||
import 'package:vikunja_app/pages/list/list_edit.dart';
|
import 'package:vikunja_app/pages/list/list_edit.dart';
|
||||||
|
import 'package:vikunja_app/pages/list/task_edit.dart';
|
||||||
|
|
||||||
class ListPage extends StatefulWidget {
|
class ListPage extends StatefulWidget {
|
||||||
final TaskList taskList;
|
final TaskList taskList;
|
||||||
|
@ -37,53 +38,87 @@ class _ListPageState extends State<ListPage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: new Text(_list.title),
|
|
||||||
actions: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.edit),
|
|
||||||
onPressed: () => Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => ListEditPage(
|
|
||||||
list: _list,
|
|
||||||
))))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: !this._loading
|
|
||||||
? RefreshIndicator(
|
|
||||||
child: _list.tasks.length > 0
|
|
||||||
? ListView(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
children: ListTile.divideTiles(
|
|
||||||
context: context, tiles: _listTasks())
|
|
||||||
.toList(),
|
|
||||||
)
|
|
||||||
: Center(child: Text('This list is empty.')),
|
|
||||||
onRefresh: _loadList,
|
|
||||||
)
|
|
||||||
: Center(child: CircularProgressIndicator()),
|
|
||||||
floatingActionButton: Builder(
|
|
||||||
builder: (context) => FloatingActionButton(
|
|
||||||
onPressed: () => _addItemDialog(context), child: Icon(Icons.add)),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Widget> _listTasks() {
|
|
||||||
var tasks = (_list?.tasks?.map(_buildTile) ?? []).toList();
|
var tasks = (_list?.tasks?.map(_buildTile) ?? []).toList();
|
||||||
tasks.addAll(_loadingTasks.map(_buildLoadingTile));
|
tasks.addAll(_loadingTasks.map(_buildLoadingTile));
|
||||||
return tasks;
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: new Text(_list.title),
|
||||||
|
actions: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.edit),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ListEditPage(
|
||||||
|
list: _list,
|
||||||
|
))))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: !this._loading
|
||||||
|
? RefreshIndicator(
|
||||||
|
onRefresh: _loadList,
|
||||||
|
child: _list.tasks.length > 0
|
||||||
|
? ListView(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
children:
|
||||||
|
ListTile.divideTiles(context: context, tiles: tasks)
|
||||||
|
.toList(),
|
||||||
|
)
|
||||||
|
: Center(child: Text('This list is empty.')),
|
||||||
|
)
|
||||||
|
: Center(child: CircularProgressIndicator()),
|
||||||
|
floatingActionButton: Builder(
|
||||||
|
builder: (context) => FloatingActionButton(
|
||||||
|
onPressed: () => _addItemDialog(context), child: Icon(Icons.add)),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskTile _buildTile(Task task) {
|
TaskTile _buildTile(Task task) {
|
||||||
return TaskTile(task: task, loading: false);
|
return TaskTile(
|
||||||
|
task: task,
|
||||||
|
loading: false,
|
||||||
|
onEdit: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => TaskEditPage(
|
||||||
|
task: task,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onMarkedAsDone: (done) {
|
||||||
|
VikunjaGlobal.of(context)
|
||||||
|
.taskService
|
||||||
|
.update(Task(
|
||||||
|
id: task.id,
|
||||||
|
done: done,
|
||||||
|
))
|
||||||
|
.then((newTask) => setState(() {
|
||||||
|
// FIXME: This is ugly. We should use a redux to not have to do these kind of things.
|
||||||
|
// This is enough for now (it works™) but we should definitly fix it later.
|
||||||
|
_list.tasks.asMap().forEach((i, t) {
|
||||||
|
if (newTask.id == t.id) {
|
||||||
|
_list.tasks[i] = newTask;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskTile _buildLoadingTile(Task task) {
|
TaskTile _buildLoadingTile(Task task) {
|
||||||
return TaskTile(
|
return TaskTile(
|
||||||
task: task,
|
task: task,
|
||||||
loading: true,
|
loading: true,
|
||||||
|
onEdit: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => TaskEditPage(
|
||||||
|
task: task,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +145,8 @@ class _ListPageState extends State<ListPage> {
|
||||||
|
|
||||||
_addItem(String name, BuildContext context) {
|
_addItem(String name, BuildContext context) {
|
||||||
var globalState = VikunjaGlobal.of(context);
|
var globalState = VikunjaGlobal.of(context);
|
||||||
var newTask =
|
var newTask = Task(
|
||||||
Task(id: null, text: name, owner: globalState.currentUser, done: false);
|
id: null, text: name, createdBy: globalState.currentUser, done: false);
|
||||||
setState(() => _loadingTasks.add(newTask));
|
setState(() => _loadingTasks.add(newTask));
|
||||||
globalState.taskService.add(_list.id, newTask).then((task) {
|
globalState.taskService.add(_list.id, newTask).then((task) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -125,4 +160,12 @@ class _ListPageState extends State<ListPage> {
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Task> _updateTask(Task task, bool checked) {
|
||||||
|
// TODO use copyFrom
|
||||||
|
return VikunjaGlobal.of(context).taskService.update(Task(
|
||||||
|
id: task.id,
|
||||||
|
done: checked,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,436 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||||
|
import 'package:vikunja_app/components/datetimePicker.dart';
|
||||||
|
import 'package:vikunja_app/components/label.dart';
|
||||||
|
import 'package:vikunja_app/global.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/task.dart';
|
||||||
|
import 'package:vikunja_app/theme/button.dart';
|
||||||
|
import 'package:vikunja_app/theme/buttonText.dart';
|
||||||
|
import 'package:vikunja_app/utils/repeat_after_parse.dart';
|
||||||
|
|
||||||
|
class TaskEditPage extends StatefulWidget {
|
||||||
|
final Task task;
|
||||||
|
|
||||||
|
TaskEditPage({this.task}) : super(key: Key(task.toString()));
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => _TaskEditPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TaskEditPageState extends State<TaskEditPage> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
int _priority;
|
||||||
|
DateTime _dueDate, _startDate, _endDate;
|
||||||
|
List<DateTime> _reminderDates;
|
||||||
|
String _text, _description, _repeatAfterType;
|
||||||
|
Duration _repeatAfter;
|
||||||
|
List<Label> _labels;
|
||||||
|
List<Label>
|
||||||
|
_suggestedLabels; // we use this to find the label object after a user taps on the suggestion, because the typeahead only uses strings, not full objects.
|
||||||
|
var _reminderInputs = new List<Widget>();
|
||||||
|
final _labelTypeAheadController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext ctx) {
|
||||||
|
// This builds the initial list of reminder inputs only once.
|
||||||
|
if (_reminderDates == null) {
|
||||||
|
_reminderDates = widget.task.reminderDates ?? new List();
|
||||||
|
|
||||||
|
_reminderDates?.asMap()?.forEach((i, time) =>
|
||||||
|
setState(() => _reminderInputs?.add(VikunjaDateTimePicker(
|
||||||
|
initialValue: time,
|
||||||
|
label: 'Reminder',
|
||||||
|
onSaved: (reminder) => _reminderDates[i] = reminder,
|
||||||
|
))));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_labels == null) {
|
||||||
|
_labels = widget.task.labels ?? new List();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('Edit Task'),
|
||||||
|
),
|
||||||
|
body: Builder(
|
||||||
|
builder: (BuildContext context) => SafeArea(
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: ListView(padding: const EdgeInsets.all(16.0), children: <
|
||||||
|
Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
child: TextFormField(
|
||||||
|
maxLines: null,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
initialValue: widget.task.text,
|
||||||
|
onSaved: (text) => _text = text,
|
||||||
|
validator: (text) {
|
||||||
|
if (text.length < 3 || text.length > 250) {
|
||||||
|
return 'The text needs to have between 3 and 250 characters.';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
decoration: new InputDecoration(
|
||||||
|
labelText: 'Text',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
child: TextFormField(
|
||||||
|
maxLines: null,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
initialValue: widget.task.description,
|
||||||
|
onSaved: (description) => _description = description,
|
||||||
|
validator: (description) {
|
||||||
|
if (description.length > 1000) {
|
||||||
|
return 'The description can have a maximum of 1000 characters.';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
decoration: new InputDecoration(
|
||||||
|
labelText: 'Description',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
VikunjaDateTimePicker(
|
||||||
|
icon: Icon(Icons.access_time),
|
||||||
|
label: 'Due Date',
|
||||||
|
initialValue: widget.task.dueDate,
|
||||||
|
onSaved: (duedate) => _dueDate = duedate,
|
||||||
|
),
|
||||||
|
VikunjaDateTimePicker(
|
||||||
|
label: 'Start Date',
|
||||||
|
initialValue: widget.task.startDate,
|
||||||
|
onSaved: (startDate) => _startDate = startDate,
|
||||||
|
),
|
||||||
|
VikunjaDateTimePicker(
|
||||||
|
label: 'End Date',
|
||||||
|
initialValue: widget.task.endDate,
|
||||||
|
onSaved: (endDate) => _endDate = endDate,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: TextFormField(
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
initialValue: getRepeatAfterValueFromDuration(
|
||||||
|
widget.task.repeatAfter)
|
||||||
|
?.toString(),
|
||||||
|
onSaved: (repeatAfter) => _repeatAfter =
|
||||||
|
getDurationFromType(repeatAfter, _repeatAfterType),
|
||||||
|
decoration: new InputDecoration(
|
||||||
|
labelText: 'Repeat after',
|
||||||
|
border: InputBorder.none,
|
||||||
|
icon: Icon(Icons.repeat),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: DropdownButton<String>(
|
||||||
|
isExpanded: true,
|
||||||
|
isDense: true,
|
||||||
|
value: _repeatAfterType ??
|
||||||
|
getRepeatAfterTypeFromDuration(
|
||||||
|
widget.task.repeatAfter),
|
||||||
|
onChanged: (String newValue) {
|
||||||
|
setState(() {
|
||||||
|
_repeatAfterType = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: <String>[
|
||||||
|
'Hours',
|
||||||
|
'Days',
|
||||||
|
'Weeks',
|
||||||
|
'Months',
|
||||||
|
'Years'
|
||||||
|
].map<DropdownMenuItem<String>>((String value) {
|
||||||
|
return DropdownMenuItem<String>(
|
||||||
|
value: value,
|
||||||
|
child: Text(value),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: _reminderInputs,
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(right: 15, left: 2),
|
||||||
|
child: Icon(
|
||||||
|
Icons.alarm_add,
|
||||||
|
color: Colors.grey,
|
||||||
|
)),
|
||||||
|
Text(
|
||||||
|
'Add a reminder',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
// We add a new entry every time we add a new input, to make sure all inputs have a place where they can put their value.
|
||||||
|
_reminderDates.add(null);
|
||||||
|
var currentIndex = _reminderDates.length - 1;
|
||||||
|
|
||||||
|
// FIXME: Why does putting this into a row fails?
|
||||||
|
setState(() => _reminderInputs.add(Row(
|
||||||
|
children: <Widget>[
|
||||||
|
VikunjaDateTimePicker(
|
||||||
|
label: 'Reminder',
|
||||||
|
onSaved: (reminder) =>
|
||||||
|
_reminderDates[currentIndex] = reminder,
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () => print('tapped'),
|
||||||
|
child: Icon(Icons.close),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)));
|
||||||
|
}),
|
||||||
|
InputDecorator(
|
||||||
|
isEmpty: _priority == null,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
icon: const Icon(Icons.flag),
|
||||||
|
labelText: 'Priority',
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
|
child: new DropdownButton<String>(
|
||||||
|
value: _priorityToString(_priority),
|
||||||
|
isExpanded: true,
|
||||||
|
isDense: true,
|
||||||
|
onChanged: (String newValue) {
|
||||||
|
setState(() {
|
||||||
|
_priority = _priorityFromString(newValue);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
items: ['Unset', 'Low', 'Medium', 'High', 'Urgent', 'DO NOW']
|
||||||
|
.map((String value) {
|
||||||
|
return new DropdownMenuItem(
|
||||||
|
value: value,
|
||||||
|
child: new Text(value),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Wrap(
|
||||||
|
spacing: 10,
|
||||||
|
children: _labels.map((Label label) {
|
||||||
|
return LabelComponent(
|
||||||
|
label: label,
|
||||||
|
onDelete: () {
|
||||||
|
_removeLabel(label);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList()),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width - 80,
|
||||||
|
child: TypeAheadFormField(
|
||||||
|
textFieldConfiguration: TextFieldConfiguration(
|
||||||
|
controller: _labelTypeAheadController,
|
||||||
|
decoration:
|
||||||
|
InputDecoration(labelText: 'Add a new label')),
|
||||||
|
suggestionsCallback: (pattern) {
|
||||||
|
return _searchLabel(pattern);
|
||||||
|
},
|
||||||
|
itemBuilder: (context, suggestion) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(suggestion),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
transitionBuilder: (context, suggestionsBox, controller) {
|
||||||
|
return suggestionsBox;
|
||||||
|
},
|
||||||
|
onSuggestionSelected: (suggestion) {
|
||||||
|
_addLabel(suggestion);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () =>
|
||||||
|
_createAndAddLabel(_labelTypeAheadController.text),
|
||||||
|
icon: Icon(Icons.add),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Builder(
|
||||||
|
builder: (context) => Padding(
|
||||||
|
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
child: FancyButton(
|
||||||
|
onPressed: !_loading
|
||||||
|
? () {
|
||||||
|
if (_formKey.currentState.validate()) {
|
||||||
|
Form.of(context).save();
|
||||||
|
_saveTask(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: _loading
|
||||||
|
? CircularProgressIndicator()
|
||||||
|
: VikunjaButtonText('Save'),
|
||||||
|
))),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
_saveTask(BuildContext context) async {
|
||||||
|
setState(() => _loading = true);
|
||||||
|
|
||||||
|
// Removes all reminders with no value set.
|
||||||
|
_reminderDates.removeWhere((d) => d == null);
|
||||||
|
|
||||||
|
Task updatedTask = Task(
|
||||||
|
id: widget.task.id,
|
||||||
|
text: _text,
|
||||||
|
description: _description,
|
||||||
|
done: widget.task.done,
|
||||||
|
reminderDates: _reminderDates,
|
||||||
|
dueDate: _dueDate,
|
||||||
|
startDate: _startDate,
|
||||||
|
endDate: _endDate,
|
||||||
|
priority: _priority,
|
||||||
|
repeatAfter: _repeatAfter,
|
||||||
|
);
|
||||||
|
|
||||||
|
// update the labels
|
||||||
|
VikunjaGlobal.of(context)
|
||||||
|
.labelTaskBulkService
|
||||||
|
.update(updatedTask, _labels)
|
||||||
|
.catchError((err) {
|
||||||
|
setState(() => _loading = false);
|
||||||
|
Scaffold.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Something went wrong: ' + err.toString()),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
VikunjaGlobal.of(context).taskService.update(updatedTask).then((_) {
|
||||||
|
setState(() => _loading = false);
|
||||||
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
|
content: Text('The task was updated successfully!'),
|
||||||
|
));
|
||||||
|
}).catchError((err) {
|
||||||
|
setState(() => _loading = false);
|
||||||
|
Scaffold.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Something went wrong: ' + err.toString()),
|
||||||
|
action: SnackBarAction(
|
||||||
|
label: 'CLOSE',
|
||||||
|
onPressed: Scaffold.of(context).hideCurrentSnackBar),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeLabel(Label label) {
|
||||||
|
setState(() {
|
||||||
|
_labels.removeWhere((l) => l.id == label.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_searchLabel(String query) {
|
||||||
|
return VikunjaGlobal.of(context)
|
||||||
|
.labelService
|
||||||
|
.getAll(query: query)
|
||||||
|
.then((labels) {
|
||||||
|
// Only show those labels which aren't already added to the task
|
||||||
|
labels.removeWhere((labelToRemove) => _labels.contains(labelToRemove));
|
||||||
|
_suggestedLabels = labels;
|
||||||
|
return labels.map((label) => label.title).toList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_addLabel(String labelTitle) {
|
||||||
|
// FIXME: This is not an optimal solution...
|
||||||
|
bool found = false;
|
||||||
|
_suggestedLabels.forEach((label) {
|
||||||
|
if (label.title == labelTitle) {
|
||||||
|
_labels.add(label);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
_labelTypeAheadController.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_createAndAddLabel(String labelTitle) {
|
||||||
|
// Only add a label if there are none to add
|
||||||
|
if (labelTitle == '' || _suggestedLabels.length > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Label newLabel = Label(title: labelTitle);
|
||||||
|
VikunjaGlobal.of(context)
|
||||||
|
.labelService
|
||||||
|
.create(newLabel)
|
||||||
|
.then((createdLabel) {
|
||||||
|
setState(() {
|
||||||
|
_labels.add(createdLabel);
|
||||||
|
_labelTypeAheadController.clear();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Move the following two functions to an extra class or type.
|
||||||
|
_priorityFromString(String priority) {
|
||||||
|
switch (priority) {
|
||||||
|
case 'Low':
|
||||||
|
return 1;
|
||||||
|
case 'Medium':
|
||||||
|
return 2;
|
||||||
|
case 'High':
|
||||||
|
return 3;
|
||||||
|
case 'Urgent':
|
||||||
|
return 4;
|
||||||
|
case 'DO NOW':
|
||||||
|
return 5;
|
||||||
|
default:
|
||||||
|
// unset
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_priorityToString(int priority) {
|
||||||
|
switch (priority) {
|
||||||
|
case 0:
|
||||||
|
return 'Unset';
|
||||||
|
case 1:
|
||||||
|
return 'Low';
|
||||||
|
case 2:
|
||||||
|
return 'Medium';
|
||||||
|
case 3:
|
||||||
|
return 'High';
|
||||||
|
case 4:
|
||||||
|
return 'Urgent';
|
||||||
|
case 5:
|
||||||
|
return 'DO NOW';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,12 +75,6 @@ class _NamespacePageState extends State<NamespacePage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() {
|
|
||||||
super.didChangeDependencies();
|
|
||||||
_loadLists();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future _removeList(TaskList list) {
|
Future _removeList(TaskList list) {
|
||||||
return VikunjaGlobal.of(context)
|
return VikunjaGlobal.of(context)
|
||||||
.listService
|
.listService
|
||||||
|
|
|
@ -4,20 +4,24 @@ class PlaceholderPage extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Container(
|
return new Container(
|
||||||
padding: EdgeInsets.only(left: 16.0),
|
padding: EdgeInsets.all(16),
|
||||||
child: new Column(
|
child: Center(
|
||||||
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 32.0),
|
padding: EdgeInsets.only(top: 32.0),
|
||||||
child: new Text(
|
child: Text(
|
||||||
'Welcome to Vikunja',
|
'Welcome to Vikunja',
|
||||||
style: Theme.of(context).textTheme.headline,
|
style: Theme.of(context).textTheme.headline,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
new Text('Please select a namespace by tapping the ☰ icon.',
|
Padding(
|
||||||
style: Theme.of(context).textTheme.subhead),
|
padding: EdgeInsets.symmetric(vertical: 10),
|
||||||
|
child: Text('Please select a namespace by tapping the ☰ icon.',
|
||||||
|
style: Theme.of(context).textTheme.subhead),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
));
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ var _tasks = {
|
||||||
1: Task(
|
1: Task(
|
||||||
id: 1,
|
id: 1,
|
||||||
text: 'Task 1',
|
text: 'Task 1',
|
||||||
owner: _users[1],
|
createdBy: _users[1],
|
||||||
updated: DateTime.now(),
|
updated: DateTime.now(),
|
||||||
created: DateTime.now(),
|
created: DateTime.now(),
|
||||||
description: 'A descriptive task',
|
description: 'A descriptive task',
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
import 'package:vikunja_app/models/labelTask.dart';
|
||||||
import 'package:vikunja_app/models/list.dart';
|
import 'package:vikunja_app/models/list.dart';
|
||||||
import 'package:vikunja_app/models/namespace.dart';
|
import 'package:vikunja_app/models/namespace.dart';
|
||||||
import 'package:vikunja_app/models/task.dart';
|
import 'package:vikunja_app/models/task.dart';
|
||||||
|
@ -33,3 +35,21 @@ abstract class UserService {
|
||||||
Future<UserTokenPair> register(String username, email, password);
|
Future<UserTokenPair> register(String username, email, password);
|
||||||
Future<User> getCurrentUser();
|
Future<User> getCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class LabelService {
|
||||||
|
Future<List<Label>> getAll({String query});
|
||||||
|
Future<Label> get(int labelID);
|
||||||
|
Future<Label> create(Label label);
|
||||||
|
Future<Label> delete(Label label);
|
||||||
|
Future<Label> update(Label label);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class LabelTaskService {
|
||||||
|
Future<List<Label>> getAll(LabelTask lt, {String query});
|
||||||
|
Future<Label> create(LabelTask lt);
|
||||||
|
Future<Label> delete(LabelTask lt);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class LabelTaskBulkService {
|
||||||
|
Future<List<Label>> update(Task task, List<Label> labels);
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
/////////
|
/////////
|
||||||
// Colors
|
// Colors
|
||||||
|
@ -17,9 +18,15 @@ const vButtonColor = vPrimary;
|
||||||
const vButtonTextColor = vWhite;
|
const vButtonTextColor = vWhite;
|
||||||
const vButtonShadow = Color(0xFFb2d9ff);
|
const vButtonShadow = Color(0xFFb2d9ff);
|
||||||
|
|
||||||
|
const vLabelLight = Color(0xFFf2f2f2);
|
||||||
|
const vLabelDark = Color(0xFF4a4a4a);
|
||||||
|
const vLabelDefaultColor = vGreen;
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// Paddings
|
// Paddings
|
||||||
////////
|
////////
|
||||||
const vStandardVerticalPadding = EdgeInsets.symmetric(vertical: 5.0);
|
const vStandardVerticalPadding = EdgeInsets.symmetric(vertical: 5.0);
|
||||||
const vStandardHorizontalPadding = EdgeInsets.symmetric(horizontal: 5.0);
|
const vStandardHorizontalPadding = EdgeInsets.symmetric(horizontal: 5.0);
|
||||||
const vStandardPadding = EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0);
|
const vStandardPadding = EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0);
|
||||||
|
|
||||||
|
var vDateFormatLong = DateFormat("EEEE, MMMM d, yyyy 'at' H:mm");
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
datetimeToUnixTimestamp(DateTime dt) {
|
||||||
|
return dt?.millisecondsSinceEpoch == null
|
||||||
|
? null
|
||||||
|
: (dt.millisecondsSinceEpoch / 1000).round();
|
||||||
|
}
|
||||||
|
|
||||||
|
dateTimeFromUnixTimestamp(int timestamp) {
|
||||||
|
return timestamp == null
|
||||||
|
? 0
|
||||||
|
: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000);
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
getRepeatAfterTypeFromDuration(Duration repeatAfter) {
|
||||||
|
if (repeatAfter == null || repeatAfter.inSeconds == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if its dividable by 24, its something with days, otherwise hours
|
||||||
|
if (repeatAfter.inHours % 24 == 0) {
|
||||||
|
if (repeatAfter.inDays % 7 == 0) {
|
||||||
|
return 'Weeks';
|
||||||
|
} else if (repeatAfter.inDays % 365 == 0) {
|
||||||
|
return 'Years';
|
||||||
|
} else if (repeatAfter.inDays % 30 == 0) {
|
||||||
|
return 'Months';
|
||||||
|
} else {
|
||||||
|
return 'Days';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 'Hours';
|
||||||
|
}
|
||||||
|
|
||||||
|
getRepeatAfterValueFromDuration(Duration repeatAfter) {
|
||||||
|
if (repeatAfter == null || repeatAfter.inSeconds == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if its dividable by 24, its something with days, otherwise hours
|
||||||
|
if (repeatAfter.inHours % 24 == 0) {
|
||||||
|
if (repeatAfter.inDays % 7 == 0) {
|
||||||
|
// Weeks
|
||||||
|
return (repeatAfter.inDays / 7).round();
|
||||||
|
} else if (repeatAfter.inDays % 365 == 0) {
|
||||||
|
// Years
|
||||||
|
return (repeatAfter.inDays / 365).round();
|
||||||
|
} else if (repeatAfter.inDays % 30 == 0) {
|
||||||
|
// Months
|
||||||
|
return (repeatAfter.inDays / 30).round();
|
||||||
|
} else {
|
||||||
|
return repeatAfter.inDays; // Days
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise Hours
|
||||||
|
return repeatAfter.inHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDurationFromType(String value, String type) {
|
||||||
|
// Return an empty duration if either of the values is not set
|
||||||
|
if (value == null || value == '' || type == null || type == '') {
|
||||||
|
return Duration();
|
||||||
|
}
|
||||||
|
|
||||||
|
int val = int.parse(value);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case 'Hours':
|
||||||
|
return Duration(hours: val);
|
||||||
|
case 'Days':
|
||||||
|
return Duration(days: val);
|
||||||
|
case 'Weeks':
|
||||||
|
return Duration(days: val * 7);
|
||||||
|
case 'Months':
|
||||||
|
return Duration(days: val * 30);
|
||||||
|
case 'Years':
|
||||||
|
return Duration(days: val * 365);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,10 +13,13 @@ dependencies:
|
||||||
flutter_secure_storage: 3.3.1+1
|
flutter_secure_storage: 3.3.1+1
|
||||||
http: 0.12.0+3
|
http: 0.12.0+3
|
||||||
after_layout: ^1.0.7
|
after_layout: ^1.0.7
|
||||||
|
datetime_picker_formfield: ^0.1.8
|
||||||
|
flutter_typeahead: ^1.2.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
test: ^1.4.0
|
||||||
flutter_launcher_icons: "^0.6.1"
|
flutter_launcher_icons: "^0.6.1"
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
import 'package:vikunja_app/models/label.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('label color from json', () {
|
||||||
|
final String json = '{"TaskID": 123,"id": 1,"title": "this","description": "","hex_color": "e8e8e8","created_by":{"id": 1,"username": "user","email": "test@example.com","created": 1537855131,"updated": 1545233325},"created": 1552903790,"updated": 1552903790}';
|
||||||
|
final JsonDecoder _decoder = new JsonDecoder();
|
||||||
|
Label label = Label.fromJson(_decoder.convert(json));
|
||||||
|
|
||||||
|
expect(label.color, Color(0xFFe8e8e8));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('hex color string from object', () {
|
||||||
|
Label label = Label(id: 1, color: Color(0xFFe8e8e8));
|
||||||
|
var json = label.toJSON();
|
||||||
|
|
||||||
|
expect(json.toString(), '{id: 1, title: null, description: null, hex_color: e8e8e8, created_by: null, updated: null, created: null}');
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
import 'package:vikunja_app/utils/repeat_after_parse.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Repeat after hours', () {
|
||||||
|
Duration testDuration = Duration(hours: 6);
|
||||||
|
|
||||||
|
expect(getRepeatAfterTypeFromDuration(testDuration), 'Hours');
|
||||||
|
expect(getRepeatAfterValueFromDuration(testDuration), 6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Repeat after days', () {
|
||||||
|
Duration testDuration = Duration(days: 6);
|
||||||
|
|
||||||
|
expect(getRepeatAfterTypeFromDuration(testDuration), 'Days');
|
||||||
|
expect(getRepeatAfterValueFromDuration(testDuration), 6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Repeat after weeks', () {
|
||||||
|
Duration testDuration = Duration(days: 6 * 7);
|
||||||
|
|
||||||
|
expect(getRepeatAfterTypeFromDuration(testDuration), 'Weeks');
|
||||||
|
expect(getRepeatAfterValueFromDuration(testDuration), 6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Repeat after months', () {
|
||||||
|
Duration testDuration = Duration(days: 6 * 30);
|
||||||
|
|
||||||
|
expect(getRepeatAfterTypeFromDuration(testDuration), 'Months');
|
||||||
|
expect(getRepeatAfterValueFromDuration(testDuration), 6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Repeat after years', () {
|
||||||
|
Duration testDuration = Duration(days: 6 * 365);
|
||||||
|
|
||||||
|
expect(getRepeatAfterTypeFromDuration(testDuration), 'Years');
|
||||||
|
expect(getRepeatAfterValueFromDuration(testDuration), 6);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Repeat null value', () {
|
||||||
|
Duration testDuration = Duration();
|
||||||
|
|
||||||
|
expect(getRepeatAfterTypeFromDuration(testDuration), null);
|
||||||
|
expect(getRepeatAfterValueFromDuration(testDuration), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Hours to duration', () {
|
||||||
|
Duration parsedDuration = getDurationFromType('6', 'Hours');
|
||||||
|
expect(parsedDuration, Duration(hours: 6));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Days to duration', () {
|
||||||
|
Duration parsedDuration = getDurationFromType('6', 'Days');
|
||||||
|
expect(parsedDuration, Duration(days: 6));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Weeks to duration', () {
|
||||||
|
Duration parsedDuration = getDurationFromType('6', 'Weeks');
|
||||||
|
expect(parsedDuration, Duration(days: 6 * 7));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Months to duration', () {
|
||||||
|
Duration parsedDuration = getDurationFromType('6', 'Months');
|
||||||
|
expect(parsedDuration, Duration(days: 6 * 30));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Years to duration', () {
|
||||||
|
Duration parsedDuration = getDurationFromType('6', 'Years');
|
||||||
|
expect(parsedDuration, Duration(days: 6 * 365));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('null to duration', () {
|
||||||
|
Duration parsedDuration = getDurationFromType(null, null);
|
||||||
|
expect(parsedDuration, Duration());
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:vikunja_app/models/task.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Check encoding with all values set', () {
|
||||||
|
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": [1543834800,1544612400],"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 1,"username": "user","email": "test@example.com","created": 1537855131,"updated": 1545233325}}';
|
||||||
|
final JsonDecoder _decoder = new JsonDecoder();
|
||||||
|
final task = Task.fromJson(_decoder.convert(json));
|
||||||
|
|
||||||
|
expect(task.id, 1);
|
||||||
|
expect(task.text, 'test');
|
||||||
|
expect(task.description, 'Lorem Ipsum');
|
||||||
|
expect(task.done, true);
|
||||||
|
expect(task.reminderDates, [
|
||||||
|
DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000),
|
||||||
|
DateTime.fromMillisecondsSinceEpoch(1544612400 * 1000),
|
||||||
|
]);
|
||||||
|
expect(task.dueDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000));
|
||||||
|
expect(task.repeatAfter, Duration(seconds: 3600));
|
||||||
|
expect(task.parentTaskId, 0);
|
||||||
|
expect(task.priority, 100);
|
||||||
|
expect(task.startDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000));
|
||||||
|
expect(task.endDate, DateTime.fromMillisecondsSinceEpoch(1543835000 * 1000));
|
||||||
|
expect(task.labels, null);
|
||||||
|
expect(task.subtasks, null);
|
||||||
|
expect(task.created, DateTime.fromMillisecondsSinceEpoch(1542465818 * 1000));
|
||||||
|
expect(task.updated, DateTime.fromMillisecondsSinceEpoch(1552771527 * 1000));
|
||||||
|
});
|
||||||
|
test('Check encoding with reminder dates as null', () {
|
||||||
|
final String json = '{"id": 1,"text": "test","description": "Lorem Ipsum","done": true,"dueDate": 1543834800,"reminderDates": null,"repeatAfter": 3600,"parentTaskID": 0,"priority": 100,"startDate": 1543834800,"endDate": 1543835000,"assignees": null,"labels": null,"subtasks": null,"created": 1542465818,"updated": 1552771527,"createdBy": {"id": 1,"username": "user","email": "test@example.com","created": 1537855131,"updated": 1545233325}}';
|
||||||
|
final JsonDecoder _decoder = new JsonDecoder();
|
||||||
|
final task = Task.fromJson(_decoder.convert(json));
|
||||||
|
|
||||||
|
expect(task.id, 1);
|
||||||
|
expect(task.text, 'test');
|
||||||
|
expect(task.description, 'Lorem Ipsum');
|
||||||
|
expect(task.done, true);
|
||||||
|
expect(task.reminderDates, null);
|
||||||
|
expect(task.dueDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000));
|
||||||
|
expect(task.repeatAfter, Duration(seconds: 3600));
|
||||||
|
expect(task.parentTaskId, 0);
|
||||||
|
expect(task.priority, 100);
|
||||||
|
expect(task.startDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000));
|
||||||
|
expect(task.endDate, DateTime.fromMillisecondsSinceEpoch(1543835000 * 1000));
|
||||||
|
expect(task.labels, null);
|
||||||
|
expect(task.subtasks, null);
|
||||||
|
expect(task.created, DateTime.fromMillisecondsSinceEpoch(1542465818 * 1000));
|
||||||
|
expect(task.updated, DateTime.fromMillisecondsSinceEpoch(1552771527 * 1000));
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue