Compare commits
3 Commits
f1ebc2c516
...
c37daa7e8b
Author | SHA1 | Date |
---|---|---|
Denys Vitali | c37daa7e8b | |
Denys Vitali | 37009e2eaa | |
Denys Vitali | ecd2006955 |
|
@ -12,15 +12,14 @@ class BucketAPIService extends APIService implements BucketService {
|
|||
return client
|
||||
.put('/projects/$projectId/buckets', body: bucket.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Bucket.fromJSON(response.body);
|
||||
});
|
||||
if (response == null) return null;
|
||||
return Bucket.fromJSON(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future delete(int projectId, int bucketId) {
|
||||
return client
|
||||
.delete('/projects/$projectId/buckets/$bucketId');
|
||||
return client.delete('/projects/$projectId/buckets/$bucketId');
|
||||
}
|
||||
|
||||
/* Not implemented in the Vikunja API
|
||||
|
@ -35,13 +34,13 @@ class BucketAPIService extends APIService implements BucketService {
|
|||
@override
|
||||
Future<Response?> getAllByList(int projectId,
|
||||
[Map<String, List<String>>? queryParameters]) {
|
||||
return client
|
||||
.get('/projects/$projectId/buckets', queryParameters)
|
||||
.then((response) => response != null ? new Response(
|
||||
convertList(response.body, (result) => Bucket.fromJSON(result)),
|
||||
response.statusCode,
|
||||
response.headers
|
||||
) : null);
|
||||
return client.get('/projects/$projectId/buckets', queryParameters).then(
|
||||
(response) => response != null
|
||||
? new Response(
|
||||
convertList(response.body, (result) => Bucket.fromJSON(result)),
|
||||
response.statusCode,
|
||||
response.headers)
|
||||
: null);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -51,10 +50,11 @@ class BucketAPIService extends APIService implements BucketService {
|
|||
@override
|
||||
Future<Bucket?> update(Bucket bucket) {
|
||||
return client
|
||||
.post('/projects/${bucket.projectId}/buckets/${bucket.id}', body: bucket.toJSON())
|
||||
.post('/projects/${bucket.projectId}/buckets/${bucket.id}',
|
||||
body: bucket.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Bucket.fromJSON(response.body);
|
||||
});
|
||||
if (response == null) return null;
|
||||
return Bucket.fromJSON(response.body);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class LabelTaskAPIService extends APIService implements LabelTaskService {
|
|||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -22,9 +22,9 @@ class LabelTaskAPIService extends APIService implements LabelTaskService {
|
|||
return client
|
||||
.delete('/tasks/${lt.task!.id}/labels/${lt.label.id}')
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -32,10 +32,9 @@ class LabelTaskAPIService extends APIService implements LabelTaskService {
|
|||
String? params =
|
||||
query == null ? null : '?s=' + Uri.encodeQueryComponent(query);
|
||||
|
||||
return client.get('/tasks/${lt.task!.id}/labels$params').then(
|
||||
(label) {
|
||||
if (label == null) return null;
|
||||
return convertList(label, (result) => Label.fromJson(result));
|
||||
});
|
||||
return client.get('/tasks/${lt.task!.id}/labels$params').then((label) {
|
||||
if (label == null) return null;
|
||||
return convertList(label, (result) => Label.fromJson(result));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,15 +11,14 @@ class LabelTaskBulkAPIService extends APIService
|
|||
|
||||
@override
|
||||
Future<List<Label>?> update(Task task, List<Label>? labels) {
|
||||
if(labels == null)
|
||||
labels = [];
|
||||
if (labels == null) labels = [];
|
||||
return client
|
||||
.post('/tasks/${task.id}/labels/bulk',
|
||||
body: LabelTaskBulk(labels: labels).toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return convertList(
|
||||
response.body['labels'], (result) => Label.fromJson(result));
|
||||
});
|
||||
if (response == null) return null;
|
||||
return convertList(
|
||||
response.body['labels'], (result) => Label.fromJson(result));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,52 +8,43 @@ class LabelAPIService extends APIService implements LabelService {
|
|||
|
||||
@override
|
||||
Future<Label?> create(Label label) {
|
||||
return client
|
||||
.put('/labels', body: label.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
return client.put('/labels', body: label.toJSON()).then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Label?> delete(Label label) {
|
||||
return client
|
||||
.delete('/labels/${label.id}')
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
return client.delete('/labels/${label.id}').then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Label?> get(int labelID) {
|
||||
return client
|
||||
.get('/labels/$labelID')
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
return client.get('/labels/$labelID').then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Label>?> getAll({String? query}) {
|
||||
String params =
|
||||
query == null ? '' : '?s=' + Uri.encodeQueryComponent(query);
|
||||
return client.get('/labels$params').then(
|
||||
(response) {
|
||||
if (response == null) return null;
|
||||
return convertList(response.body, (result) => Label.fromJson(result));
|
||||
});
|
||||
return client.get('/labels$params').then((response) {
|
||||
if (response == null) return null;
|
||||
return convertList(response.body, (result) => Label.fromJson(result));
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Label?> update(Label label) {
|
||||
return client
|
||||
.post('/labels/${label.id}', body: label)
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
return client.post('/labels/${label.id}', body: label).then((response) {
|
||||
if (response == null) return null;
|
||||
return Label.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ class NamespaceAPIService extends APIService implements NamespaceService {
|
|||
return client
|
||||
.post('/namespaces/${ns.id}', body: ns.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Namespace.fromJson(response.body);
|
||||
if (response == null) return null;
|
||||
return Namespace.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,7 @@ class ServerAPIService extends APIService implements ServerService {
|
|||
@override
|
||||
Future<Server?> getInfo() {
|
||||
return client.get('/info').then((value) {
|
||||
if(value == null)
|
||||
return null;
|
||||
if (value == null) return null;
|
||||
return Server.fromJson(value.body);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,25 +14,22 @@ class TaskAPIService extends APIService implements TaskService {
|
|||
return client
|
||||
.put('/projects/$projectId/tasks', body: task.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Task.fromJson(response.body);
|
||||
});
|
||||
if (response == null) return null;
|
||||
return Task.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Task?> get(int listId) {
|
||||
return client
|
||||
.get('/project/$listId/tasks')
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Task.fromJson(response.body);
|
||||
});
|
||||
return client.get('/project/$listId/tasks').then((response) {
|
||||
if (response == null) return null;
|
||||
return Task.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future delete(int taskId) {
|
||||
return client
|
||||
.delete('/tasks/$taskId');
|
||||
return client.delete('/tasks/$taskId');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -40,36 +37,38 @@ class TaskAPIService extends APIService implements TaskService {
|
|||
return client
|
||||
.post('/tasks/${task.id}', body: task.toJSON())
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return Task.fromJson(response.body);
|
||||
});
|
||||
if (response == null) return null;
|
||||
return Task.fromJson(response.body);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Task>?> getAll() {
|
||||
return client
|
||||
.get('/tasks/all')
|
||||
.then((response) {
|
||||
int page_n = 0;
|
||||
if (response == null) return null;
|
||||
if (response.headers["x-pagination-total-pages"] != null) {
|
||||
page_n = int.parse(response.headers["x-pagination-total-pages"]!);
|
||||
} else {
|
||||
return Future.value(response.body);
|
||||
}
|
||||
return client.get('/tasks/all').then((response) {
|
||||
int page_n = 0;
|
||||
if (response == null) return null;
|
||||
if (response.headers["x-pagination-total-pages"] != null) {
|
||||
page_n = int.parse(response.headers["x-pagination-total-pages"]!);
|
||||
} else {
|
||||
return Future.value(response.body);
|
||||
}
|
||||
|
||||
List<Future<void>> futureList = [];
|
||||
List<Task> taskList = [];
|
||||
List<Future<void>> futureList = [];
|
||||
List<Task> taskList = [];
|
||||
|
||||
for(int i = 0; i < page_n; i++) {
|
||||
Map<String, List<String>> paramMap = {
|
||||
"page": [i.toString()]
|
||||
};
|
||||
futureList.add(client.get('/tasks/all', paramMap).then((pageResponse) {convertList(pageResponse?.body, (result) {taskList.add(Task.fromJson(result));});}));
|
||||
}
|
||||
return Future.wait(futureList).then((value) {
|
||||
return taskList;
|
||||
for (int i = 0; i < page_n; i++) {
|
||||
Map<String, List<String>> paramMap = {
|
||||
"page": [i.toString()]
|
||||
};
|
||||
futureList.add(client.get('/tasks/all', paramMap).then((pageResponse) {
|
||||
convertList(pageResponse?.body, (result) {
|
||||
taskList.add(Task.fromJson(result));
|
||||
});
|
||||
}));
|
||||
}
|
||||
return Future.wait(futureList).then((value) {
|
||||
return taskList;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -77,14 +76,15 @@ class TaskAPIService extends APIService implements TaskService {
|
|||
Future<Response?> getAllByProject(int projectId,
|
||||
[Map<String, List<String>>? queryParameters]) {
|
||||
return client
|
||||
.get('/projects/$projectId/tasks', queryParameters).then(
|
||||
(response) {
|
||||
return response != null ?
|
||||
new Response(
|
||||
convertList(response.body, (result) => Task.fromJson(result)),
|
||||
response.statusCode,
|
||||
response.headers) : null;
|
||||
});
|
||||
.get('/projects/$projectId/tasks', queryParameters)
|
||||
.then((response) {
|
||||
return response != null
|
||||
? new Response(
|
||||
convertList(response.body, (result) => Task.fromJson(result)),
|
||||
response.statusCode,
|
||||
response.headers)
|
||||
: null;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -93,16 +93,13 @@ class TaskAPIService extends APIService implements TaskService {
|
|||
//optionString = "?sort_by[]=due_date&sort_by[]=id&order_by[]=asc&order_by[]=desc&filter_by[]=done&filter_value[]=false&filter_comparator[]=equals&filter_concat=and&filter_include_nulls=false&page=1";
|
||||
//print(optionString);
|
||||
|
||||
return client
|
||||
.get('/tasks/all', optionsMap)
|
||||
.then((response) {
|
||||
if (response == null) return null;
|
||||
return convertList(response.body, (result) => Task.fromJson(result));
|
||||
return client.get('/tasks/all', optionsMap).then((response) {
|
||||
if (response == null) return null;
|
||||
return convertList(response.body, (result) => Task.fromJson(result));
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
// TODO: implement maxPages
|
||||
int get maxPages => maxPages;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'dart:convert';
|
|||
import 'package:http/http.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
|
||||
class VersionChecker {
|
||||
GlobalKey<ScaffoldMessengerState> snackbarKey;
|
||||
VersionChecker(this.snackbarKey);
|
||||
|
@ -46,7 +45,8 @@ class VersionChecker {
|
|||
content: Text("New version available: $latest"),
|
||||
action: SnackBarAction(
|
||||
label: "View on Github",
|
||||
onPressed: () => launchUrl(Uri.parse(repo), mode: LaunchMode.externalApplication)),
|
||||
onPressed: () => launchUrl(Uri.parse(repo),
|
||||
mode: LaunchMode.externalApplication)),
|
||||
);
|
||||
snackbarKey.currentState?.showSnackBar(snackBar);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:vikunja_app/components/datetimePicker.dart';
|
||||
|
||||
enum NewTaskDue {day,week, month, custom}
|
||||
enum NewTaskDue { day, week, month, custom }
|
||||
|
||||
// TODO: add to enum above
|
||||
Map<NewTaskDue, Duration> newTaskDueToDuration = {
|
||||
NewTaskDue.day: Duration(days: 1),
|
||||
|
@ -13,11 +14,11 @@ class AddDialog extends StatefulWidget {
|
|||
final ValueChanged<String>? onAdd;
|
||||
final void Function(String title, DateTime? dueDate)? onAddTask;
|
||||
final InputDecoration? decoration;
|
||||
const AddDialog({Key? key, this.onAdd, this.decoration, this.onAddTask}) : super(key: key);
|
||||
const AddDialog({Key? key, this.onAdd, this.decoration, this.onAddTask})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => AddDialogState();
|
||||
|
||||
}
|
||||
|
||||
class AddDialogState extends State<AddDialog> {
|
||||
|
@ -27,13 +28,11 @@ class AddDialogState extends State<AddDialog> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(newTaskDue != NewTaskDue.custom)
|
||||
if (newTaskDue != NewTaskDue.custom)
|
||||
customDueDate = DateTime.now().add(newTaskDueToDuration[newTaskDue]!);
|
||||
return new AlertDialog(
|
||||
contentPadding: const EdgeInsets.all(16.0),
|
||||
content: new Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
content: new Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Row(children: <Widget>[
|
||||
Expanded(
|
||||
child: new TextField(
|
||||
|
@ -43,14 +42,24 @@ class AddDialogState extends State<AddDialog> {
|
|||
),
|
||||
),
|
||||
]),
|
||||
widget.onAddTask != null ? taskDueList("1 Day", NewTaskDue.day) : new Container(),
|
||||
widget.onAddTask != null ? taskDueList("1 Week", NewTaskDue.week) : new Container(),
|
||||
widget.onAddTask != null ? taskDueList("1 Month", NewTaskDue.month) : new Container(),
|
||||
widget.onAddTask != null ? VikunjaDateTimePicker(
|
||||
label: "Enter exact time",
|
||||
onChanged: (value) {setState(() => newTaskDue = NewTaskDue.custom); customDueDate = value;},
|
||||
|
||||
) : new Container(),
|
||||
widget.onAddTask != null
|
||||
? taskDueList("1 Day", NewTaskDue.day)
|
||||
: new Container(),
|
||||
widget.onAddTask != null
|
||||
? taskDueList("1 Week", NewTaskDue.week)
|
||||
: new Container(),
|
||||
widget.onAddTask != null
|
||||
? taskDueList("1 Month", NewTaskDue.month)
|
||||
: new Container(),
|
||||
widget.onAddTask != null
|
||||
? VikunjaDateTimePicker(
|
||||
label: "Enter exact time",
|
||||
onChanged: (value) {
|
||||
setState(() => newTaskDue = NewTaskDue.custom);
|
||||
customDueDate = value;
|
||||
},
|
||||
)
|
||||
: new Container(),
|
||||
//],)
|
||||
]),
|
||||
actions: <Widget>[
|
||||
|
@ -63,7 +72,7 @@ class AddDialogState extends State<AddDialog> {
|
|||
onPressed: () {
|
||||
if (widget.onAdd != null && textController.text.isNotEmpty)
|
||||
widget.onAdd!(textController.text);
|
||||
if(widget.onAddTask != null && textController.text.isNotEmpty) {
|
||||
if (widget.onAddTask != null && textController.text.isNotEmpty) {
|
||||
widget.onAddTask!(textController.text, customDueDate);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
|
@ -75,9 +84,15 @@ class AddDialogState extends State<AddDialog> {
|
|||
|
||||
Widget taskDueList(String name, NewTaskDue thisNewTaskDue) {
|
||||
return Row(children: [
|
||||
Checkbox(value: newTaskDue == thisNewTaskDue, onChanged: (value) {
|
||||
newTaskDue = thisNewTaskDue;
|
||||
setState(() => customDueDate = DateTime.now().add(newTaskDueToDuration[thisNewTaskDue]!));}, shape: CircleBorder(),),
|
||||
Checkbox(
|
||||
value: newTaskDue == thisNewTaskDue,
|
||||
onChanged: (value) {
|
||||
newTaskDue = thisNewTaskDue;
|
||||
setState(() => customDueDate =
|
||||
DateTime.now().add(newTaskDueToDuration[thisNewTaskDue]!));
|
||||
},
|
||||
shape: CircleBorder(),
|
||||
),
|
||||
Text(name),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -36,13 +36,15 @@ class _BucketLimitDialogState extends State<BucketLimitDialog> {
|
|||
inputFormatters: <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
],
|
||||
onSubmitted: (text) => Navigator.of(context).pop(int.parse(text)),
|
||||
onSubmitted: (text) =>
|
||||
Navigator.of(context).pop(int.parse(text)),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
IconButton(
|
||||
onPressed: () => _controller.text = '${int.parse(_controller.text) + 1}',
|
||||
onPressed: () =>
|
||||
_controller.text = '${int.parse(_controller.text) + 1}',
|
||||
icon: Icon(Icons.expand_less),
|
||||
),
|
||||
IconButton(
|
||||
|
@ -68,7 +70,8 @@ class _BucketLimitDialogState extends State<BucketLimitDialog> {
|
|||
child: Text('Remove Limit'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(int.parse(_controller.text)),
|
||||
onPressed: () =>
|
||||
Navigator.of(context).pop(int.parse(_controller.text)),
|
||||
child: Text('Done'),
|
||||
)
|
||||
],
|
||||
|
|
|
@ -20,20 +20,23 @@ class SliverBucketList extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return index >= bucket.tasks.length ? null : BucketTaskCard(
|
||||
key: ObjectKey(bucket.tasks[index]),
|
||||
task: bucket.tasks[index],
|
||||
index: index,
|
||||
onDragUpdate: onTaskDragUpdate,
|
||||
onAccept: (task, index) {
|
||||
_moveTaskToBucket(context, task, index);
|
||||
},
|
||||
);
|
||||
return index >= bucket.tasks.length
|
||||
? null
|
||||
: BucketTaskCard(
|
||||
key: ObjectKey(bucket.tasks[index]),
|
||||
task: bucket.tasks[index],
|
||||
index: index,
|
||||
onDragUpdate: onTaskDragUpdate,
|
||||
onAccept: (task, index) {
|
||||
_moveTaskToBucket(context, task, index);
|
||||
},
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _moveTaskToBucket(BuildContext context, Task task, int index) async {
|
||||
Future<void> _moveTaskToBucket(
|
||||
BuildContext context, Task task, int index) async {
|
||||
await Provider.of<ProjectProvider>(context, listen: false).moveTaskToBucket(
|
||||
context: context,
|
||||
task: task,
|
||||
|
@ -42,7 +45,8 @@ class SliverBucketList extends StatelessWidget {
|
|||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('\'${task.title}\' was moved to \'${bucket.title}\' successfully!'),
|
||||
content: Text(
|
||||
'\'${task.title}\' was moved to \'${bucket.title}\' successfully!'),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,14 @@ class SliverBucketPersistentHeader extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _SliverBucketPersistentHeaderDelegate(child, minExtent, maxExtent),
|
||||
delegate:
|
||||
_SliverBucketPersistentHeaderDelegate(child, minExtent, maxExtent),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SliverBucketPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||
class _SliverBucketPersistentHeaderDelegate
|
||||
extends SliverPersistentHeaderDelegate {
|
||||
final Widget child;
|
||||
final double min;
|
||||
final double max;
|
||||
|
@ -29,7 +31,8 @@ class _SliverBucketPersistentHeaderDelegate extends SliverPersistentHeaderDelega
|
|||
_SliverBucketPersistentHeaderDelegate(this.child, this.min, this.max);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return child;
|
||||
}
|
||||
|
||||
|
@ -40,8 +43,10 @@ class _SliverBucketPersistentHeaderDelegate extends SliverPersistentHeaderDelega
|
|||
double get minExtent => min;
|
||||
|
||||
@override
|
||||
bool shouldRebuild(covariant _SliverBucketPersistentHeaderDelegate oldDelegate) {
|
||||
return oldDelegate.child != child || oldDelegate.min != min || oldDelegate.max != max;
|
||||
bool shouldRebuild(
|
||||
covariant _SliverBucketPersistentHeaderDelegate oldDelegate) {
|
||||
return oldDelegate.child != child ||
|
||||
oldDelegate.min != min ||
|
||||
oldDelegate.max != max;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||
import 'package:vikunja_app/components/label.dart';
|
||||
import 'package:vikunja_app/models/task.dart';
|
||||
import 'package:vikunja_app/pages/list/task_edit.dart';
|
||||
import 'package:vikunja_app/stores/project_store.dart';
|
||||
import 'package:vikunja_app/theme/constants.dart';
|
||||
import 'package:vikunja_app/utils/priority.dart';
|
||||
|
||||
import '../models/label.dart';
|
||||
import '../models/task.dart';
|
||||
import '../pages/list/task_edit.dart';
|
||||
import '../stores/project_store.dart';
|
||||
import '../theme/constants.dart';
|
||||
import 'label.dart';
|
||||
|
||||
class TaskBottomSheet extends StatefulWidget {
|
||||
final Task task;
|
||||
final bool showInfo;
|
||||
|
@ -26,129 +24,131 @@ class TaskBottomSheet extends StatefulWidget {
|
|||
this.showInfo = false,
|
||||
this.onMarkedAsDone,
|
||||
}) : super(key: key);
|
||||
/*
|
||||
@override
|
||||
TaskTileState createState() {
|
||||
return new TaskTileState(this.task, this.loading);
|
||||
}
|
||||
|
||||
*/
|
||||
@override
|
||||
TaskBottomSheetState createState() => TaskBottomSheetState(this.task);
|
||||
TaskBottomSheetState createState() => TaskBottomSheetState();
|
||||
}
|
||||
|
||||
class TaskBottomSheetState extends State<TaskBottomSheet> {
|
||||
Task _currentTask;
|
||||
late Task _currentTask;
|
||||
|
||||
TaskBottomSheetState(this._currentTask);
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_currentTask = widget.task;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ThemeData theme = Theme.of(context);
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height * 0.9,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 10, 10, 20),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
// Title and edit button
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(_currentTask.title,
|
||||
style: theme.textTheme.headlineLarge),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.push<Task>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (buildContext) => TaskEditPage(
|
||||
task: _currentTask,
|
||||
taskState: widget.taskState,
|
||||
),
|
||||
),
|
||||
)
|
||||
.then((task) => setState(() {
|
||||
if (task != null) _currentTask = task;
|
||||
}))
|
||||
.whenComplete(() => widget.onEdit());
|
||||
},
|
||||
icon: Icon(Icons.edit)),
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
children: _currentTask.labels.map((Label label) {
|
||||
return LabelComponent(
|
||||
label: label,
|
||||
);
|
||||
}).toList()),
|
||||
final theme = Theme.of(context);
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
_currentTask.title,
|
||||
style: theme.textTheme.headline6,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _editTask,
|
||||
icon: Icon(Icons.edit),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: _currentTask.labels.map((label) {
|
||||
return LabelComponent(label: label);
|
||||
}).toList(),
|
||||
),
|
||||
HtmlWidget(
|
||||
_currentTask.description.isNotEmpty
|
||||
? _currentTask.description
|
||||
: 'No description',
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
_buildRowWithIconAndText(
|
||||
Icons.access_time,
|
||||
_currentTask.dueDate != null
|
||||
? vDateFormatShort.format(_currentTask.dueDate!.toLocal())
|
||||
: 'No due date',
|
||||
),
|
||||
_buildRowWithIconAndText(
|
||||
Icons.play_arrow_rounded,
|
||||
_currentTask.startDate != null
|
||||
? vDateFormatShort.format(_currentTask.startDate!.toLocal())
|
||||
: 'No start date',
|
||||
),
|
||||
_buildRowWithIconAndText(
|
||||
Icons.stop_rounded,
|
||||
_currentTask.endDate != null
|
||||
? vDateFormatShort.format(_currentTask.endDate!.toLocal())
|
||||
: 'No end date',
|
||||
),
|
||||
_buildRowWithIconAndText(
|
||||
Icons.priority_high,
|
||||
_currentTask.priority != null
|
||||
? priorityToString(_currentTask.priority)
|
||||
: 'No priority',
|
||||
),
|
||||
_buildRowWithIconAndText(
|
||||
Icons.percent,
|
||||
_currentTask.percent_done != null
|
||||
? '${(_currentTask.percent_done! * 100).toInt()}%'
|
||||
: 'Unset',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// description with html rendering
|
||||
Text("Description", style: theme.textTheme.headlineSmall),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
|
||||
child: HtmlWidget(_currentTask.description.isNotEmpty
|
||||
? _currentTask.description
|
||||
: "No description"),
|
||||
),
|
||||
// Due date
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.access_time),
|
||||
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
|
||||
Text(_currentTask.dueDate != null
|
||||
? vDateFormatShort.format(_currentTask.dueDate!.toLocal())
|
||||
: "No due date"),
|
||||
],
|
||||
),
|
||||
// start date
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.play_arrow_rounded),
|
||||
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
|
||||
Text(_currentTask.startDate != null
|
||||
? vDateFormatShort
|
||||
.format(_currentTask.startDate!.toLocal())
|
||||
: "No start date"),
|
||||
],
|
||||
),
|
||||
// end date
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.stop_rounded),
|
||||
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
|
||||
Text(_currentTask.endDate != null
|
||||
? vDateFormatShort.format(_currentTask.endDate!.toLocal())
|
||||
: "No end date"),
|
||||
],
|
||||
),
|
||||
// priority
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.priority_high),
|
||||
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
|
||||
Text(_currentTask.priority != null
|
||||
? priorityToString(_currentTask.priority)
|
||||
: "No priority"),
|
||||
],
|
||||
),
|
||||
// progress
|
||||
Row(
|
||||
children: [
|
||||
Icon(Icons.percent),
|
||||
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
|
||||
Text(_currentTask.percent_done != null
|
||||
? (_currentTask.percent_done! * 100).toInt().toString() +
|
||||
"%"
|
||||
: "Unset"),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
void _editTask() {
|
||||
Navigator.push<Task>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (buildContext) => TaskEditPage(
|
||||
task: _currentTask,
|
||||
taskState: widget.taskState,
|
||||
),
|
||||
),
|
||||
).then((task) {
|
||||
if (task != null) {
|
||||
setState(() {
|
||||
_currentTask = task;
|
||||
});
|
||||
}
|
||||
widget.onEdit();
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowWithIconAndText(IconData icon, String text) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon),
|
||||
SizedBox(width: 8),
|
||||
Text(text),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,160 +1,65 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:vikunja_app/components/TaskBottomSheet.dart';
|
||||
import 'package:vikunja_app/models/project.dart';
|
||||
import 'package:vikunja_app/models/task.dart';
|
||||
import 'package:vikunja_app/utils/misc.dart';
|
||||
import 'package:vikunja_app/pages/list/task_edit.dart';
|
||||
import 'package:vikunja_app/stores/project_store.dart';
|
||||
import 'package:vikunja_app/utils/misc.dart';
|
||||
import 'package:vikunja_app/utils/priority.dart';
|
||||
|
||||
import '../stores/project_store.dart';
|
||||
|
||||
class TaskTile extends StatefulWidget {
|
||||
final Task task;
|
||||
final Function onEdit;
|
||||
final bool showInfo;
|
||||
final bool loading;
|
||||
final ValueSetter<bool>? onMarkedAsDone;
|
||||
final Map<int, Project>? projectsMap;
|
||||
|
||||
const TaskTile({
|
||||
Key? key,
|
||||
required this.task,
|
||||
required this.onEdit,
|
||||
this.projectsMap,
|
||||
this.loading = false,
|
||||
this.showInfo = false,
|
||||
this.onMarkedAsDone,
|
||||
}) : super(key: key);
|
||||
/*
|
||||
@override
|
||||
TaskTileState createState() {
|
||||
return new TaskTileState(this.task, this.loading);
|
||||
}
|
||||
|
||||
*/
|
||||
@override
|
||||
TaskTileState createState() => TaskTileState(this.task);
|
||||
_TaskTileState createState() => _TaskTileState();
|
||||
}
|
||||
|
||||
Widget? _buildTaskSubtitle(Task? task, bool showInfo, BuildContext context) {
|
||||
Duration? durationUntilDue = task?.dueDate?.difference(DateTime.now());
|
||||
class _TaskTileState extends State<TaskTile> {
|
||||
late Task _currentTask;
|
||||
|
||||
if (task == null) return null;
|
||||
|
||||
List<TextSpan> texts = [];
|
||||
|
||||
if (showInfo && task.hasDueDate) {
|
||||
texts.add(TextSpan(
|
||||
text: "Due " + durationToHumanReadable(durationUntilDue!),
|
||||
style: durationUntilDue.isNegative
|
||||
? TextStyle(color: Colors.red)
|
||||
: Theme.of(context).textTheme.bodyMedium));
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_currentTask = widget.task;
|
||||
}
|
||||
if (task.priority != null && task.priority != 0) {
|
||||
texts.add(TextSpan(
|
||||
text: " !" + priorityToString(task.priority),
|
||||
style: TextStyle(color: Colors.orange)));
|
||||
}
|
||||
|
||||
//if(texts.isEmpty && task.description.isNotEmpty) {
|
||||
// return HtmlWidget(task.description);
|
||||
// }
|
||||
|
||||
if (texts.isNotEmpty) {
|
||||
return RichText(text: TextSpan(children: texts));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
||||
Task _currentTask;
|
||||
|
||||
TaskTileState(this._currentTask);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final taskState = Provider.of<ProjectProvider>(context);
|
||||
if (_currentTask.loading) {
|
||||
return ListTile(
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: SizedBox(
|
||||
height: Checkbox.width,
|
||||
width: Checkbox.width,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
)),
|
||||
),
|
||||
title: Text(_currentTask.title),
|
||||
subtitle: _currentTask.description.isEmpty
|
||||
? null
|
||||
: HtmlWidget(_currentTask.description),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () {},
|
||||
),
|
||||
);
|
||||
}
|
||||
return IntrinsicHeight(
|
||||
child: Row(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Container(
|
||||
width: 4.0, // Adjust the width of the red line
|
||||
color: widget.task.color,
|
||||
//margin: EdgeInsets.only(left: 10.0),
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
_showBottomSheet(context, taskState);
|
||||
},
|
||||
leading: _buildLeading(),
|
||||
title: _buildTitle(),
|
||||
subtitle: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
_buildSubtitle(context),
|
||||
SizedBox(height: 8),
|
||||
buildChip() ?? Container(),
|
||||
],
|
||||
),
|
||||
Flexible(
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return TaskBottomSheet(task: widget.task, onEdit: widget.onEdit, taskState: taskState);
|
||||
});
|
||||
},
|
||||
title: widget.showInfo
|
||||
? RichText(
|
||||
text: TextSpan(
|
||||
text: null,
|
||||
children: <TextSpan>[
|
||||
// TODO: get list name of task
|
||||
//TextSpan(text: widget.task.list.title+" - ", style: TextStyle(color: Colors.grey)),
|
||||
TextSpan(text: widget.task.title),
|
||||
],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
),
|
||||
))
|
||||
: Text(_currentTask.title),
|
||||
subtitle: _buildTaskSubtitle(widget.task, widget.showInfo, context),
|
||||
leading: Checkbox(
|
||||
value: _currentTask.done,
|
||||
onChanged: (bool? newValue) {
|
||||
_change(newValue);
|
||||
},
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
Navigator.push<Task>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (buildContext) => TaskEditPage(
|
||||
task: _currentTask,
|
||||
taskState: taskState,
|
||||
),
|
||||
),
|
||||
)
|
||||
.then((task) => setState(() {
|
||||
if (task != null) _currentTask = task;
|
||||
}))
|
||||
.whenComplete(() => widget.onEdit());
|
||||
}),
|
||||
))
|
||||
]));
|
||||
trailing: _buildTrailing(context),
|
||||
);
|
||||
}
|
||||
|
||||
void _change(bool? value) async {
|
||||
|
@ -179,8 +84,123 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
|
|||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => _currentTask != widget.task;
|
||||
}
|
||||
Widget _buildLeading() {
|
||||
return Checkbox(
|
||||
value: _currentTask.done,
|
||||
onChanged: (bool? newValue) {
|
||||
_change(newValue);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
typedef Future<void> TaskChanged(Task task, bool newValue);
|
||||
Widget _buildTitle() {
|
||||
return widget.showInfo
|
||||
? RichText(
|
||||
text: TextSpan(
|
||||
text: null,
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: widget.task.title,
|
||||
style: TextStyle(
|
||||
decoration:
|
||||
_currentTask.done ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
),
|
||||
],
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).brightness == Brightness.dark
|
||||
? Colors.white
|
||||
: Colors.black,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
_currentTask.title,
|
||||
style: TextStyle(
|
||||
decoration: _currentTask.done ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSubtitle(BuildContext context) {
|
||||
final durationUntilDue = _currentTask.dueDate?.difference(DateTime.now());
|
||||
if (widget.loading) {
|
||||
return CircularProgressIndicator(
|
||||
strokeWidth: 2.0,
|
||||
);
|
||||
} else if (widget.showInfo && _currentTask.hasDueDate) {
|
||||
return Text(
|
||||
"Due " + durationToHumanReadable(durationUntilDue!),
|
||||
style: TextStyle(
|
||||
color: durationUntilDue.isNegative ? Colors.red : null,
|
||||
),
|
||||
);
|
||||
} else if (_currentTask.priority != null && _currentTask.priority != 0) {
|
||||
return Text(
|
||||
" !" + priorityToString(_currentTask.priority),
|
||||
style: TextStyle(color: Colors.orange),
|
||||
);
|
||||
} else if (_currentTask.description.isNotEmpty) {
|
||||
return HtmlWidget(_currentTask.description);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTrailing(BuildContext context) {
|
||||
return IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
Navigator.push<Task>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (buildContext) => TaskEditPage(
|
||||
task: _currentTask,
|
||||
taskState: Provider.of<ProjectProvider>(context, listen: false),
|
||||
),
|
||||
),
|
||||
).then((task) {
|
||||
if (task != null) {
|
||||
setState(() {
|
||||
_currentTask = task;
|
||||
});
|
||||
}
|
||||
widget.onEdit();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showBottomSheet(BuildContext context, ProjectProvider taskState) {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return TaskBottomSheet(
|
||||
task: widget.task,
|
||||
onEdit: widget.onEdit,
|
||||
taskState: taskState,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget? buildChip() {
|
||||
if (_currentTask.projectId == null || widget.projectsMap == null) {
|
||||
return null;
|
||||
}
|
||||
Project? p = widget.projectsMap![_currentTask.projectId!];
|
||||
if (p != null) {
|
||||
return Transform(
|
||||
transform: new Matrix4.identity()..scale(0.8),
|
||||
child: Chip(
|
||||
label: Text(p.title),
|
||||
backgroundColor: p.color,
|
||||
labelStyle: TextStyle(color: Colors.white),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity: VisualDensity(horizontal: 0.0, vertical: -4),
|
||||
),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -40,8 +40,7 @@ class VikunjaDateTimePicker extends StatelessWidget {
|
|||
onSaved: onSaved,
|
||||
onChanged: onChanged,
|
||||
onShowPicker: (context, currentValue) {
|
||||
if(currentValue == null)
|
||||
currentValue = DateTime.now();
|
||||
if (currentValue == null) currentValue = DateTime.now();
|
||||
return _showDatePickerFuture(context, currentValue);
|
||||
},
|
||||
);
|
||||
|
@ -51,26 +50,22 @@ class VikunjaDateTimePicker extends StatelessWidget {
|
|||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) => DatePickerDialog(
|
||||
initialDate: currentValue.year <= 1
|
||||
? DateTime.now()
|
||||
: currentValue,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
initialCalendarMode: DatePickerMode.day,
|
||||
)).then((date) {
|
||||
if(date == null)
|
||||
return null;
|
||||
return showDialog(
|
||||
initialDate:
|
||||
currentValue.year <= 1 ? DateTime.now() : currentValue,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
initialCalendarMode: DatePickerMode.day,
|
||||
)).then((date) {
|
||||
if (date == null) return null;
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (_) =>
|
||||
TimePickerDialog(
|
||||
builder: (_) => TimePickerDialog(
|
||||
initialTime: TimeOfDay.fromDateTime(currentValue),
|
||||
)
|
||||
).then((time) {
|
||||
if(time == null)
|
||||
return null;
|
||||
return DateTime(date.year,date.month, date.day,time.hour,time.minute);
|
||||
});
|
||||
)).then((time) {
|
||||
if (time == null) return null;
|
||||
return DateTime(
|
||||
date.year, date.month, date.day, time.hour, time.minute);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,12 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
|
|||
});
|
||||
}
|
||||
|
||||
void changeUser(User newUser, {String? token, String? base}) async {
|
||||
void changeUser(
|
||||
User newUser, {
|
||||
String? token,
|
||||
String? base,
|
||||
String? xClientToken,
|
||||
}) async {
|
||||
setState(() {
|
||||
_loading = true;
|
||||
});
|
||||
|
@ -145,6 +150,16 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
|
|||
// Write new base to secure storage
|
||||
await _storage.write(key: "${newUser.id.toString()}_base", value: base);
|
||||
}
|
||||
|
||||
if (xClientToken == null) {
|
||||
xClientToken =
|
||||
await _storage.read(key: "${newUser.id.toString()}_x_client_token");
|
||||
} else {
|
||||
// Write new xClientToken to secure storage
|
||||
await _storage.write(
|
||||
key: "${newUser.id.toString()}_x_client_token", value: xClientToken);
|
||||
}
|
||||
|
||||
// Set current user in storage
|
||||
await _storage.write(key: 'currentUser', value: newUser.id.toString());
|
||||
client.configure(token: token, base: base, authenticated: true);
|
||||
|
@ -182,13 +197,20 @@ class VikunjaGlobalState extends State<VikunjaGlobal> {
|
|||
}
|
||||
var token = await _storage.read(key: currentUser);
|
||||
var base = await _storage.read(key: '${currentUser}_base');
|
||||
var xClientToken =
|
||||
await _storage.read(key: '${currentUser}_x_client_token');
|
||||
if (token == null || base == null) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
client.configure(token: token, base: base, authenticated: true);
|
||||
client.configure(
|
||||
token: token,
|
||||
base: base,
|
||||
authenticated: true,
|
||||
xClientToken: xClientToken,
|
||||
);
|
||||
User loadedCurrentUser;
|
||||
try {
|
||||
loadedCurrentUser = await UserAPIService(client).getCurrentUser();
|
||||
|
|
|
@ -47,15 +47,15 @@ class Bucket {
|
|||
.toList();
|
||||
|
||||
toJSON() => {
|
||||
'id': id,
|
||||
'list_id': projectId,
|
||||
'title': title,
|
||||
'position': position,
|
||||
'limit': limit,
|
||||
'is_done_bucket': isDoneBucket,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'updated': updated.toUtc().toIso8601String(),
|
||||
'created_by': createdBy.toJSON(),
|
||||
'tasks': tasks.map((task) => task.toJSON()).toList(),
|
||||
};
|
||||
}
|
||||
'id': id,
|
||||
'list_id': projectId,
|
||||
'title': title,
|
||||
'position': position,
|
||||
'limit': limit,
|
||||
'is_done_bucket': isDoneBucket,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'updated': updated.toUtc().toIso8601String(),
|
||||
'created_by': createdBy.toJSON(),
|
||||
'tasks': tasks.map((task) => task.toJSON()).toList(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ class Label {
|
|||
final User createdBy;
|
||||
final Color? color;
|
||||
|
||||
late final Color textColor = color != null && color!.computeLuminance() <= 0.5 ? vLabelLight : vLabelDark;
|
||||
late final Color textColor = color != null && color!.computeLuminance() <= 0.5
|
||||
? vLabelLight
|
||||
: vLabelDark;
|
||||
|
||||
Label({
|
||||
this.id = 0,
|
||||
|
|
|
@ -33,9 +33,11 @@ class TaskList {
|
|||
created = DateTime.parse(json['created']),
|
||||
isFavorite = json['is_favorite'],
|
||||
namespaceId = json['namespace_id'],
|
||||
tasks = json['tasks'] == null ? [] : (json['tasks'] as List<dynamic>)
|
||||
.map((taskJson) => Task.fromJson(taskJson))
|
||||
.toList();
|
||||
tasks = json['tasks'] == null
|
||||
? []
|
||||
: (json['tasks'] as List<dynamic>)
|
||||
.map((taskJson) => Task.fromJson(taskJson))
|
||||
.toList();
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
|
|
|
@ -17,20 +17,19 @@ class Project {
|
|||
Iterable<Project>? subprojects;
|
||||
|
||||
Project(
|
||||
{
|
||||
this.id = 0,
|
||||
this.owner,
|
||||
this.parentProjectId = 0,
|
||||
this.description = '',
|
||||
this.position = 0,
|
||||
this.doneBucketId,
|
||||
this.color,
|
||||
this.isArchived = false,
|
||||
this.isFavourite = false,
|
||||
required this.title,
|
||||
{this.id = 0,
|
||||
this.owner,
|
||||
this.parentProjectId = 0,
|
||||
this.description = '',
|
||||
this.position = 0,
|
||||
this.doneBucketId,
|
||||
this.color,
|
||||
this.isArchived = false,
|
||||
this.isFavourite = false,
|
||||
required this.title,
|
||||
created,
|
||||
updated}) :
|
||||
this.created = created ?? DateTime.now(),
|
||||
updated})
|
||||
: this.created = created ?? DateTime.now(),
|
||||
this.updated = updated ?? DateTime.now();
|
||||
|
||||
Project.fromJson(Map<String, dynamic> json)
|
||||
|
@ -50,19 +49,20 @@ class Project {
|
|||
owner = json['owner'] != null ? User.fromJson(json['owner']) : null;
|
||||
|
||||
Map<String, dynamic> toJSON() => {
|
||||
'id': id,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'updated': updated.toUtc().toIso8601String(),
|
||||
'title': title,
|
||||
'owner': owner?.toJSON(),
|
||||
'description': description,
|
||||
'parent_project_id': parentProjectId,
|
||||
'hex_color': color?.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'is_archived': isArchived,
|
||||
'is_favourite': isFavourite,
|
||||
'done_bucket_id': doneBucketId,
|
||||
'position': position
|
||||
};
|
||||
'id': id,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'updated': updated.toUtc().toIso8601String(),
|
||||
'title': title,
|
||||
'owner': owner?.toJSON(),
|
||||
'description': description,
|
||||
'parent_project_id': parentProjectId,
|
||||
'hex_color':
|
||||
color?.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'is_archived': isArchived,
|
||||
'is_favourite': isFavourite,
|
||||
'done_bucket_id': doneBucketId,
|
||||
'position': position
|
||||
};
|
||||
|
||||
Project copyWith({
|
||||
int? id,
|
||||
|
@ -77,21 +77,20 @@ class Project {
|
|||
bool? isFavourite,
|
||||
int? doneBucketId,
|
||||
double? position,
|
||||
|
||||
}) {
|
||||
return Project(
|
||||
id: id ?? this.id,
|
||||
created: created ?? this.created,
|
||||
updated: updated ?? this.updated,
|
||||
title: title ?? this.title,
|
||||
owner: owner ?? this.owner,
|
||||
description: description ?? this.description,
|
||||
parentProjectId: parentProjectId ?? this.parentProjectId,
|
||||
doneBucketId: doneBucketId ?? this.doneBucketId,
|
||||
color: color ?? this.color,
|
||||
isArchived: isArchived ?? this.isArchived,
|
||||
isFavourite: isFavourite ?? this.isFavourite,
|
||||
position: position ?? this.position,
|
||||
id: id ?? this.id,
|
||||
created: created ?? this.created,
|
||||
updated: updated ?? this.updated,
|
||||
title: title ?? this.title,
|
||||
owner: owner ?? this.owner,
|
||||
description: description ?? this.description,
|
||||
parentProjectId: parentProjectId ?? this.parentProjectId,
|
||||
doneBucketId: doneBucketId ?? this.doneBucketId,
|
||||
color: color ?? this.color,
|
||||
isArchived: isArchived ?? this.isArchived,
|
||||
isFavourite: isFavourite ?? this.isFavourite,
|
||||
position: position ?? this.position,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ class Server {
|
|||
String? version;
|
||||
|
||||
Server.fromJson(Map<String, dynamic> json)
|
||||
:
|
||||
caldavEnabled = json['caldav_enabled'],
|
||||
: caldavEnabled = json['caldav_enabled'],
|
||||
emailRemindersEnabled = json['email_reminders_enabled'],
|
||||
frontendUrl = json['frontend_url'],
|
||||
linkSharingEnabled = json['link_sharing_enabled'],
|
||||
|
@ -26,4 +25,4 @@ class Server {
|
|||
totpEnabled = json['totp_enabled'],
|
||||
userDeletion = json['user_deletion'],
|
||||
version = json['version'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ class Task {
|
|||
}
|
||||
return Colors.white;
|
||||
}
|
||||
|
||||
bool get hasDueDate => dueDate?.year != 1;
|
||||
|
||||
Task.fromJson(Map<String, dynamic> json)
|
||||
|
@ -131,7 +132,8 @@ class Task {
|
|||
'end_date': endDate?.toUtc().toIso8601String(),
|
||||
'priority': priority,
|
||||
'repeat_after': repeatAfter?.inSeconds,
|
||||
'hex_color': color?.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'hex_color':
|
||||
color?.value.toRadixString(16).padLeft(8, '0').substring(2),
|
||||
'kanban_position': kanbanPosition,
|
||||
'percent_done': percent_done,
|
||||
'project_id': projectId,
|
||||
|
|
|
@ -25,15 +25,14 @@ class TaskAttachmentFile {
|
|||
size = json['size'];
|
||||
|
||||
toJSON() => {
|
||||
'id': id,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'mime': mime,
|
||||
'name': name,
|
||||
'size': size,
|
||||
};
|
||||
'id': id,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'mime': mime,
|
||||
'name': name,
|
||||
'size': size,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
class TaskAttachment {
|
||||
final int id, taskId;
|
||||
|
@ -58,10 +57,10 @@ class TaskAttachment {
|
|||
createdBy = User.fromJson(json['created_by']);
|
||||
|
||||
toJSON() => {
|
||||
'id': id,
|
||||
'task_id': taskId,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'created_by': createdBy.toJSON(),
|
||||
'file': file.toJSON(),
|
||||
};
|
||||
}
|
||||
'id': id,
|
||||
'task_id': taskId,
|
||||
'created': created.toUtc().toIso8601String(),
|
||||
'created_by': createdBy.toJSON(),
|
||||
'file': file.toJSON(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ import 'package:vikunja_app/global.dart';
|
|||
|
||||
class UserSettings {
|
||||
final int default_project_id;
|
||||
final bool discoverable_by_email, discoverable_by_name, email_reminders_enabled;
|
||||
final bool discoverable_by_email,
|
||||
discoverable_by_name,
|
||||
email_reminders_enabled;
|
||||
final Map<String, dynamic>? frontend_settings;
|
||||
final String language;
|
||||
final String name;
|
||||
|
@ -34,24 +36,25 @@ class UserSettings {
|
|||
frontend_settings = json['frontend_settings'],
|
||||
language = json['language'],
|
||||
name = json['name'],
|
||||
overdue_tasks_reminders_enabled = json['overdue_tasks_reminders_enabled'],
|
||||
overdue_tasks_reminders_enabled =
|
||||
json['overdue_tasks_reminders_enabled'],
|
||||
overdue_tasks_reminders_time = json['overdue_tasks_reminders_time'],
|
||||
timezone = json['timezone'],
|
||||
week_start = json['week_start'];
|
||||
|
||||
toJson() => {
|
||||
'default_project_id': default_project_id,
|
||||
'discoverable_by_email': discoverable_by_email,
|
||||
'discoverable_by_name': discoverable_by_name,
|
||||
'email_reminders_enabled': email_reminders_enabled,
|
||||
'frontend_settings': frontend_settings,
|
||||
'language': language,
|
||||
'name': name,
|
||||
'overdue_tasks_reminders_enabled': overdue_tasks_reminders_enabled,
|
||||
'overdue_tasks_reminders_time': overdue_tasks_reminders_time,
|
||||
'timezone': timezone,
|
||||
'week_start': week_start,
|
||||
};
|
||||
'default_project_id': default_project_id,
|
||||
'discoverable_by_email': discoverable_by_email,
|
||||
'discoverable_by_name': discoverable_by_name,
|
||||
'email_reminders_enabled': email_reminders_enabled,
|
||||
'frontend_settings': frontend_settings,
|
||||
'language': language,
|
||||
'name': name,
|
||||
'overdue_tasks_reminders_enabled': overdue_tasks_reminders_enabled,
|
||||
'overdue_tasks_reminders_time': overdue_tasks_reminders_time,
|
||||
'timezone': timezone,
|
||||
'week_start': week_start,
|
||||
};
|
||||
|
||||
UserSettings copyWith({
|
||||
int? default_project_id,
|
||||
|
@ -68,14 +71,18 @@ class UserSettings {
|
|||
}) {
|
||||
return UserSettings(
|
||||
default_project_id: default_project_id ?? this.default_project_id,
|
||||
discoverable_by_email: discoverable_by_email ?? this.discoverable_by_email,
|
||||
discoverable_by_email:
|
||||
discoverable_by_email ?? this.discoverable_by_email,
|
||||
discoverable_by_name: discoverable_by_name ?? this.discoverable_by_name,
|
||||
email_reminders_enabled: email_reminders_enabled ?? this.email_reminders_enabled,
|
||||
email_reminders_enabled:
|
||||
email_reminders_enabled ?? this.email_reminders_enabled,
|
||||
frontend_settings: frontend_settings ?? this.frontend_settings,
|
||||
language: language ?? this.language,
|
||||
name: name ?? this.name,
|
||||
overdue_tasks_reminders_enabled: overdue_tasks_reminders_enabled ?? this.overdue_tasks_reminders_enabled,
|
||||
overdue_tasks_reminders_time: overdue_tasks_reminders_time ?? this.overdue_tasks_reminders_time,
|
||||
overdue_tasks_reminders_enabled: overdue_tasks_reminders_enabled ??
|
||||
this.overdue_tasks_reminders_enabled,
|
||||
overdue_tasks_reminders_time:
|
||||
overdue_tasks_reminders_time ?? this.overdue_tasks_reminders_time,
|
||||
timezone: timezone ?? this.timezone,
|
||||
week_start: week_start ?? this.week_start,
|
||||
);
|
||||
|
@ -104,9 +111,10 @@ class User {
|
|||
username = json['username'],
|
||||
created = DateTime.parse(json['created']),
|
||||
updated = DateTime.parse(json['updated']) {
|
||||
if(json.containsKey('settings')){
|
||||
if (json.containsKey('settings')) {
|
||||
this.settings = UserSettings.fromJson(json['settings']);
|
||||
};
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
toJSON() => {
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:vikunja_app/global.dart';
|
||||
import 'package:vikunja_app/models/project.dart';
|
||||
import 'package:vikunja_app/service/services.dart';
|
||||
|
||||
import 'dart:developer';
|
||||
|
@ -33,6 +34,7 @@ class LandingPageState extends State<LandingPage>
|
|||
int? defaultList;
|
||||
bool onlyDueDate = true;
|
||||
List<Task> _tasks = [];
|
||||
Map<int, Project> _projectsMap = {};
|
||||
PageStatus landingPageStatus = PageStatus.built;
|
||||
static const platform = const MethodChannel('vikunja');
|
||||
|
||||
|
@ -115,9 +117,10 @@ class LandingPageState extends State<LandingPage>
|
|||
body = ListView(
|
||||
scrollDirection: Axis.vertical,
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children:
|
||||
ListTile.divideTiles(context: context, tiles: _listTasks(context))
|
||||
.toList(),
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: _listTasks(context),
|
||||
).toList(),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -205,66 +208,66 @@ class LandingPageState extends State<LandingPage>
|
|||
}
|
||||
|
||||
List<Widget> _listTasks(BuildContext context) {
|
||||
var tasks = (_tasks.map((task) => _buildTile(task, context))).toList();
|
||||
//tasks.addAll(_loadingTasks.map(_buildLoadingTile));
|
||||
return tasks;
|
||||
return (_tasks.map((task) => _buildTile(task, context))).toList();
|
||||
}
|
||||
|
||||
TaskTile _buildTile(Task task, BuildContext context) {
|
||||
// key: UniqueKey() seems like a weird workaround to fix the loading issue
|
||||
// is there a better way?
|
||||
return TaskTile(
|
||||
key: UniqueKey(),
|
||||
key: Key("task_${task.id}"),
|
||||
projectsMap: _projectsMap,
|
||||
task: task,
|
||||
onEdit: () => _loadList(context),
|
||||
showInfo: true,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _loadList(BuildContext context) {
|
||||
Future<void> _loadList(BuildContext context) async {
|
||||
_tasks = [];
|
||||
_projectsMap = {};
|
||||
landingPageStatus = PageStatus.loading;
|
||||
// FIXME: loads and reschedules tasks each time list is updated
|
||||
VikunjaGlobal.of(context)
|
||||
.notifications
|
||||
.scheduleDueNotifications(VikunjaGlobal.of(context).taskService);
|
||||
return VikunjaGlobal.of(context)
|
||||
bool showOnlyDueDateTasks = await VikunjaGlobal.of(context)
|
||||
.settingsManager
|
||||
.getLandingPageOnlyDueDateTasks()
|
||||
.then((showOnlyDueDateTasks) {
|
||||
VikunjaGlobalState global = VikunjaGlobal.of(context);
|
||||
Map<String, dynamic>? frontend_settings =
|
||||
global.currentUser?.settings?.frontend_settings;
|
||||
int? filterId = 0;
|
||||
if (frontend_settings != null) {
|
||||
if (frontend_settings["filter_id_used_on_overview"] != null)
|
||||
filterId = frontend_settings["filter_id_used_on_overview"];
|
||||
}
|
||||
if (filterId != null && filterId != 0) {
|
||||
return global.taskService.getAllByProject(filterId, {
|
||||
"sort_by": ["due_date", "id"],
|
||||
"order_by": ["asc", "desc"],
|
||||
}).then<Future<void>?>((response) =>
|
||||
_handleTaskList(response?.body, showOnlyDueDateTasks));
|
||||
}
|
||||
.getLandingPageOnlyDueDateTasks();
|
||||
|
||||
return global.taskService
|
||||
.getByOptions(TaskServiceOptions(newOptions: [
|
||||
TaskServiceOption<TaskServiceOptionSortBy>(
|
||||
"sort_by", ["due_date", "id"]),
|
||||
TaskServiceOption<TaskServiceOptionSortBy>(
|
||||
"order_by", ["asc", "desc"]),
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", "done"),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>(
|
||||
"filter_value", "false"),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>(
|
||||
"filter_comparator", "equals"),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>(
|
||||
"filter_concat", "and"),
|
||||
], clearOther: true))
|
||||
.then<Future<void>?>(
|
||||
(taskList) => _handleTaskList(taskList, showOnlyDueDateTasks));
|
||||
}); //.onError((error, stackTrace) {print("error");});
|
||||
VikunjaGlobalState global = VikunjaGlobal.of(context);
|
||||
List<Project>? projects = await global.projectService.getAll();
|
||||
if (projects != null) {
|
||||
projects.forEach((project) {
|
||||
_projectsMap[project.id] = project;
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, dynamic>? frontend_settings =
|
||||
global.currentUser?.settings?.frontend_settings;
|
||||
int? filterId = 0;
|
||||
if (frontend_settings != null) {
|
||||
if (frontend_settings["filter_id_used_on_overview"] != null)
|
||||
filterId = frontend_settings["filter_id_used_on_overview"];
|
||||
}
|
||||
if (filterId != null && filterId != 0) {
|
||||
var response = await global.taskService.getAllByProject(filterId, {
|
||||
"sort_by": ["due_date", "id"],
|
||||
"order_by": ["asc", "desc"],
|
||||
});
|
||||
await _handleTaskList(response?.body, showOnlyDueDateTasks);
|
||||
return;
|
||||
}
|
||||
|
||||
var taskList =
|
||||
await global.taskService.getByOptions(TaskServiceOptions(newOptions: [
|
||||
TaskServiceOption<TaskServiceOptionSortBy>("sort_by", ["due_date", "id"]),
|
||||
TaskServiceOption<TaskServiceOptionSortBy>("order_by", ["asc", "desc"]),
|
||||
TaskServiceOption<TaskServiceOptionFilterBy>("filter_by", "done"),
|
||||
TaskServiceOption<TaskServiceOptionFilterValue>("filter_value", "false"),
|
||||
TaskServiceOption<TaskServiceOptionFilterComparator>(
|
||||
"filter_comparator", "equals"),
|
||||
TaskServiceOption<TaskServiceOptionFilterConcat>("filter_concat", "and"),
|
||||
], clearOther: true));
|
||||
await _handleTaskList(taskList, showOnlyDueDateTasks);
|
||||
}
|
||||
|
||||
Future<void> _handleTaskList(
|
||||
|
|
|
@ -65,7 +65,7 @@ class _ListPageState extends State<ListPage> {
|
|||
Widget build(BuildContext context) {
|
||||
taskState = Provider.of<ListProvider>(context);
|
||||
//_kanban = KanbanClass(
|
||||
// context, nullSetState, _onViewTapped, _addItemDialog, _list);
|
||||
// context, nullSetState, _onViewTapped, _addItemDialog, _list);
|
||||
|
||||
Widget body;
|
||||
|
||||
|
@ -126,10 +126,8 @@ class _ListPageState extends State<ListPage> {
|
|||
]);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
body = new Stack(
|
||||
children: [ListView(), Center(child: Text("This view is empty"))]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -241,8 +239,8 @@ class _ListPageState extends State<ListPage> {
|
|||
TaskTile _buildLoadingTile(Task task) {
|
||||
return TaskTile(
|
||||
task: task,
|
||||
loading: true, onEdit: () {},
|
||||
|
||||
loading: true,
|
||||
onEdit: () {},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -255,13 +253,11 @@ class _ListPageState extends State<ListPage> {
|
|||
_loadTasksForPage(1);
|
||||
break;
|
||||
case 1:
|
||||
await _kanban
|
||||
.loadBucketsForPage(1);
|
||||
await _kanban.loadBucketsForPage(1);
|
||||
// load all buckets to get length for RecordableListView
|
||||
while (_currentPage < taskState.maxPages) {
|
||||
_currentPage++;
|
||||
await _kanban
|
||||
.loadBucketsForPage(_currentPage);
|
||||
await _kanban.loadBucketsForPage(_currentPage);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -271,12 +267,11 @@ class _ListPageState extends State<ListPage> {
|
|||
}
|
||||
|
||||
Future<void> _loadTasksForPage(int page) {
|
||||
return Provider.of<ListProvider>(context, listen: false)
|
||||
.loadTasks(
|
||||
context: context,
|
||||
listId: _list.id,
|
||||
page: page,
|
||||
displayDoneTasks: displayDoneTasks);
|
||||
return Provider.of<ListProvider>(context, listen: false).loadTasks(
|
||||
context: context,
|
||||
listId: _list.id,
|
||||
page: page,
|
||||
displayDoneTasks: displayDoneTasks);
|
||||
}
|
||||
|
||||
Future<void> _addItemDialog(BuildContext context, [Bucket? bucket]) {
|
||||
|
|
|
@ -22,16 +22,18 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
late int listId;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
void initState() {
|
||||
listId = widget.list.id;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
if(displayDoneTasks == null)
|
||||
VikunjaGlobal.of(context).listService.getDisplayDoneTasks(listId).then(
|
||||
(value) => setState(() => displayDoneTasks = value == "1"));
|
||||
if (displayDoneTasks == null)
|
||||
VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.getDisplayDoneTasks(listId)
|
||||
.then((value) => setState(() => displayDoneTasks = value == "1"));
|
||||
else
|
||||
log("Display done tasks: " + displayDoneTasks.toString());
|
||||
return Scaffold(
|
||||
|
@ -43,7 +45,7 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
//reverse: true,
|
||||
//reverse: true,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
|
@ -71,10 +73,10 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
maxLines: null,
|
||||
keyboardType: TextInputType.multiline,
|
||||
initialValue: widget.list.description,
|
||||
onSaved: (description) => _description = description ?? '',
|
||||
onSaved: (description) =>
|
||||
_description = description ?? '',
|
||||
validator: (description) {
|
||||
if(description == null)
|
||||
return null;
|
||||
if (description == null) return null;
|
||||
if (description.length > 1000) {
|
||||
return 'The description can have a maximum of 1000 characters.';
|
||||
}
|
||||
|
@ -93,7 +95,9 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
title: Text("Show done tasks"),
|
||||
onChanged: (value) {
|
||||
value ??= false;
|
||||
VikunjaGlobal.of(context).listService.setDisplayDoneTasks(listId, value ? "1" : "0");
|
||||
VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.setDisplayDoneTasks(listId, value ? "1" : "0");
|
||||
setState(() => displayDoneTasks = value);
|
||||
},
|
||||
),
|
||||
|
@ -135,8 +139,7 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
},)
|
||||
],
|
||||
)*/
|
||||
]
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -84,10 +84,8 @@ class _NamespacePageState extends State<NamespacePage> {
|
|||
);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
body = new Stack(
|
||||
children: [ListView(), Center(child: Text("This view is empty"))]);
|
||||
break;
|
||||
}
|
||||
return new Scaffold(
|
||||
|
@ -112,7 +110,6 @@ class _NamespacePageState extends State<NamespacePage> {
|
|||
onPressed: () => _addListDialog(context),
|
||||
child: const Icon(Icons.add))),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -7,7 +7,8 @@ import 'package:vikunja_app/theme/buttonText.dart';
|
|||
class NamespaceEditPage extends StatefulWidget {
|
||||
final Namespace namespace;
|
||||
|
||||
NamespaceEditPage({required this.namespace}) : super(key: Key(namespace.toString()));
|
||||
NamespaceEditPage({required this.namespace})
|
||||
: super(key: Key(namespace.toString()));
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _NamespaceEditPageState();
|
||||
|
@ -63,7 +64,8 @@ class _NamespaceEditPageState extends State<NamespaceEditPage> {
|
|||
maxLines: null,
|
||||
keyboardType: TextInputType.multiline,
|
||||
initialValue: widget.namespace.description,
|
||||
onSaved: (description) => _description = description ?? '',
|
||||
onSaved: (description) =>
|
||||
_description = description ?? '',
|
||||
validator: (description) {
|
||||
//if (description.length > 1000) {
|
||||
// return 'The description can have a maximum of 1000 characters.';
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -9,7 +9,8 @@ import '../../models/project.dart';
|
|||
class ProjectEditPage extends StatefulWidget {
|
||||
final Project project;
|
||||
|
||||
ProjectEditPage({required this.project}) : super(key: Key(project.toString()));
|
||||
ProjectEditPage({required this.project})
|
||||
: super(key: Key(project.toString()));
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ProjectEditPageState();
|
||||
|
@ -23,16 +24,18 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
late int listId;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
void initState() {
|
||||
listId = widget.project.id;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
if(displayDoneTasks == null)
|
||||
VikunjaGlobal.of(context).projectService.getDisplayDoneTasks(listId).then(
|
||||
(value) => setState(() => displayDoneTasks = value == "1"));
|
||||
if (displayDoneTasks == null)
|
||||
VikunjaGlobal.of(context)
|
||||
.projectService
|
||||
.getDisplayDoneTasks(listId)
|
||||
.then((value) => setState(() => displayDoneTasks = value == "1"));
|
||||
else
|
||||
log("Display done tasks: " + displayDoneTasks.toString());
|
||||
return Scaffold(
|
||||
|
@ -44,7 +47,7 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
//reverse: true,
|
||||
//reverse: true,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
|
@ -72,10 +75,10 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
maxLines: null,
|
||||
keyboardType: TextInputType.multiline,
|
||||
initialValue: widget.project.description,
|
||||
onSaved: (description) => _description = description ?? '',
|
||||
onSaved: (description) =>
|
||||
_description = description ?? '',
|
||||
validator: (description) {
|
||||
if(description == null)
|
||||
return null;
|
||||
if (description == null) return null;
|
||||
if (description.length > 1000) {
|
||||
return 'The description can have a maximum of 1000 characters.';
|
||||
}
|
||||
|
@ -94,7 +97,9 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
title: Text("Show done tasks"),
|
||||
onChanged: (value) {
|
||||
value ??= false;
|
||||
VikunjaGlobal.of(context).listService.setDisplayDoneTasks(listId, value ? "1" : "0");
|
||||
VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.setDisplayDoneTasks(listId, value ? "1" : "0");
|
||||
setState(() => displayDoneTasks = value);
|
||||
},
|
||||
),
|
||||
|
@ -105,11 +110,11 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
child: FancyButton(
|
||||
onPressed: !_loading
|
||||
? () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
Form.of(context).save();
|
||||
_saveList(context);
|
||||
}
|
||||
}
|
||||
if (_formKey.currentState!.validate()) {
|
||||
Form.of(context).save();
|
||||
_saveList(context);
|
||||
}
|
||||
}
|
||||
: () {},
|
||||
child: _loading
|
||||
? CircularProgressIndicator()
|
||||
|
@ -136,8 +141,7 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
},)
|
||||
],
|
||||
)*/
|
||||
]
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -148,10 +152,8 @@ class _ProjectEditPageState extends State<ProjectEditPage> {
|
|||
setState(() => _loading = true);
|
||||
// FIXME: is there a way we can update the list without creating a new list object?
|
||||
// aka updating the existing list we got from context (setters?)
|
||||
Project newProject = widget.project.copyWith(
|
||||
title: _title,
|
||||
description: _description
|
||||
);
|
||||
Project newProject =
|
||||
widget.project.copyWith(title: _title, description: _description);
|
||||
VikunjaGlobal.of(context).projectService.update(newProject).then((_) {
|
||||
setState(() => _loading = false);
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
|
|
|
@ -95,42 +95,42 @@ class _ListPageState extends State<ListPage> {
|
|||
]);
|
||||
break;
|
||||
case PageStatus.success:
|
||||
body = taskState.tasks.length > 0 || taskState.buckets.length > 0 || _project.subprojects!.length > 0
|
||||
body = taskState.tasks.length > 0 ||
|
||||
taskState.buckets.length > 0 ||
|
||||
_project.subprojects!.length > 0
|
||||
? ListenableProvider.value(
|
||||
value: taskState,
|
||||
child: Theme(
|
||||
data: (ThemeData base) {
|
||||
return base.copyWith(
|
||||
chipTheme: base.chipTheme.copyWith(
|
||||
labelPadding: EdgeInsets.symmetric(horizontal: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
),
|
||||
value: taskState,
|
||||
child: Theme(
|
||||
data: (ThemeData base) {
|
||||
return base.copyWith(
|
||||
chipTheme: base.chipTheme.copyWith(
|
||||
labelPadding: EdgeInsets.symmetric(horizontal: 2),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}(Theme.of(context)),
|
||||
child: () {
|
||||
switch (_viewIndex) {
|
||||
case 0:
|
||||
return _listView(context);
|
||||
case 1:
|
||||
return _kanban.kanbanView();
|
||||
default:
|
||||
return _listView(context);
|
||||
}
|
||||
}(),
|
||||
),
|
||||
);
|
||||
}(Theme.of(context)),
|
||||
child: () {
|
||||
switch (_viewIndex) {
|
||||
case 0:
|
||||
return _listView(context);
|
||||
case 1:
|
||||
return _kanban.kanbanView();
|
||||
default:
|
||||
return _listView(context);
|
||||
}
|
||||
}(),
|
||||
),
|
||||
)
|
||||
)
|
||||
: Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text('This list is empty.'))
|
||||
]);
|
||||
ListView(),
|
||||
Center(child: Text('This list is empty.'))
|
||||
]);
|
||||
break;
|
||||
case PageStatus.empty:
|
||||
body = new Stack(children: [
|
||||
ListView(),
|
||||
Center(child: Text("This view is empty"))
|
||||
]);
|
||||
body = new Stack(
|
||||
children: [ListView(), Center(child: Text("This view is empty"))]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -154,10 +154,10 @@ class _ListPageState extends State<ListPage> {
|
|||
floatingActionButton: _viewIndex == 1
|
||||
? null
|
||||
: Builder(
|
||||
builder: (context) => FloatingActionButton(
|
||||
onPressed: () => _addItemDialog(context),
|
||||
child: Icon(Icons.add)),
|
||||
),
|
||||
builder: (context) => FloatingActionButton(
|
||||
onPressed: () => _addItemDialog(context),
|
||||
child: Icon(Icons.add)),
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
items: const <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
|
@ -181,22 +181,23 @@ class _ListPageState extends State<ListPage> {
|
|||
return Container(
|
||||
height: 80,
|
||||
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
child:
|
||||
ListView(
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
...?widget.project.subprojects?.map((elem) =>
|
||||
InkWell(
|
||||
onTap: () {openList(context, elem);},
|
||||
child:
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
height: 20,
|
||||
width: 100,
|
||||
child:
|
||||
Text(elem.title, overflow: TextOverflow.ellipsis,softWrap: false,)))
|
||||
),
|
||||
...?widget.project.subprojects?.map((elem) => InkWell(
|
||||
onTap: () {
|
||||
openList(context, elem);
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 20,
|
||||
width: 100,
|
||||
child: Text(
|
||||
elem.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
)))),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -213,39 +214,50 @@ class _ListPageState extends State<ListPage> {
|
|||
|
||||
Widget _listView(BuildContext context) {
|
||||
List<Widget> children = [];
|
||||
if(widget.project.subprojects?.length != 0) {
|
||||
children.add(Padding(child: Text("Projects", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||
if (widget.project.subprojects?.length != 0) {
|
||||
children.add(Padding(
|
||||
child: Text(
|
||||
"Projects",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
||||
));
|
||||
children.add(buildSubProjectSelector());
|
||||
|
||||
}
|
||||
if(taskState.tasks.length != 0) {
|
||||
children.add(Padding(child: Text("Tasks", style: TextStyle(fontWeight: FontWeight.bold),), padding: EdgeInsets.fromLTRB(0, 10, 0, 0),));
|
||||
if (taskState.tasks.length != 0) {
|
||||
children.add(Padding(
|
||||
child: Text(
|
||||
"Tasks",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
|
||||
));
|
||||
children.add(Divider());
|
||||
children.add(Expanded(child:
|
||||
ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
itemCount: taskState.tasks.length * 2,
|
||||
itemBuilder: (context, i) {
|
||||
if (i.isOdd) return Divider();
|
||||
children.add(Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
itemCount: taskState.tasks.length * 2,
|
||||
itemBuilder: (context, i) {
|
||||
if (i.isOdd) return Divider();
|
||||
|
||||
if (_loadingTasks.isNotEmpty) {
|
||||
final loadingTask = _loadingTasks.removeLast();
|
||||
return _buildLoadingTile(loadingTask);
|
||||
}
|
||||
if (_loadingTasks.isNotEmpty) {
|
||||
final loadingTask = _loadingTasks.removeLast();
|
||||
return _buildLoadingTile(loadingTask);
|
||||
}
|
||||
|
||||
final index = i ~/ 2;
|
||||
final index = i ~/ 2;
|
||||
|
||||
if (taskState.maxPages == _currentPage &&
|
||||
index == taskState.tasks.length)
|
||||
throw Exception("Check itemCount attribute");
|
||||
if (taskState.maxPages == _currentPage &&
|
||||
index == taskState.tasks.length)
|
||||
throw Exception("Check itemCount attribute");
|
||||
|
||||
if (index >= taskState.tasks.length &&
|
||||
_currentPage < taskState.maxPages) {
|
||||
_currentPage++;
|
||||
_loadTasksForPage(_currentPage);
|
||||
}
|
||||
return _buildTile(taskState.tasks[index]);
|
||||
})));
|
||||
if (index >= taskState.tasks.length &&
|
||||
_currentPage < taskState.maxPages) {
|
||||
_currentPage++;
|
||||
_loadTasksForPage(_currentPage);
|
||||
}
|
||||
return _buildTile(taskState.tasks[index]);
|
||||
})));
|
||||
}
|
||||
|
||||
return Column(children: children);
|
||||
|
@ -302,13 +314,11 @@ class _ListPageState extends State<ListPage> {
|
|||
_loadTasksForPage(1);
|
||||
break;
|
||||
case 1:
|
||||
await _kanban
|
||||
.loadBucketsForPage(1);
|
||||
await _kanban.loadBucketsForPage(1);
|
||||
// load all buckets to get length for RecordableListView
|
||||
while (_currentPage < taskState.maxPages) {
|
||||
_currentPage++;
|
||||
await _kanban
|
||||
.loadBucketsForPage(_currentPage);
|
||||
await _kanban.loadBucketsForPage(_currentPage);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -318,8 +328,7 @@ class _ListPageState extends State<ListPage> {
|
|||
}
|
||||
|
||||
Future<void> _loadTasksForPage(int page) {
|
||||
return Provider.of<ProjectProvider>(context, listen: false)
|
||||
.loadTasks(
|
||||
return Provider.of<ProjectProvider>(context, listen: false).loadTasks(
|
||||
context: context,
|
||||
listId: _project.id,
|
||||
page: page,
|
||||
|
@ -333,7 +342,7 @@ class _ListPageState extends State<ListPage> {
|
|||
onAdd: (title) => _addItem(title, context, bucket),
|
||||
decoration: InputDecoration(
|
||||
labelText:
|
||||
(bucket != null ? '\'${bucket.title}\': ' : '') + 'New Task Name',
|
||||
(bucket != null ? '\'${bucket.title}\': ' : '') + 'New Task Name',
|
||||
hintText: 'eg. Milk',
|
||||
),
|
||||
),
|
||||
|
@ -375,7 +384,6 @@ class _ListPageState extends State<ListPage> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
openList(BuildContext context, Project project) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (context) => ChangeNotifierProvider<ProjectProvider>(
|
||||
|
@ -386,4 +394,4 @@ openList(BuildContext context, Project project) {
|
|||
),
|
||||
// ListPage(taskList: list)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -357,7 +357,12 @@ class _LoginPageState extends State<LoginPage> {
|
|||
}
|
||||
|
||||
if (newUser.error == 0)
|
||||
vGlobal.changeUser(newUser.user!, token: newUser.token, base: _server);
|
||||
vGlobal.changeUser(
|
||||
newUser.user!,
|
||||
token: newUser.token,
|
||||
base: _server,
|
||||
xClientToken: _xClientToken,
|
||||
);
|
||||
} catch (ex) {
|
||||
print(ex);
|
||||
} finally {
|
||||
|
|
|
@ -127,10 +127,9 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
setState(() => _loading = true);
|
||||
try {
|
||||
var vGlobal = VikunjaGlobal.of(context);
|
||||
var newUserLoggedIn = await vGlobal
|
||||
.newUserService
|
||||
?.register(_username!, _email, _password);
|
||||
if(newUserLoggedIn != null)
|
||||
var newUserLoggedIn =
|
||||
await vGlobal.newUserService?.register(_username!, _email, _password);
|
||||
if (newUserLoggedIn != null)
|
||||
vGlobal.changeUser(newUserLoggedIn.user!,
|
||||
token: newUserLoggedIn.token, base: _server!);
|
||||
} catch (ex) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vikunja_app/models/task.dart';
|
||||
import 'package:vikunja_app/models/bucket.dart';
|
||||
|
@ -15,7 +14,6 @@ class ListProvider with ChangeNotifier {
|
|||
List<Task> _tasks = [];
|
||||
List<Bucket> _buckets = [];
|
||||
|
||||
|
||||
bool get taskDragging => _taskDragging;
|
||||
|
||||
set taskDragging(bool value) {
|
||||
|
@ -39,7 +37,6 @@ class ListProvider with ChangeNotifier {
|
|||
|
||||
List<Bucket> get buckets => _buckets;
|
||||
|
||||
|
||||
PageStatus _pageStatus = PageStatus.built;
|
||||
|
||||
PageStatus get pageStatus => _pageStatus;
|
||||
|
@ -50,7 +47,11 @@ class ListProvider with ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> loadTasks({required BuildContext context, required int listId, int page = 1, bool displayDoneTasks = true}) {
|
||||
Future<void> loadTasks(
|
||||
{required BuildContext context,
|
||||
required int listId,
|
||||
int page = 1,
|
||||
bool displayDoneTasks = true}) {
|
||||
_tasks = [];
|
||||
notifyListeners();
|
||||
|
||||
|
@ -60,7 +61,7 @@ class ListProvider with ChangeNotifier {
|
|||
"page": [page.toString()]
|
||||
};
|
||||
|
||||
if(!displayDoneTasks) {
|
||||
if (!displayDoneTasks) {
|
||||
queryParams.addAll({
|
||||
"filter_by": ["done"],
|
||||
"filter_value": ["false"]
|
||||
|
@ -81,7 +82,8 @@ class ListProvider with ChangeNotifier {
|
|||
});*/
|
||||
}
|
||||
|
||||
Future<void> loadBuckets({required BuildContext context, required int listId, int page = 1}) {
|
||||
Future<void> loadBuckets(
|
||||
{required BuildContext context, required int listId, int page = 1}) {
|
||||
_buckets = [];
|
||||
pageStatus = PageStatus.loading;
|
||||
notifyListeners();
|
||||
|
@ -90,8 +92,11 @@ class ListProvider with ChangeNotifier {
|
|||
"page": [page.toString()]
|
||||
};
|
||||
|
||||
return VikunjaGlobal.of(context).bucketService.getAllByList(listId, queryParams).then((response) {
|
||||
if(response == null) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.getAllByList(listId, queryParams)
|
||||
.then((response) {
|
||||
if (response == null) {
|
||||
pageStatus = PageStatus.error;
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +110,9 @@ class ListProvider with ChangeNotifier {
|
|||
}
|
||||
|
||||
Future<void> addTaskByTitle(
|
||||
{required BuildContext context, required String title, required int listId}) async{
|
||||
{required BuildContext context,
|
||||
required String title,
|
||||
required int listId}) async {
|
||||
final globalState = VikunjaGlobal.of(context);
|
||||
if (globalState.currentUser == null) {
|
||||
return;
|
||||
|
@ -120,13 +127,15 @@ class ListProvider with ChangeNotifier {
|
|||
pageStatus = PageStatus.loading;
|
||||
|
||||
return globalState.taskService.add(listId, newTask).then((task) {
|
||||
if(task != null)
|
||||
_tasks.insert(0, task);
|
||||
if (task != null) _tasks.insert(0, task);
|
||||
pageStatus = PageStatus.success;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> addTask({required BuildContext context, required Task newTask, required int listId}) {
|
||||
Future<void> addTask(
|
||||
{required BuildContext context,
|
||||
required Task newTask,
|
||||
required int listId}) {
|
||||
var globalState = VikunjaGlobal.of(context);
|
||||
if (newTask.bucketId == null) pageStatus = PageStatus.loading;
|
||||
notifyListeners();
|
||||
|
@ -136,107 +145,129 @@ class ListProvider with ChangeNotifier {
|
|||
pageStatus = PageStatus.error;
|
||||
return;
|
||||
}
|
||||
if (_tasks.isNotEmpty)
|
||||
_tasks.insert(0, task);
|
||||
if (_tasks.isNotEmpty) _tasks.insert(0, task);
|
||||
if (_buckets.isNotEmpty) {
|
||||
final bucket = _buckets[_buckets.indexWhere((b) => task.bucketId == b.id)];
|
||||
final bucket =
|
||||
_buckets[_buckets.indexWhere((b) => task.bucketId == b.id)];
|
||||
bucket.tasks.add(task);
|
||||
}
|
||||
pageStatus = PageStatus.success;
|
||||
});
|
||||
}
|
||||
|
||||
Future<Task?> updateTask({required BuildContext context, required Task task}) {
|
||||
Future<Task?> updateTask(
|
||||
{required BuildContext context, required Task task}) {
|
||||
return VikunjaGlobal.of(context).taskService.update(task).then((task) {
|
||||
// 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 definitely fix it later.
|
||||
if(task == null)
|
||||
return null;
|
||||
if (task == null) return null;
|
||||
_tasks.asMap().forEach((i, t) {
|
||||
if (task.id == t.id) {
|
||||
_tasks[i] = task;
|
||||
}
|
||||
});
|
||||
_buckets.asMap().forEach((i, b) => b.tasks.asMap().forEach((v, t) {
|
||||
if (task.id == t.id){
|
||||
_buckets[i].tasks[v] = task;
|
||||
}
|
||||
}));
|
||||
if (task.id == t.id) {
|
||||
_buckets[i].tasks[v] = task;
|
||||
}
|
||||
}));
|
||||
notifyListeners();
|
||||
return task;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> addBucket({required BuildContext context, required Bucket newBucket, required int listId}) {
|
||||
Future<void> addBucket(
|
||||
{required BuildContext context,
|
||||
required Bucket newBucket,
|
||||
required int listId}) {
|
||||
notifyListeners();
|
||||
return VikunjaGlobal.of(context).bucketService.add(listId, newBucket)
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.add(listId, newBucket)
|
||||
.then((bucket) {
|
||||
if(bucket == null)
|
||||
return null;
|
||||
_buckets.add(bucket);
|
||||
notifyListeners();
|
||||
});
|
||||
if (bucket == null) return null;
|
||||
_buckets.add(bucket);
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> updateBucket({required BuildContext context, required Bucket bucket}) {
|
||||
return VikunjaGlobal.of(context).bucketService.update(bucket)
|
||||
Future<void> updateBucket(
|
||||
{required BuildContext context, required Bucket bucket}) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.update(bucket)
|
||||
.then((rBucket) {
|
||||
if(rBucket == null)
|
||||
return null;
|
||||
_buckets[_buckets.indexWhere((b) => rBucket.id == b.id)] = rBucket;
|
||||
_buckets.sort((a, b) => a.position!.compareTo(b.position!));
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> deleteBucket({required BuildContext context, required int listId, required int bucketId}) {
|
||||
return VikunjaGlobal.of(context).bucketService.delete(listId, bucketId)
|
||||
.then((_) {
|
||||
_buckets.removeWhere((bucket) => bucket.id == bucketId);
|
||||
notifyListeners();
|
||||
});
|
||||
if (rBucket == null) return null;
|
||||
_buckets[_buckets.indexWhere((b) => rBucket.id == b.id)] = rBucket;
|
||||
_buckets.sort((a, b) => a.position!.compareTo(b.position!));
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> moveTaskToBucket({required BuildContext context, required Task? task, int? newBucketId, required int index}) async {
|
||||
if(task == null)
|
||||
throw Exception("Task to be moved may not be null");
|
||||
Future<void> deleteBucket(
|
||||
{required BuildContext context,
|
||||
required int listId,
|
||||
required int bucketId}) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.delete(listId, bucketId)
|
||||
.then((_) {
|
||||
_buckets.removeWhere((bucket) => bucket.id == bucketId);
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> moveTaskToBucket(
|
||||
{required BuildContext context,
|
||||
required Task? task,
|
||||
int? newBucketId,
|
||||
required int index}) async {
|
||||
if (task == null) throw Exception("Task to be moved may not be null");
|
||||
final sameBucket = task.bucketId == newBucketId;
|
||||
final newBucketIndex = _buckets.indexWhere((b) => b.id == newBucketId);
|
||||
if (sameBucket && index > _buckets[newBucketIndex].tasks.indexWhere((t) => t.id == task?.id)) index--;
|
||||
if (sameBucket &&
|
||||
index >
|
||||
_buckets[newBucketIndex].tasks.indexWhere((t) => t.id == task?.id))
|
||||
index--;
|
||||
|
||||
_buckets[_buckets.indexWhere((b) => b.id == task?.bucketId)].tasks.remove(task);
|
||||
_buckets[_buckets.indexWhere((b) => b.id == task?.bucketId)]
|
||||
.tasks
|
||||
.remove(task);
|
||||
if (index >= _buckets[newBucketIndex].tasks.length)
|
||||
_buckets[newBucketIndex].tasks.add(task);
|
||||
else
|
||||
_buckets[newBucketIndex].tasks.insert(index, task);
|
||||
|
||||
task = await VikunjaGlobal.of(context).taskService.update(task.copyWith(
|
||||
bucketId: newBucketId,
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: index != 0
|
||||
? _buckets[newBucketIndex].tasks[index - 1].kanbanPosition : null,
|
||||
positionAfter: index < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[index + 1].kanbanPosition : null,
|
||||
),
|
||||
));
|
||||
if(task == null)
|
||||
return;
|
||||
bucketId: newBucketId,
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: index != 0
|
||||
? _buckets[newBucketIndex].tasks[index - 1].kanbanPosition
|
||||
: null,
|
||||
positionAfter: index < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[index + 1].kanbanPosition
|
||||
: null,
|
||||
),
|
||||
));
|
||||
if (task == null) return;
|
||||
_buckets[newBucketIndex].tasks[index] = task;
|
||||
|
||||
// make sure the first 2 tasks don't have 0 kanbanPosition
|
||||
Task? secondTask;
|
||||
if (index == 0 && _buckets[newBucketIndex].tasks.length > 1
|
||||
&& _buckets[newBucketIndex].tasks[1].kanbanPosition == 0) {
|
||||
secondTask = await VikunjaGlobal.of(context).taskService.update(
|
||||
_buckets[newBucketIndex].tasks[1].copyWith(
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: task.kanbanPosition,
|
||||
positionAfter: 1 < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[2].kanbanPosition : null,
|
||||
),
|
||||
));
|
||||
if(secondTask != null)
|
||||
_buckets[newBucketIndex].tasks[1] = secondTask;
|
||||
if (index == 0 &&
|
||||
_buckets[newBucketIndex].tasks.length > 1 &&
|
||||
_buckets[newBucketIndex].tasks[1].kanbanPosition == 0) {
|
||||
secondTask = await VikunjaGlobal.of(context)
|
||||
.taskService
|
||||
.update(_buckets[newBucketIndex].tasks[1].copyWith(
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: task.kanbanPosition,
|
||||
positionAfter: 1 < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[2].kanbanPosition
|
||||
: null,
|
||||
),
|
||||
));
|
||||
if (secondTask != null) _buckets[newBucketIndex].tasks[1] = secondTask;
|
||||
}
|
||||
|
||||
if (_tasks.isNotEmpty) {
|
||||
|
@ -245,8 +276,12 @@ class ListProvider with ChangeNotifier {
|
|||
_tasks[_tasks.indexWhere((t) => t.id == secondTask!.id)] = secondTask;
|
||||
}
|
||||
|
||||
_buckets[newBucketIndex].tasks[_buckets[newBucketIndex].tasks.indexWhere((t) => t.id == task?.id)] = task;
|
||||
_buckets[newBucketIndex].tasks.sort((a, b) => a.kanbanPosition!.compareTo(b.kanbanPosition!));
|
||||
_buckets[newBucketIndex].tasks[_buckets[newBucketIndex]
|
||||
.tasks
|
||||
.indexWhere((t) => t.id == task?.id)] = task;
|
||||
_buckets[newBucketIndex]
|
||||
.tasks
|
||||
.sort((a, b) => a.kanbanPosition!.compareTo(b.kanbanPosition!));
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ class ProjectProvider with ChangeNotifier {
|
|||
List<Task> _tasks = [];
|
||||
List<Bucket> _buckets = [];
|
||||
|
||||
|
||||
bool get taskDragging => _taskDragging;
|
||||
|
||||
set taskDragging(bool value) {
|
||||
|
@ -38,7 +37,6 @@ class ProjectProvider with ChangeNotifier {
|
|||
|
||||
List<Bucket> get buckets => _buckets;
|
||||
|
||||
|
||||
PageStatus _pageStatus = PageStatus.built;
|
||||
|
||||
PageStatus get pageStatus => _pageStatus;
|
||||
|
@ -49,7 +47,11 @@ class ProjectProvider with ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> loadTasks({required BuildContext context, required int listId, int page = 1, bool displayDoneTasks = true}) {
|
||||
Future<void> loadTasks(
|
||||
{required BuildContext context,
|
||||
required int listId,
|
||||
int page = 1,
|
||||
bool displayDoneTasks = true}) {
|
||||
_tasks = [];
|
||||
notifyListeners();
|
||||
|
||||
|
@ -59,15 +61,18 @@ class ProjectProvider with ChangeNotifier {
|
|||
"page": [page.toString()]
|
||||
};
|
||||
|
||||
if(!displayDoneTasks) {
|
||||
if (!displayDoneTasks) {
|
||||
queryParams.addAll({
|
||||
"filter_by": ["done"],
|
||||
"filter_value": ["false"],
|
||||
"sort_by": ["done"],
|
||||
});
|
||||
}
|
||||
return VikunjaGlobal.of(context).taskService.getAllByProject(listId, queryParams).then((response) {
|
||||
if(response == null) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.taskService
|
||||
.getAllByProject(listId, queryParams)
|
||||
.then((response) {
|
||||
if (response == null) {
|
||||
pageStatus = PageStatus.error;
|
||||
return;
|
||||
}
|
||||
|
@ -79,7 +84,8 @@ class ProjectProvider with ChangeNotifier {
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> loadBuckets({required BuildContext context, required int listId, int page = 1}) {
|
||||
Future<void> loadBuckets(
|
||||
{required BuildContext context, required int listId, int page = 1}) {
|
||||
_buckets = [];
|
||||
pageStatus = PageStatus.loading;
|
||||
notifyListeners();
|
||||
|
@ -88,8 +94,11 @@ class ProjectProvider with ChangeNotifier {
|
|||
"page": [page.toString()]
|
||||
};
|
||||
|
||||
return VikunjaGlobal.of(context).bucketService.getAllByList(listId, queryParams).then((response) {
|
||||
if(response == null) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.getAllByList(listId, queryParams)
|
||||
.then((response) {
|
||||
if (response == null) {
|
||||
pageStatus = PageStatus.error;
|
||||
return;
|
||||
}
|
||||
|
@ -103,7 +112,9 @@ class ProjectProvider with ChangeNotifier {
|
|||
}
|
||||
|
||||
Future<void> addTaskByTitle(
|
||||
{required BuildContext context, required String title, required int projectId}) async{
|
||||
{required BuildContext context,
|
||||
required String title,
|
||||
required int projectId}) async {
|
||||
final globalState = VikunjaGlobal.of(context);
|
||||
if (globalState.currentUser == null) {
|
||||
return;
|
||||
|
@ -118,13 +129,15 @@ class ProjectProvider with ChangeNotifier {
|
|||
pageStatus = PageStatus.loading;
|
||||
|
||||
return globalState.taskService.add(projectId, newTask).then((task) {
|
||||
if(task != null)
|
||||
_tasks.insert(0, task);
|
||||
if (task != null) _tasks.insert(0, task);
|
||||
pageStatus = PageStatus.success;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> addTask({required BuildContext context, required Task newTask, required int listId}) {
|
||||
Future<void> addTask(
|
||||
{required BuildContext context,
|
||||
required Task newTask,
|
||||
required int listId}) {
|
||||
var globalState = VikunjaGlobal.of(context);
|
||||
if (newTask.bucketId == null) pageStatus = PageStatus.loading;
|
||||
notifyListeners();
|
||||
|
@ -134,107 +147,129 @@ class ProjectProvider with ChangeNotifier {
|
|||
pageStatus = PageStatus.error;
|
||||
return;
|
||||
}
|
||||
if (_tasks.isNotEmpty)
|
||||
_tasks.insert(0, task);
|
||||
if (_tasks.isNotEmpty) _tasks.insert(0, task);
|
||||
if (_buckets.isNotEmpty) {
|
||||
final bucket = _buckets[_buckets.indexWhere((b) => task.bucketId == b.id)];
|
||||
final bucket =
|
||||
_buckets[_buckets.indexWhere((b) => task.bucketId == b.id)];
|
||||
bucket.tasks.add(task);
|
||||
}
|
||||
pageStatus = PageStatus.success;
|
||||
});
|
||||
}
|
||||
|
||||
Future<Task?> updateTask({required BuildContext context, required Task task}) {
|
||||
Future<Task?> updateTask(
|
||||
{required BuildContext context, required Task task}) {
|
||||
return VikunjaGlobal.of(context).taskService.update(task).then((task) {
|
||||
// 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 definitely fix it later.
|
||||
if(task == null)
|
||||
return null;
|
||||
if (task == null) return null;
|
||||
_tasks.asMap().forEach((i, t) {
|
||||
if (task.id == t.id) {
|
||||
_tasks[i] = task;
|
||||
}
|
||||
});
|
||||
_buckets.asMap().forEach((i, b) => b.tasks.asMap().forEach((v, t) {
|
||||
if (task.id == t.id){
|
||||
_buckets[i].tasks[v] = task;
|
||||
}
|
||||
}));
|
||||
if (task.id == t.id) {
|
||||
_buckets[i].tasks[v] = task;
|
||||
}
|
||||
}));
|
||||
notifyListeners();
|
||||
return task;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> addBucket({required BuildContext context, required Bucket newBucket, required int listId}) {
|
||||
Future<void> addBucket(
|
||||
{required BuildContext context,
|
||||
required Bucket newBucket,
|
||||
required int listId}) {
|
||||
notifyListeners();
|
||||
return VikunjaGlobal.of(context).bucketService.add(listId, newBucket)
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.add(listId, newBucket)
|
||||
.then((bucket) {
|
||||
if(bucket == null)
|
||||
return null;
|
||||
if (bucket == null) return null;
|
||||
_buckets.add(bucket);
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> updateBucket({required BuildContext context, required Bucket bucket}) {
|
||||
return VikunjaGlobal.of(context).bucketService.update(bucket)
|
||||
Future<void> updateBucket(
|
||||
{required BuildContext context, required Bucket bucket}) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.update(bucket)
|
||||
.then((rBucket) {
|
||||
if(rBucket == null)
|
||||
return null;
|
||||
if (rBucket == null) return null;
|
||||
_buckets[_buckets.indexWhere((b) => rBucket.id == b.id)] = rBucket;
|
||||
_buckets.sort((a, b) => a.position!.compareTo(b.position!));
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> deleteBucket({required BuildContext context, required int listId, required int bucketId}) {
|
||||
return VikunjaGlobal.of(context).bucketService.delete(listId, bucketId)
|
||||
Future<void> deleteBucket(
|
||||
{required BuildContext context,
|
||||
required int listId,
|
||||
required int bucketId}) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.bucketService
|
||||
.delete(listId, bucketId)
|
||||
.then((_) {
|
||||
_buckets.removeWhere((bucket) => bucket.id == bucketId);
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> moveTaskToBucket({required BuildContext context, required Task? task, int? newBucketId, required int index}) async {
|
||||
if(task == null)
|
||||
throw Exception("Task to be moved may not be null");
|
||||
Future<void> moveTaskToBucket(
|
||||
{required BuildContext context,
|
||||
required Task? task,
|
||||
int? newBucketId,
|
||||
required int index}) async {
|
||||
if (task == null) throw Exception("Task to be moved may not be null");
|
||||
final sameBucket = task.bucketId == newBucketId;
|
||||
final newBucketIndex = _buckets.indexWhere((b) => b.id == newBucketId);
|
||||
if (sameBucket && index > _buckets[newBucketIndex].tasks.indexWhere((t) => t.id == task?.id)) index--;
|
||||
if (sameBucket &&
|
||||
index >
|
||||
_buckets[newBucketIndex].tasks.indexWhere((t) => t.id == task?.id))
|
||||
index--;
|
||||
|
||||
_buckets[_buckets.indexWhere((b) => b.id == task?.bucketId)].tasks.remove(task);
|
||||
_buckets[_buckets.indexWhere((b) => b.id == task?.bucketId)]
|
||||
.tasks
|
||||
.remove(task);
|
||||
if (index >= _buckets[newBucketIndex].tasks.length)
|
||||
_buckets[newBucketIndex].tasks.add(task);
|
||||
else
|
||||
_buckets[newBucketIndex].tasks.insert(index, task);
|
||||
|
||||
task = await VikunjaGlobal.of(context).taskService.update(task.copyWith(
|
||||
bucketId: newBucketId,
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: index != 0
|
||||
? _buckets[newBucketIndex].tasks[index - 1].kanbanPosition : null,
|
||||
positionAfter: index < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[index + 1].kanbanPosition : null,
|
||||
),
|
||||
));
|
||||
if(task == null)
|
||||
return;
|
||||
bucketId: newBucketId,
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: index != 0
|
||||
? _buckets[newBucketIndex].tasks[index - 1].kanbanPosition
|
||||
: null,
|
||||
positionAfter: index < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[index + 1].kanbanPosition
|
||||
: null,
|
||||
),
|
||||
));
|
||||
if (task == null) return;
|
||||
_buckets[newBucketIndex].tasks[index] = task;
|
||||
|
||||
// make sure the first 2 tasks don't have 0 kanbanPosition
|
||||
Task? secondTask;
|
||||
if (index == 0 && _buckets[newBucketIndex].tasks.length > 1
|
||||
&& _buckets[newBucketIndex].tasks[1].kanbanPosition == 0) {
|
||||
secondTask = await VikunjaGlobal.of(context).taskService.update(
|
||||
_buckets[newBucketIndex].tasks[1].copyWith(
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: task.kanbanPosition,
|
||||
positionAfter: 1 < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[2].kanbanPosition : null,
|
||||
),
|
||||
));
|
||||
if(secondTask != null)
|
||||
_buckets[newBucketIndex].tasks[1] = secondTask;
|
||||
if (index == 0 &&
|
||||
_buckets[newBucketIndex].tasks.length > 1 &&
|
||||
_buckets[newBucketIndex].tasks[1].kanbanPosition == 0) {
|
||||
secondTask = await VikunjaGlobal.of(context)
|
||||
.taskService
|
||||
.update(_buckets[newBucketIndex].tasks[1].copyWith(
|
||||
kanbanPosition: calculateItemPosition(
|
||||
positionBefore: task.kanbanPosition,
|
||||
positionAfter: 1 < _buckets[newBucketIndex].tasks.length - 1
|
||||
? _buckets[newBucketIndex].tasks[2].kanbanPosition
|
||||
: null,
|
||||
),
|
||||
));
|
||||
if (secondTask != null) _buckets[newBucketIndex].tasks[1] = secondTask;
|
||||
}
|
||||
|
||||
if (_tasks.isNotEmpty) {
|
||||
|
@ -243,8 +278,12 @@ class ProjectProvider with ChangeNotifier {
|
|||
_tasks[_tasks.indexWhere((t) => t.id == secondTask!.id)] = secondTask;
|
||||
}
|
||||
|
||||
_buckets[newBucketIndex].tasks[_buckets[newBucketIndex].tasks.indexWhere((t) => t.id == task?.id)] = task;
|
||||
_buckets[newBucketIndex].tasks.sort((a, b) => a.kanbanPosition!.compareTo(b.kanbanPosition!));
|
||||
_buckets[newBucketIndex].tasks[_buckets[newBucketIndex]
|
||||
.tasks
|
||||
.indexWhere((t) => t.id == task?.id)] = task;
|
||||
_buckets[newBucketIndex]
|
||||
.tasks
|
||||
.sort((a, b) => a.kanbanPosition!.compareTo(b.kanbanPosition!));
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
@ -17,11 +17,13 @@ class FancyButton extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(onPressed: onPressed,
|
||||
return ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: Center(child: child),
|
||||
),);
|
||||
),
|
||||
);
|
||||
return Padding(
|
||||
padding: vStandardVerticalPadding,
|
||||
child: Container(
|
||||
|
|
|
@ -13,7 +13,9 @@ class VikunjaButtonText extends StatelessWidget {
|
|||
return Text(text);
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(color: Theme.of(context).primaryTextTheme.labelMedium?.color, fontWeight: FontWeight.w600),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryTextTheme.labelMedium?.color,
|
||||
fontWeight: FontWeight.w600),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,4 +31,4 @@ const vStandardHorizontalPadding = EdgeInsets.symmetric(horizontal: 5.0);
|
|||
const vStandardPadding = EdgeInsets.symmetric(horizontal: 5.0, vertical: 5.0);
|
||||
|
||||
var vDateFormatLong = DateFormat("EEEE, MMMM d, yyyy 'at' H:mm");
|
||||
var vDateFormatShort = DateFormat("d MMM yyyy, H:mm");
|
||||
var vDateFormatShort = DateFormat("d MMM yyyy, H:mm");
|
||||
|
|
|
@ -4,17 +4,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:vikunja_app/theme/constants.dart';
|
||||
|
||||
ThemeData buildVikunjaTheme() => _buildVikunjaTheme(ThemeData.light());
|
||||
ThemeData buildVikunjaDarkTheme() => _buildVikunjaTheme(ThemeData.dark(), isDark: true);
|
||||
ThemeData buildVikunjaDarkTheme() =>
|
||||
_buildVikunjaTheme(ThemeData.dark(), isDark: true);
|
||||
|
||||
ThemeData buildVikunjaMaterialLightTheme() {
|
||||
return ThemeData.light().copyWith(
|
||||
|
||||
);
|
||||
return ThemeData.light().copyWith();
|
||||
}
|
||||
|
||||
ThemeData buildVikunjaMaterialDarkTheme() {
|
||||
return ThemeData.dark().copyWith(
|
||||
|
||||
);
|
||||
return ThemeData.dark().copyWith();
|
||||
}
|
||||
|
||||
ThemeData _buildVikunjaTheme(ThemeData base, {bool isDark = false}) {
|
||||
|
@ -39,11 +37,8 @@ ThemeData _buildVikunjaTheme(ThemeData base, {bool isDark = false}) {
|
|||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: const BorderSide(color: Colors.grey, width: 1)
|
||||
),
|
||||
|
||||
borderSide: const BorderSide(color: Colors.grey, width: 1)),
|
||||
),
|
||||
|
||||
dividerTheme: DividerThemeData(
|
||||
color: () {
|
||||
return isDark ? Colors.white10 : Colors.black12;
|
||||
|
@ -54,14 +49,18 @@ ThemeData _buildVikunjaTheme(ThemeData base, {bool isDark = false}) {
|
|||
// Make bottomNavigationBar backgroundColor darker to provide more separation
|
||||
backgroundColor: () {
|
||||
final _hslColor = HSLColor.fromColor(
|
||||
base.bottomNavigationBarTheme.backgroundColor
|
||||
?? base.scaffoldBackgroundColor
|
||||
);
|
||||
return _hslColor.withLightness(max(_hslColor.lightness - 0.03, 0)).toColor();
|
||||
base.bottomNavigationBarTheme.backgroundColor ??
|
||||
base.scaffoldBackgroundColor);
|
||||
return _hslColor
|
||||
.withLightness(max(_hslColor.lightness - 0.03, 0))
|
||||
.toColor();
|
||||
}(),
|
||||
), colorScheme: base.colorScheme.copyWith(
|
||||
primary: vPrimaryDark,
|
||||
secondary: vPrimary,
|
||||
).copyWith(error: vRed),
|
||||
),
|
||||
colorScheme: base.colorScheme
|
||||
.copyWith(
|
||||
primary: vPrimaryDark,
|
||||
secondary: vPrimary,
|
||||
)
|
||||
.copyWith(error: vRed),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -18,4 +18,4 @@ double calculateItemPosition({double? positionBefore, double? positionAfter}) {
|
|||
|
||||
// in the middle (positionBefore != null && positionAfter != null)
|
||||
return (positionBefore! + positionAfter!) / 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,4 +46,3 @@ CheckboxStatistics getCheckboxStatistics(String text) {
|
|||
checked: checkboxes.checked.length,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
String durationToHumanReadable(Duration dur) {
|
||||
var durString = '';
|
||||
if(dur.inDays.abs() > 1)
|
||||
if (dur.inDays.abs() > 1)
|
||||
durString = dur.inDays.abs().toString() + " days";
|
||||
else if(dur.inDays.abs() == 1)
|
||||
else if (dur.inDays.abs() == 1)
|
||||
durString = dur.inDays.abs().toString() + " day";
|
||||
|
||||
else if(dur.inHours.abs() > 1)
|
||||
else if (dur.inHours.abs() > 1)
|
||||
durString = dur.inHours.abs().toString() + " hours";
|
||||
else if(dur.inHours.abs() == 1)
|
||||
else if (dur.inHours.abs() == 1)
|
||||
durString = dur.inHours.abs().toString() + " hour";
|
||||
|
||||
else if(dur.inMinutes.abs() > 1)
|
||||
else if (dur.inMinutes.abs() > 1)
|
||||
durString = dur.inMinutes.abs().toString() + " minutes";
|
||||
else if(dur.inMinutes.abs() == 1)
|
||||
else if (dur.inMinutes.abs() == 1)
|
||||
durString = dur.inMinutes.abs().toString() + " minute";
|
||||
else durString = "less than a minute";
|
||||
else
|
||||
durString = "less than a minute";
|
||||
|
||||
if (dur.isNegative) return durString + " ago";
|
||||
return "in " + durString;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ priorityFromString(String? priority) {
|
|||
case 'DO NOW':
|
||||
return 5;
|
||||
default:
|
||||
// unset
|
||||
// unset
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,6 @@ Duration? getDurationFromType(String? value, String? type) {
|
|||
case 'Years':
|
||||
return Duration(days: val * 365);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import 'package:vikunja_app/models/user.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 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));
|
||||
|
||||
|
@ -15,9 +16,14 @@ void main() {
|
|||
});
|
||||
|
||||
test('hex color string from object', () {
|
||||
Label label = Label(id: 1, title: '', color: Color(0xFFe8e8e8), createdBy: User(id: 0, username: ''));
|
||||
Label label = Label(
|
||||
id: 1,
|
||||
title: '',
|
||||
color: Color(0xFFe8e8e8),
|
||||
createdBy: User(id: 0, username: ''));
|
||||
var json = label.toJSON();
|
||||
|
||||
expect(json.toString(), '{id: 1, title: , description: null, hex_color: e8e8e8, created_by: {id: 0, username: ,}, updated: null, created: null}');
|
||||
expect(json.toString(),
|
||||
'{id: 1, title: , description: null, hex_color: e8e8e8, created_by: {id: 0, username: ,}, updated: null, created: null}');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ 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 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));
|
||||
|
||||
|
@ -17,19 +18,25 @@ void main() {
|
|||
DateTime.fromMillisecondsSinceEpoch(1543834800 * 1000),
|
||||
DateTime.fromMillisecondsSinceEpoch(1544612400 * 1000),
|
||||
]);
|
||||
expect(task.dueDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 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.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));
|
||||
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 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));
|
||||
|
||||
|
@ -38,15 +45,20 @@ void main() {
|
|||
expect(task.description, 'Lorem Ipsum');
|
||||
expect(task.done, true);
|
||||
expect(task.reminderDates, null);
|
||||
expect(task.dueDate, DateTime.fromMillisecondsSinceEpoch(1543834800 * 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.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));
|
||||
expect(
|
||||
task.created, DateTime.fromMillisecondsSinceEpoch(1542465818 * 1000));
|
||||
expect(
|
||||
task.updated, DateTime.fromMillisecondsSinceEpoch(1552771527 * 1000));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue