This commit is contained in:
parent
9f289cf11e
commit
f30958f33c
|
@ -11,7 +11,11 @@ class TaskTile extends StatefulWidget {
|
|||
final bool loading;
|
||||
|
||||
const TaskTile(
|
||||
{Key key, @required this.task, this.onEdit, this.loading = false, this.onMarkedAsDone})
|
||||
{Key key,
|
||||
@required this.task,
|
||||
this.onEdit,
|
||||
this.loading = false,
|
||||
this.onMarkedAsDone})
|
||||
: assert(task != null),
|
||||
super(key: key);
|
||||
|
||||
|
@ -24,8 +28,7 @@ class TaskTile extends StatefulWidget {
|
|||
class TaskTileState extends State<TaskTile> {
|
||||
bool _loading;
|
||||
|
||||
TaskTileState(this._loading)
|
||||
: assert(_loading != null);
|
||||
TaskTileState(this._loading) : assert(_loading != null);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
|
@ -38,7 +38,6 @@ class _ListPageState extends State<ListPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
var tasks = (_list?.tasks?.map(_buildTile) ?? []).toList();
|
||||
tasks.addAll(_loadingTasks.map(_buildLoadingTile));
|
||||
|
||||
|
@ -60,26 +59,26 @@ class _ListPageState extends State<ListPage> {
|
|||
? RefreshIndicator(
|
||||
onRefresh: _loadList,
|
||||
child: /*_list.tasks.length > 0
|
||||
? */ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: tasks)
|
||||
.toList(),
|
||||
),
|
||||
//: Center(child: Text('This list is empty.')),
|
||||
? */
|
||||
ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(context: context, tiles: tasks)
|
||||
.toList(),
|
||||
),
|
||||
//: Center(child: Text('This list is empty.')),
|
||||
)
|
||||
: Center(child: CircularProgressIndicator()),
|
||||
floatingActionButton: Builder(
|
||||
builder: (context) => FloatingActionButton(
|
||||
//onPressed: () => _addItemDialog(context), child: Icon(Icons.add)),
|
||||
onPressed: () {
|
||||
print('test');
|
||||
setState(() {
|
||||
tasks = null;
|
||||
});
|
||||
}, child: Icon(Icons.add),
|
||||
),
|
||||
//onPressed: () => _addItemDialog(context), child: Icon(Icons.add)),
|
||||
onPressed: () {
|
||||
print('test');
|
||||
setState(() {
|
||||
tasks = null;
|
||||
});
|
||||
},
|
||||
child: Icon(Icons.add),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -102,18 +101,21 @@ class _ListPageState extends State<ListPage> {
|
|||
),
|
||||
),
|
||||
onMarkedAsDone: (done) {
|
||||
VikunjaGlobal.of(context).taskService.update(Task(
|
||||
id: task.id,
|
||||
done: done,
|
||||
)).then((newTask) => setState(() {
|
||||
// FIXME: This is ugly. We should use a redux to not have to do these kind of things.
|
||||
// This is enough for now (it works™) but we should definitly fix it later.
|
||||
_list.tasks.asMap().forEach((i, t) {
|
||||
if (newTask.id == t.id) {
|
||||
_list.tasks[i] = newTask;
|
||||
}
|
||||
});
|
||||
}));
|
||||
VikunjaGlobal.of(context)
|
||||
.taskService
|
||||
.update(Task(
|
||||
id: task.id,
|
||||
done: done,
|
||||
))
|
||||
.then((newTask) => setState(() {
|
||||
// FIXME: This is ugly. We should use a redux to not have to do these kind of things.
|
||||
// This is enough for now (it works™) but we should definitly fix it later.
|
||||
_list.tasks.asMap().forEach((i, t) {
|
||||
if (newTask.id == t.id) {
|
||||
_list.tasks[i] = newTask;
|
||||
}
|
||||
});
|
||||
}));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -175,8 +177,8 @@ class _ListPageState extends State<ListPage> {
|
|||
Future<Task> _updateTask(Task task, bool checked) {
|
||||
// TODO use copyFrom
|
||||
return VikunjaGlobal.of(context).taskService.update(Task(
|
||||
id: task.id,
|
||||
done: checked,
|
||||
));
|
||||
id: task.id,
|
||||
done: checked,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue
Block a user