mirror of
https://github.com/go-vikunja/app
synced 2025-01-19 14:16:08 +00:00
Show a message if a list or namespace is empty (#29)
This commit is contained in:
parent
2121b831a0
commit
8278340242
@ -25,7 +25,7 @@ class TaskList {
|
||||
title = json['title'],
|
||||
updated = DateTime.fromMillisecondsSinceEpoch(json['updated']),
|
||||
created = DateTime.fromMillisecondsSinceEpoch(json['created']),
|
||||
tasks = (json['tasks'] as List<dynamic>)
|
||||
tasks = (json['tasks'] == null ? [] : json['tasks'] as List<dynamic>)
|
||||
?.map((taskJson) => Task.fromJson(taskJson))
|
||||
?.toList();
|
||||
|
||||
|
@ -53,12 +53,14 @@ class _ListPageState extends State<ListPage> {
|
||||
),
|
||||
body: !this._loading
|
||||
? RefreshIndicator(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(
|
||||
context: context, tiles: _listTasks())
|
||||
.toList(),
|
||||
),
|
||||
child: _list.tasks.length > 0
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(
|
||||
context: context, tiles: _listTasks())
|
||||
.toList(),
|
||||
)
|
||||
: Center(child: Text('This list is empty.')),
|
||||
onRefresh: _loadList,
|
||||
)
|
||||
: Center(child: CircularProgressIndicator()),
|
||||
@ -89,10 +91,10 @@ class _ListPageState extends State<ListPage> {
|
||||
return VikunjaGlobal.of(context)
|
||||
.listService
|
||||
.get(widget.taskList.id)
|
||||
.then((tasks) {
|
||||
.then((list) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_list = tasks;
|
||||
_list = list;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -36,31 +36,35 @@ class _NamespacePageState extends State<NamespacePage>
|
||||
return Scaffold(
|
||||
body: !this._loading
|
||||
? RefreshIndicator(
|
||||
child: new ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: _lists.map((ls) => Dismissible(
|
||||
key: Key(ls.id.toString()),
|
||||
direction: DismissDirection.startToEnd,
|
||||
child: ListTile(
|
||||
title: new Text(ls.title),
|
||||
onTap: () => _openList(context, ls),
|
||||
trailing: Icon(Icons.arrow_right),
|
||||
),
|
||||
background: Container(
|
||||
color: Colors.red,
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.delete,
|
||||
color: Colors.white, size: 36.0)),
|
||||
),
|
||||
onDismissed: (direction) {
|
||||
_removeList(ls).then((_) => Scaffold.of(context)
|
||||
.showSnackBar(SnackBar(
|
||||
content: Text("${ls.title} removed"))));
|
||||
},
|
||||
))).toList(),
|
||||
),
|
||||
child: _lists.length > 0
|
||||
? new ListView(
|
||||
padding: EdgeInsets.symmetric(vertical: 8.0),
|
||||
children: ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: _lists.map((ls) => Dismissible(
|
||||
key: Key(ls.id.toString()),
|
||||
direction: DismissDirection.startToEnd,
|
||||
child: ListTile(
|
||||
title: new Text(ls.title),
|
||||
onTap: () => _openList(context, ls),
|
||||
trailing: Icon(Icons.arrow_right),
|
||||
),
|
||||
background: Container(
|
||||
color: Colors.red,
|
||||
child: const ListTile(
|
||||
leading: Icon(Icons.delete,
|
||||
color: Colors.white, size: 36.0)),
|
||||
),
|
||||
onDismissed: (direction) {
|
||||
_removeList(ls).then((_) => Scaffold.of(
|
||||
context)
|
||||
.showSnackBar(SnackBar(
|
||||
content:
|
||||
Text("${ls.title} removed"))));
|
||||
},
|
||||
))).toList(),
|
||||
)
|
||||
: Center(child: Text('This namespace is empty.')),
|
||||
onRefresh: _loadLists,
|
||||
)
|
||||
: Center(child: CircularProgressIndicator()),
|
||||
@ -71,6 +75,12 @@ class _NamespacePageState extends State<NamespacePage>
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_loadLists();
|
||||
}
|
||||
|
||||
Future _removeList(TaskList list) {
|
||||
return VikunjaGlobal.of(context)
|
||||
.listService
|
||||
|
15
pubspec.lock
15
pubspec.lock
@ -146,6 +146,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.2"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -171,7 +178,7 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
version: "1.5.4"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -199,14 +206,14 @@ packages:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.1.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
version: "0.2.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -236,4 +243,4 @@ packages:
|
||||
source: hosted
|
||||
version: "2.1.15"
|
||||
sdks:
|
||||
dart: ">=2.0.0 <3.0.0"
|
||||
dart: ">=2.1.0 <3.0.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user