Add ListPage
This commit is contained in:
parent
7e681bd16b
commit
9dc281317b
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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")),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue