forked from vikunja/app
Started implementing creation of new labels on the fly
This commit is contained in:
parent
70bec87d50
commit
6515afdd64
|
@ -31,6 +31,8 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
List<Label>
|
||||
_suggestedLabels; // we use this to find the label object after a user taps on the suggestion, because the typeahead only uses strings, not full objects.
|
||||
var _reminderInputs = new List<Widget>();
|
||||
final _labelTypeAheadController = TextEditingController();
|
||||
String _labelSearchText;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext ctx) {
|
||||
|
@ -238,25 +240,37 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
},
|
||||
);
|
||||
}).toList()),
|
||||
TypeAheadFormField(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
//controller: _typeAheadController,
|
||||
decoration:
|
||||
InputDecoration(labelText: 'Add a new label')),
|
||||
suggestionsCallback: (pattern) {
|
||||
return _searchLabel(pattern);
|
||||
},
|
||||
itemBuilder: (context, suggestion) {
|
||||
return ListTile(
|
||||
title: Text(suggestion),
|
||||
);
|
||||
},
|
||||
transitionBuilder: (context, suggestionsBox, controller) {
|
||||
return suggestionsBox;
|
||||
},
|
||||
onSuggestionSelected: (suggestion) {
|
||||
_addLabel(suggestion);
|
||||
},
|
||||
Row(
|
||||
children: <Widget>[
|
||||
TypeAheadFormField(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
controller: _labelTypeAheadController,
|
||||
onChanged: (value) => _labelSearchText = value,
|
||||
decoration:
|
||||
InputDecoration(labelText: 'Add a new label')),
|
||||
suggestionsCallback: (pattern) {
|
||||
return _searchLabel(pattern);
|
||||
},
|
||||
itemBuilder: (context, suggestion) {
|
||||
return ListTile(
|
||||
title: Text(suggestion),
|
||||
);
|
||||
},
|
||||
transitionBuilder:
|
||||
(context, suggestionsBox, controller) {
|
||||
return suggestionsBox;
|
||||
},
|
||||
onSuggestionSelected: (suggestion) {
|
||||
_addLabel(suggestion);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
print(_labelSearchText);
|
||||
},
|
||||
icon: Icon(Icons.add),
|
||||
)
|
||||
],
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => Padding(
|
||||
|
@ -350,11 +364,17 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||
|
||||
_addLabel(String labelTitle) {
|
||||
// FIXME: This is not an optimal solution...
|
||||
bool found = false;
|
||||
_suggestedLabels.forEach((label) {
|
||||
if (label.title == labelTitle) {
|
||||
_labels.add(label);
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (found) {
|
||||
_labelTypeAheadController.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Move the following two functions to an extra class or type.
|
||||
|
|
Loading…
Reference in New Issue
Block a user