Reformat code
Add "Add namespace" functionality
This commit is contained in:
parent
744dd0db94
commit
fb3c6e78ba
|
@ -4,21 +4,21 @@ class NamespaceFragment extends StatelessWidget {
|
||||||
final String namespace;
|
final String namespace;
|
||||||
|
|
||||||
NamespaceFragment({this.namespace});
|
NamespaceFragment({this.namespace});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return new Center(
|
return new Center(
|
||||||
child: new Column(
|
child: new Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Container(
|
new Container(
|
||||||
child: new Text(
|
child: new Text(
|
||||||
'Namespace: $namespace',
|
'Namespace: $namespace',
|
||||||
style: Theme.of(context).textTheme.title,
|
style: Theme.of(context).textTheme.title,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
new Text('You\'ve selected a namespace!')
|
new Text('You\'ve selected a namespace!')
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,4 @@ class VikunjaApp extends StatelessWidget {
|
||||||
home: new HomePage(),
|
home: new HomePage(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,18 +5,14 @@ import 'package:fluttering_vikunja/fragments/placeholder.dart';
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => new HomePageState();
|
State<StatefulWidget> createState() => new HomePageState();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomePageState extends State<HomePage> {
|
class HomePageState extends State<HomePage> {
|
||||||
List<String> namespaces = [
|
List<String> namespaces = ["Jonas's namespace", 'Another namespace'];
|
||||||
"Jonas's namespace",
|
|
||||||
'Another namespace'
|
|
||||||
];
|
|
||||||
int _selectedDrawerIndex = -1;
|
int _selectedDrawerIndex = -1;
|
||||||
|
|
||||||
_getDrawerItemWidget(int pos) {
|
_getDrawerItemWidget(int pos) {
|
||||||
if(pos == -1) {
|
if (pos == -1) {
|
||||||
return new PlaceholderFragment();
|
return new PlaceholderFragment();
|
||||||
}
|
}
|
||||||
return new NamespaceFragment(namespace: namespaces[pos]);
|
return new NamespaceFragment(namespace: namespaces[pos]);
|
||||||
|
@ -29,79 +25,75 @@ class HomePageState extends State<HomePage> {
|
||||||
|
|
||||||
_addNamespace() {
|
_addNamespace() {
|
||||||
var textController = new TextEditingController();
|
var textController = new TextEditingController();
|
||||||
showDialog(context: context, child: new _SystemPadding(
|
showDialog(
|
||||||
child: new AlertDialog(
|
context: context,
|
||||||
contentPadding: const EdgeInsets.all(4.0),
|
child: new _SystemPadding(
|
||||||
content: new Row(
|
child: new AlertDialog(
|
||||||
children: <Widget>[
|
contentPadding: const EdgeInsets.all(16.0),
|
||||||
Expanded(
|
content: new Row(children: <Widget>[
|
||||||
|
Expanded(
|
||||||
child: new TextField(
|
child: new TextField(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
labelText: 'Namespace', hintText: 'eg. Family Namespace'
|
labelText: 'Namespace', hintText: 'eg. Family Namespace'),
|
||||||
),
|
|
||||||
controller: textController,
|
controller: textController,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
actions: <Widget>[
|
||||||
|
new FlatButton(
|
||||||
|
child: const Text('CANCEL'),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
),
|
),
|
||||||
)
|
new FlatButton(
|
||||||
]
|
child: const Text('ADD'),
|
||||||
),
|
onPressed: () {
|
||||||
actions: <Widget>[
|
if (textController.text.isNotEmpty)
|
||||||
new FlatButton(
|
setState(() => namespaces.add(textController.text));
|
||||||
child: const Text('CANCEL'),
|
Navigator.pop(context);
|
||||||
onPressed: () => Navigator.pop(context),
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
new FlatButton(
|
));
|
||||||
child: const Text('ADD'),
|
|
||||||
onPressed: () {
|
|
||||||
namespaces.add(textController.text);
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
List<Widget> drawerOptions = <Widget>[];
|
List<Widget> drawerOptions = <Widget>[];
|
||||||
namespaces.asMap().forEach((i, namespace) =>
|
namespaces.asMap().forEach((i, namespace) => drawerOptions.add(new ListTile(
|
||||||
drawerOptions.add(new ListTile(
|
leading: const Icon(Icons.folder),
|
||||||
leading: const Icon(Icons.folder),
|
title: new Text(namespace),
|
||||||
title: new Text(namespace),
|
selected: i == _selectedDrawerIndex,
|
||||||
selected: i == _selectedDrawerIndex,
|
onTap: () => _onSelectItem(i),
|
||||||
onTap: () => _onSelectItem(i),
|
)));
|
||||||
))
|
|
||||||
);
|
|
||||||
return new Scaffold(
|
return new Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: new Text(_selectedDrawerIndex == -1 ?
|
title: new Text(_selectedDrawerIndex == -1
|
||||||
'Vakunja' :
|
? 'Vakunja'
|
||||||
namespaces[_selectedDrawerIndex]),
|
: namespaces[_selectedDrawerIndex]),
|
||||||
),
|
),
|
||||||
drawer: new Drawer(
|
drawer: new Drawer(
|
||||||
child: new Column(
|
child: new Column(children: <Widget>[
|
||||||
children: <Widget>[
|
new UserAccountsDrawerHeader(
|
||||||
new UserAccountsDrawerHeader(
|
accountEmail: const Text('jonas@try.vikunja.io'),
|
||||||
accountEmail: const Text('jonas@try.vikunja.io'),
|
accountName: const Text('Jonas Franz'),
|
||||||
accountName: const Text('Jonas Franz'),
|
),
|
||||||
),
|
new Expanded(
|
||||||
new Column(
|
child: ListView(
|
||||||
children: ListTile.divideTiles(context: context, tiles: drawerOptions).toList()
|
padding: EdgeInsets.zero,
|
||||||
),
|
children:
|
||||||
new Expanded(
|
ListTile.divideTiles(context: context, tiles: drawerOptions)
|
||||||
child: new Align(
|
.toList())),
|
||||||
alignment: FractionalOffset.bottomCenter,
|
new Align(
|
||||||
child: new ListTile(
|
alignment: FractionalOffset.bottomCenter,
|
||||||
leading: const Icon(Icons.add),
|
child: new ListTile(
|
||||||
title: const Text('Add namespace...'),
|
leading: const Icon(Icons.add),
|
||||||
onTap: () => _addNamespace(),
|
title: const Text('Add namespace...'),
|
||||||
),
|
onTap: () => _addNamespace(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
])),
|
||||||
)
|
|
||||||
),
|
|
||||||
body: _getDrawerItemWidget(_selectedDrawerIndex),
|
body: _getDrawerItemWidget(_selectedDrawerIndex),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -120,4 +112,4 @@ class _SystemPadding extends StatelessWidget {
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: child);
|
child: child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,24 +8,16 @@ const vBlack = Color(0xFFFFFFFF);
|
||||||
ThemeData buildVikunjaTheme() {
|
ThemeData buildVikunjaTheme() {
|
||||||
var base = ThemeData.light();
|
var base = ThemeData.light();
|
||||||
return base.copyWith(
|
return base.copyWith(
|
||||||
primaryColor: vBlue,
|
primaryColor: vBlue,
|
||||||
primaryColorLight: vBlueLight,
|
primaryColorLight: vBlueLight,
|
||||||
primaryColorDark: vBlueDark,
|
primaryColorDark: vBlueDark,
|
||||||
textTheme: base.textTheme.copyWith(
|
textTheme: base.textTheme.copyWith(
|
||||||
headline: base.textTheme.headline.copyWith(
|
headline: base.textTheme.headline.copyWith(
|
||||||
fontFamily: 'Quicksand',
|
fontFamily: 'Quicksand',
|
||||||
fontSize: 72.0,
|
fontSize: 72.0,
|
||||||
),
|
),
|
||||||
subhead: base.textTheme.subhead.copyWith(
|
title: base.textTheme.title.copyWith(
|
||||||
fontFamily: 'Quicksand',
|
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