functional activity addition, bug to only remove activity action and date selection need to be fixed

This commit is contained in:
Joshua Burman
2025-01-05 15:07:36 -05:00
parent fec4eaaf92
commit acab37eb60
10 changed files with 177 additions and 28 deletions

View File

@ -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;