functional activity addition, bug to only remove activity action and date selection need to be fixed
This commit is contained in:
@ -5,9 +5,15 @@ import 'package:sendtrain/services/functional/debouncer.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/form_text_input.dart';
|
||||
|
||||
class Suggestion<T> {
|
||||
T type;
|
||||
T content;
|
||||
|
||||
Suggestion(this.type);
|
||||
Suggestion(this.content);
|
||||
|
||||
Widget resultWidget() {
|
||||
return ListTile(
|
||||
title: Text('test'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// controller: manages the selected content
|
||||
@ -19,13 +25,13 @@ class FormSearchInput extends StatefulWidget {
|
||||
{super.key,
|
||||
required this.controller,
|
||||
required this.service,
|
||||
this.title,
|
||||
this.callback});
|
||||
required this.resultHandler,
|
||||
this.title});
|
||||
|
||||
final String? title;
|
||||
final TextEditingController controller;
|
||||
final dynamic service;
|
||||
final Function? callback;
|
||||
final Function resultHandler;
|
||||
|
||||
@override
|
||||
State<FormSearchInput> createState() => _FormSearchInputState();
|
||||
@ -35,7 +41,7 @@ class _FormSearchInputState extends State<FormSearchInput> {
|
||||
String? _currentQuery;
|
||||
|
||||
late final service = widget.service;
|
||||
late final callback = widget.callback;
|
||||
late final resultHandler = widget.resultHandler;
|
||||
// The most recent suggestions received from the API.
|
||||
late Iterable<Widget> _lastOptions = <Widget>[];
|
||||
late final Debouncer debouncer;
|
||||
@ -54,7 +60,7 @@ class _FormSearchInputState extends State<FormSearchInput> {
|
||||
// final Iterable<String> options = await _FakeAPI.search(_currentQuery!);
|
||||
if (query.isNotEmpty) {
|
||||
final List<Suggestion>? suggestions =
|
||||
await service.fetchSuggestions(_currentQuery!, 'en');
|
||||
await service.fetchSuggestions(_currentQuery!);
|
||||
|
||||
// If another search happened after this one, throw away these options.
|
||||
if (_currentQuery != query) {
|
||||
@ -96,17 +102,11 @@ class _FormSearchInputState extends State<FormSearchInput> {
|
||||
}
|
||||
_lastOptions = List<ListTile>.generate(options.length, (int index) {
|
||||
final Suggestion item = options[index];
|
||||
final dynamic content = item.type;
|
||||
return ListTile(
|
||||
title: Text(content.description),
|
||||
onTap: () async {
|
||||
if (callback != null) {
|
||||
callback!(content, service);
|
||||
}
|
||||
|
||||
controller.closeView(null);
|
||||
},
|
||||
);
|
||||
final dynamic content = item.content;
|
||||
return service.resultWidget(content, () {
|
||||
resultHandler(content, service);
|
||||
controller.closeView(null);
|
||||
});
|
||||
});
|
||||
|
||||
return _lastOptions;
|
||||
|
Reference in New Issue
Block a user