mirror of
https://github.com/go-vikunja/app
synced 2024-06-04 11:39:47 +00:00
added option to save default list and add to it from the start screen
This commit is contained in:
parent
36ce680927
commit
168c4a7518
|
@ -7,7 +7,7 @@ import 'package:vikunja_app/components/AddDialog.dart';
|
|||
import 'package:vikunja_app/components/ErrorDialog.dart';
|
||||
import 'package:vikunja_app/pages/namespace/namespace.dart';
|
||||
import 'package:vikunja_app/pages/namespace/namespace_edit.dart';
|
||||
import 'package:vikunja_app/pages/placeholder.dart';
|
||||
import 'package:vikunja_app/pages/landing_page.dart';
|
||||
import 'package:vikunja_app/global.dart';
|
||||
import 'package:vikunja_app/models/namespace.dart';
|
||||
import 'package:vikunja_app/pages/settings.dart';
|
||||
|
@ -97,7 +97,7 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
),
|
||||
drawer: new Drawer(
|
||||
child: new Column(children: <Widget>[
|
||||
new UserAccountsDrawerHeader(
|
||||
new UserAccountsDrawerHeader(
|
||||
accountEmail:
|
||||
currentUser?.email == null ? null : Text(currentUser.email),
|
||||
accountName:
|
||||
|
@ -125,6 +125,18 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
child: _showUserDetails
|
||||
? _userDetailsWidget(context)
|
||||
: _namespacesWidget())),
|
||||
new Align(
|
||||
alignment: FractionalOffset.bottomLeft,
|
||||
child: Builder(
|
||||
builder: (context) => ListTile(
|
||||
leading: Icon(Icons.house),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
setState(() => _selectedDrawerIndex = -1);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
new Align(
|
||||
alignment: FractionalOffset.bottomCenter,
|
||||
child: Builder(
|
||||
|
@ -142,7 +154,7 @@ class HomePageState extends State<HomePage> with AfterLayoutMixin<HomePage> {
|
|||
|
||||
_getDrawerItemWidget(int pos) {
|
||||
if (pos == -1) {
|
||||
return new PlaceholderPage();
|
||||
return new LandingPage();
|
||||
}
|
||||
return new NamespacePage(namespace: _namespaces[pos]);
|
||||
}
|
||||
|
|
74
lib/pages/landing_page.dart
Normal file
74
lib/pages/landing_page.dart
Normal file
|
@ -0,0 +1,74 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:vikunja_app/global.dart';
|
||||
|
||||
import '../components/AddDialog.dart';
|
||||
import '../models/task.dart';
|
||||
|
||||
class LandingPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => LandingPageState();
|
||||
|
||||
}
|
||||
|
||||
class LandingPageState extends State<LandingPage> {
|
||||
int defaultList;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
VikunjaGlobal.of(context).listService.getDefaultList().then((value) => setState(() => defaultList = value == null ? null : int.tryParse(value)));
|
||||
return new Scaffold(
|
||||
body: Container(
|
||||
padding: EdgeInsets.only(left: 16.0),
|
||||
child: new Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
padding: EdgeInsets.only(top: 32.0),
|
||||
child: new Text(
|
||||
'Welcome to Vikunja',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
new Text('Please select a namespace by tapping the ☰ icon.',
|
||||
style: Theme.of(context).textTheme.subtitle1),
|
||||
],
|
||||
)
|
||||
),
|
||||
floatingActionButton: Builder(
|
||||
builder: (context) =>
|
||||
defaultList == null ?
|
||||
FloatingActionButton(
|
||||
backgroundColor: Colors.grey,
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Please select a default list in the settings'),
|
||||
));},
|
||||
child: const Icon(Icons.add))
|
||||
:
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
_addItemDialog(context);
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
));
|
||||
}
|
||||
_addItemDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AddDialog(
|
||||
onAdd: (name) => _addItem(name, context),
|
||||
decoration: new InputDecoration(
|
||||
labelText: 'Task Name', hintText: 'eg. Milk')));
|
||||
}
|
||||
|
||||
_addItem(String name, BuildContext context) {
|
||||
var globalState = VikunjaGlobal.of(context);
|
||||
var newTask = Task(
|
||||
id: null, title: name, owner: globalState.currentUser, done: false, loading: true);
|
||||
globalState.taskService.add(defaultList, newTask).then((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('The task was added successfully!'),
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class PlaceholderPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
padding: EdgeInsets.only(left: 16.0),
|
||||
child: new Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Container(
|
||||
padding: EdgeInsets.only(top: 32.0),
|
||||
child: new Text(
|
||||
'Welcome to Vikunja',
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
new Text('Please select a namespace by tapping the ☰ icon.',
|
||||
style: Theme.of(context).textTheme.subtitle1),
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
|
@ -126,6 +126,17 @@ class MockedListService implements ListService {
|
|||
void setDisplayDoneTasks(int listId, String value) {
|
||||
// TODO: implement setDisplayDoneTasks
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getDefaultList() {
|
||||
// TODO: implement getDefaultList
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
void setDefaultList(int listId) {
|
||||
// TODO: implement setDefaultList
|
||||
}
|
||||
}
|
||||
|
||||
class MockedTaskService implements TaskService {
|
||||
|
|
Loading…
Reference in New Issue
Block a user