functional activity addition, bug to only remove activity action and date selection need to be fixed
This commit is contained in:
41
lib/services/search/activity_finder_service.dart
Normal file
41
lib/services/search/activity_finder_service.dart
Normal file
@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/daos/activities_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
// import 'package:sendtrain/widgets/activities/activity_card.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/form_search_input.dart';
|
||||
|
||||
class ActivityFinderService {
|
||||
final BuildContext context;
|
||||
final ActivitiesDao dao;
|
||||
|
||||
ActivityFinderService(this.context)
|
||||
: dao = ActivitiesDao(Provider.of<AppDatabase>(context, listen: false));
|
||||
|
||||
void finish() {}
|
||||
|
||||
Future<List<Suggestion>?> fetchSuggestions(String input) async {
|
||||
List<Activity> activities = await dao.contains(input);
|
||||
|
||||
if (activities.isNotEmpty) {
|
||||
return activities
|
||||
.map<Suggestion>((activity) => Suggestion<Activity>(activity))
|
||||
.toList();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Widget resultWidget(Activity activity, Function? callback) {
|
||||
// return ActivityCard(activity: activity, callback: callback);
|
||||
return ListTile(
|
||||
title: Text(activity.title),
|
||||
subtitle: Text(activity.description),
|
||||
onTap: () {
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:sendtrain/models/google_place_model.dart';
|
||||
import 'package:sendtrain/widgets/generic/elements/form_search_input.dart';
|
||||
@ -15,7 +16,7 @@ class GooglePlacesService {
|
||||
client.close();
|
||||
}
|
||||
|
||||
Future<List<Suggestion>?> fetchSuggestions(String input, String lang) async {
|
||||
Future<List<Suggestion>?> fetchSuggestions(String input) async {
|
||||
var headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Goog-Api-Key': apiKey,
|
||||
@ -75,4 +76,15 @@ class GooglePlacesService {
|
||||
throw Exception(response.reasonPhrase);
|
||||
}
|
||||
}
|
||||
|
||||
Widget resultWidget(GooglePlaceModel place, Function? callback) {
|
||||
return ListTile(
|
||||
title: Text(place.description),
|
||||
onTap: () async {
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user