Reformat code
Add "Add namespace" functionality
This commit is contained in:
parent
744dd0db94
commit
fb3c6e78ba
|
@ -5,14 +5,10 @@ import 'package:fluttering_vikunja/fragments/placeholder.dart';
|
|||
class HomePage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => new HomePageState();
|
||||
|
||||
}
|
||||
|
||||
class HomePageState extends State<HomePage> {
|
||||
List<String> namespaces = [
|
||||
"Jonas's namespace",
|
||||
'Another namespace'
|
||||
];
|
||||
List<String> namespaces = ["Jonas's namespace", 'Another namespace'];
|
||||
int _selectedDrawerIndex = -1;
|
||||
|
||||
_getDrawerItemWidget(int pos) {
|
||||
|
@ -29,22 +25,21 @@ class HomePageState extends State<HomePage> {
|
|||
|
||||
_addNamespace() {
|
||||
var textController = new TextEditingController();
|
||||
showDialog(context: context, child: new _SystemPadding(
|
||||
showDialog(
|
||||
context: context,
|
||||
child: new _SystemPadding(
|
||||
child: new AlertDialog(
|
||||
contentPadding: const EdgeInsets.all(4.0),
|
||||
content: new Row(
|
||||
children: <Widget>[
|
||||
contentPadding: const EdgeInsets.all(16.0),
|
||||
content: new Row(children: <Widget>[
|
||||
Expanded(
|
||||
child: new TextField(
|
||||
autofocus: true,
|
||||
decoration: new InputDecoration(
|
||||
labelText: 'Namespace', hintText: 'eg. Family Namespace'
|
||||
),
|
||||
labelText: 'Namespace', hintText: 'eg. Family Namespace'),
|
||||
controller: textController,
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
]),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: const Text('CANCEL'),
|
||||
|
@ -53,7 +48,8 @@ class HomePageState extends State<HomePage> {
|
|||
new FlatButton(
|
||||
child: const Text('ADD'),
|
||||
onPressed: () {
|
||||
namespaces.add(textController.text);
|
||||
if (textController.text.isNotEmpty)
|
||||
setState(() => namespaces.add(textController.text));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
|
@ -65,32 +61,31 @@ class HomePageState extends State<HomePage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Widget> drawerOptions = <Widget>[];
|
||||
namespaces.asMap().forEach((i, namespace) =>
|
||||
drawerOptions.add(new ListTile(
|
||||
namespaces.asMap().forEach((i, namespace) => drawerOptions.add(new ListTile(
|
||||
leading: const Icon(Icons.folder),
|
||||
title: new Text(namespace),
|
||||
selected: i == _selectedDrawerIndex,
|
||||
onTap: () => _onSelectItem(i),
|
||||
))
|
||||
);
|
||||
)));
|
||||
return new Scaffold(
|
||||
appBar: AppBar(
|
||||
title: new Text(_selectedDrawerIndex == -1 ?
|
||||
'Vakunja' :
|
||||
namespaces[_selectedDrawerIndex]),
|
||||
title: new Text(_selectedDrawerIndex == -1
|
||||
? 'Vakunja'
|
||||
: namespaces[_selectedDrawerIndex]),
|
||||
),
|
||||
drawer: new Drawer(
|
||||
child: new Column(
|
||||
children: <Widget>[
|
||||
child: new Column(children: <Widget>[
|
||||
new UserAccountsDrawerHeader(
|
||||
accountEmail: const Text('jonas@try.vikunja.io'),
|
||||
accountName: const Text('Jonas Franz'),
|
||||
),
|
||||
new Column(
|
||||
children: ListTile.divideTiles(context: context, tiles: drawerOptions).toList()
|
||||
),
|
||||
new Expanded(
|
||||
child: new Align(
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
children:
|
||||
ListTile.divideTiles(context: context, tiles: drawerOptions)
|
||||
.toList())),
|
||||
new Align(
|
||||
alignment: FractionalOffset.bottomCenter,
|
||||
child: new ListTile(
|
||||
leading: const Icon(Icons.add),
|
||||
|
@ -98,10 +93,7 @@ class HomePageState extends State<HomePage> {
|
|||
onTap: () => _addNamespace(),
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
])),
|
||||
body: _getDrawerItemWidget(_selectedDrawerIndex),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,16 +16,8 @@ ThemeData buildVikunjaTheme() {
|
|||
fontFamily: 'Quicksand',
|
||||
fontSize: 72.0,
|
||||
),
|
||||
subhead: base.textTheme.subhead.copyWith(
|
||||
fontFamily: 'Quicksand',
|
||||
fontSize: 24.0,
|
||||
),
|
||||
title: base.textTheme.title.copyWith(
|
||||
fontFamily: 'Quicksand',
|
||||
),
|
||||
body1: base.textTheme.body1.copyWith(
|
||||
fontFamily: 'Quicksand',
|
||||
)
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
Reference in New Issue
Block a user