Add ListPage

This commit is contained in:
Jonas Franz 2018-09-15 18:21:48 +02:00
parent fb3c6e78ba
commit e865fb904b
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:flutter/material.dart';
import 'package:fluttering_vikunja/pages/list_page.dart';
class NamespaceFragment extends StatelessWidget { class NamespaceFragment extends StatefulWidget {
final String namespace; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Center( return new ListView(
child: new Column( padding: EdgeInsets.symmetric(vertical: 8.0),
mainAxisAlignment: MainAxisAlignment.center, children: ListTile.divideTiles(
children: <Widget>[ context: context,
new Container( tiles: _lists.map((name) => Dismissible(
child: new Text( key: Key(name),
'Namespace: $namespace', direction: DismissDirection.startToEnd,
style: Theme.of(context).textTheme.title, child: ListTile(
), title: new Text(name),
), onTap: () => _openList(context, name),
new Text('You\'ve selected a namespace!') 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")),
),
);
}
}