List edit #21
|
@ -46,10 +46,11 @@ class TaskTileState extends State<TaskTile> {
|
|||
_currentTask.description == null || _currentTask.description.isEmpty
|
||||
? null
|
||||
: Text(_currentTask.description),
|
||||
trailing: IconButton(icon: Icon(Icons.settings), onPressed: () {
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
|
||||
onPressed: () {
|
||||
print("test");
|
||||
}
|
||||
),
|
||||
}),
|
||||
);
|
||||
}
|
||||
return CheckboxListTile(
|
||||
|
|
|
@ -46,5 +46,3 @@ class Task {
|
|||
'createdBy': owner?.toJSON()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,19 +18,16 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Edit List'),
|
||||
),
|
||||
body: Builder(
|
||||
builder: (BuildContext context) =>
|
||||
SafeArea(
|
||||
builder: (BuildContext context) => SafeArea(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||
|
@ -55,42 +52,41 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
maxLines: null,
|
||||
keyboardType: TextInputType.multiline,
|
||||
initialValue: widget.list.description,
|
||||
onSaved: (description) => _description = description,
|
||||
onSaved: (description) =>
|
||||
_description = description,
|
||||
validator: (description) {
|
||||
if (description.length > 1000) {
|
||||
return 'The description can have a maximum of 1000 characters.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
decoration:
|
||||
new InputDecoration(labelText: 'Description'),
|
||||
decoration: new InputDecoration(
|
||||
labelText: 'Description'),
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => RaisedButton(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.0),
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 10.0),
|
||||
onPressed: !_loading
|
||||
? () {
|
||||
if (_formKey.currentState
|
||||
.validate()) {
|
||||
Form.of(context).save(); // Why does this not work?
|
||||
Form.of(context)
|
||||
.save(); // Why does this not work?
|
||||
_saveList(context);
|
||||
} else {
|
||||
print("sdf"); // TODO: handle error
|
||||
print(
|
||||
"sdf"); // TODO: handle error
|
||||
}
|
||||
}
|
||||
: null,
|
||||
child: _loading
|
||||
? CircularProgressIndicator()
|
||||
: Text('Save'),
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
)),
|
||||
])),
|
||||
)));
|
||||
}
|
||||
|
||||
_saveList(BuildContext context) async {
|
||||
|
@ -100,23 +96,17 @@ class _ListEditPageState extends State<ListEditPage> {
|
|||
// FIXME: is there a way we can update the list without creating a new list object?
|
||||
// aka updating the existing list we got from context (setters?)
|
||||
TaskList updatedList = TaskList(
|
||||
id: widget.list.id,
|
||||
title: _title,
|
||||
description: _description
|
||||
);
|
||||
id: widget.list.id, title: _title, description: _description);
|
||||
|
||||
// FIXME: When the api returns an error (status code != 2xx), this throws an exception
|
||||
VikunjaGlobal.of(context).listService.update(updatedList)
|
||||
.then((_) {
|
||||
VikunjaGlobal.of(context).listService.update(updatedList).then((_) {
|
||||
setState(() {});
|
||||
final scaffold = Scaffold.of(context);
|
||||
scaffold.showSnackBar(
|
||||
SnackBar(
|
||||
scaffold.showSnackBar(SnackBar(
|
||||
content: Text('The list was updated successfully!'),
|
||||
)
|
||||
);
|
||||
));
|
||||
}); // TODO: show the user a message the list was updated successfully
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
final scaffold = Scaffold.of(context);
|
||||
scaffold.showSnackBar(
|
||||
SnackBar(
|
||||
|
|
|
@ -45,9 +45,10 @@ class _ListPageState extends State<ListPage> {
|
|||
icon: Icon(Icons.edit),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => ListEditPage(list: _list,))
|
||||
)
|
||||
)
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ListEditPage(
|
||||
list: _list,
|
||||
))))
|
||||
],
|
||||
),
|
||||
body: !this._loading
|
||||
|
|
Reference in New Issue
Block a user
Unrelated change