Add ListPage

This commit is contained in:
Jonas Franz 2018-09-15 18:21:48 +02:00
parent 7e681bd16b
commit 9dc281317b
No known key found for this signature in database
GPG Key ID: 506AEEBE80BEDECD
2 changed files with 67 additions and 15 deletions

View File

@ -1,24 +1,50 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttering_vikunja/pages/list_page.dart';
class NamespaceFragment extends StatelessWidget {
class NamespaceFragment extends StatefulWidget {
final String namespace;
NamespaceFragment({this.namespace}) : super(key: Key(namespace));
NamespaceFragment({this.namespace});
@override
_NamespaceFragmentState createState() => new _NamespaceFragmentState();
}
class _NamespaceFragmentState extends State<NamespaceFragment> {
Set<String> _lists = Set.from(
["Cupertino List", "Material List", "Shopping List", "NAS List"]);
@override
Widget build(BuildContext context) {
return new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
child: new Text(
'Namespace: $namespace',
style: Theme.of(context).textTheme.title,
),
),
new Text('You\'ve selected a namespace!')
],
));
return new ListView(
padding: EdgeInsets.symmetric(vertical: 8.0),
children: ListTile.divideTiles(
context: context,
tiles: _lists.map((name) => Dismissible(
key: Key(name),
direction: DismissDirection.startToEnd,
child: ListTile(
title: new Text(name),
onTap: () => _openList(context, name),
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) {
setState(() => _lists.remove(name));
Scaffold.of(context)
.showSnackBar(SnackBar(content: Text("$name removed")));
},
))).toList(),
);
}
_openList(BuildContext context, String name) {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => ListPage(listName: name)));
}
}

26
lib/pages/list_page.dart Normal file
View File

@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
class ListPage extends StatefulWidget {
final String listName;
ListPage({this.listName}) : super(key: Key(listName));
@override
_ListPageState createState() => _ListPageState();
}
class _ListPageState extends State<ListPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: new Text(widget.listName),
),
body: Center(
child: RaisedButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text("Go back")),
),
);
}
}