2024-08-22 09:20:59 +01:00
|
|
|
import 'dart:convert';
|
2024-08-27 11:16:07 +01:00
|
|
|
import 'dart:math';
|
2024-08-29 12:21:00 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2024-08-05 08:00:16 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2024-08-20 10:00:10 +01:00
|
|
|
import 'package:flutter_map/flutter_map.dart';
|
2024-08-21 11:49:38 +01:00
|
|
|
import 'package:latlong2/latlong.dart';
|
2024-09-05 13:55:34 +01:00
|
|
|
import 'package:mobile/createreview.dart';
|
2024-08-22 11:14:06 +01:00
|
|
|
import 'package:mobile/favorites.dart';
|
2024-08-20 15:46:13 +01:00
|
|
|
import 'package:mobile/register.dart';
|
2024-09-05 13:55:34 +01:00
|
|
|
import 'package:mobile/reviewlist.dart';
|
2024-09-13 08:59:21 +01:00
|
|
|
import 'package:mobile/touristguidebook.dart';
|
2024-09-02 10:39:03 +01:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2024-08-21 11:49:38 +01:00
|
|
|
import 'login.dart';
|
2024-08-21 12:28:48 +01:00
|
|
|
import 'base/sidemenu.dart';
|
|
|
|
import 'profile.dart';
|
2024-08-22 09:20:59 +01:00
|
|
|
import 'models.dart';
|
2024-08-30 13:58:11 +01:00
|
|
|
import 'package:geolocator/geolocator.dart';
|
2024-09-13 08:59:21 +01:00
|
|
|
import 'services/api.dart' as api;
|
2024-08-27 08:55:43 +01:00
|
|
|
import 'package:http/http.dart' as http;
|
2024-08-05 08:00:16 +01:00
|
|
|
|
2024-09-02 10:39:03 +01:00
|
|
|
void main() async {
|
2024-09-02 12:14:13 +01:00
|
|
|
// Refresh JWT on startup
|
2024-09-02 10:39:03 +01:00
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
if (prefs.getString("token") != null && prefs.getString("refresh-token") != null) {
|
2024-09-02 12:14:13 +01:00
|
|
|
final token = await api.request(null, api.ApiService.auth, "POST", "/RefreshToken", {'refreshToken': prefs.getString("refresh-token")});
|
|
|
|
if (token != null) prefs.setString("token", token);
|
2024-09-02 10:39:03 +01:00
|
|
|
}
|
|
|
|
|
2024-08-05 08:00:16 +01:00
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'H4 Flutter',
|
|
|
|
theme: ThemeData(
|
2024-08-20 13:04:40 +01:00
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
|
2024-08-05 08:00:16 +01:00
|
|
|
useMaterial3: true,
|
|
|
|
),
|
2024-08-21 14:37:44 +01:00
|
|
|
home: const MyHomePage(),
|
2024-08-21 12:28:48 +01:00
|
|
|
initialRoute: '/',
|
|
|
|
routes: {
|
2024-08-21 14:37:44 +01:00
|
|
|
'/home': (context) => const MyHomePage(),
|
2024-08-21 12:28:48 +01:00
|
|
|
'/profile': (context) => const ProfilePage(),
|
2024-08-22 11:14:06 +01:00
|
|
|
'/favorites': (context) => const FavoritesPage(),
|
2024-08-21 14:37:44 +01:00
|
|
|
'/login': (context) => const LoginPage(),
|
|
|
|
'/register': (context) => const RegisterPage(),
|
2024-09-04 10:53:32 +01:00
|
|
|
'/reviews': (context) => const ReviewListPage(),
|
2024-09-05 13:55:34 +01:00
|
|
|
'/create-review': (context) => const CreateReviewPage(),
|
2024-09-13 08:59:21 +01:00
|
|
|
'/tourist-guide-book': (context) => const TouristGuideBookPage(),
|
2024-08-21 12:28:48 +01:00
|
|
|
},
|
2024-08-05 08:00:16 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
2024-08-21 14:37:44 +01:00
|
|
|
const MyHomePage({super.key});
|
2024-08-05 08:00:16 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2024-08-21 11:49:38 +01:00
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
2024-08-22 09:20:59 +01:00
|
|
|
List<Favorite> _favorites = [];
|
2024-09-03 12:33:50 +01:00
|
|
|
List<Review> _reviews = [];
|
2024-08-27 08:15:21 +01:00
|
|
|
LatLng? _selectedPoint;
|
2024-09-02 13:39:56 +01:00
|
|
|
LatLng _currentPosition = LatLng(55.656707, 10.563214);
|
|
|
|
LatLng? _userPosition;
|
2024-08-27 11:16:07 +01:00
|
|
|
double _zoom = 7.0;
|
2024-09-02 13:39:56 +01:00
|
|
|
MapController _mapController = MapController();
|
|
|
|
List<SearchResults> _searchResults = [];
|
2024-08-29 12:21:00 +01:00
|
|
|
final TextEditingController searchBarInput =TextEditingController(text: '');
|
2024-08-30 13:58:11 +01:00
|
|
|
final LocationSettings locationSettings = const LocationSettings(
|
|
|
|
accuracy: LocationAccuracy.high,
|
|
|
|
distanceFilter: 100,
|
|
|
|
);
|
2024-08-27 08:15:21 +01:00
|
|
|
|
2024-09-02 13:39:56 +01:00
|
|
|
@override
|
|
|
|
void didChangeDependencies() {
|
|
|
|
super.didChangeDependencies();
|
|
|
|
|
|
|
|
api.isLoggedIn(context).then((isLoggedIn) {
|
|
|
|
if (!isLoggedIn || !mounted) return;
|
|
|
|
|
|
|
|
_fetchFavorites();
|
2024-09-03 12:33:50 +01:00
|
|
|
_fetchReviews();
|
2024-09-02 13:39:56 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
searchBarInput.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2024-08-27 10:48:11 +01:00
|
|
|
void _onTap(TapPosition _, LatLng point) async {
|
2024-08-27 08:15:21 +01:00
|
|
|
setState(() => _selectedPoint = point);
|
2024-08-27 08:55:43 +01:00
|
|
|
|
2024-08-27 09:40:01 +01:00
|
|
|
final dynamic location;
|
2024-08-27 08:55:43 +01:00
|
|
|
try {
|
|
|
|
final response = await http.get(
|
2024-08-27 11:16:07 +01:00
|
|
|
Uri.parse('https://nominatim.openstreetmap.org/reverse.php?lat=${point.latitude}&lon=${point.longitude}&zoom=${max(12, _zoom.ceil())}&format=jsonv2'),
|
2024-08-27 08:55:43 +01:00
|
|
|
headers: {'User-Agent': 'SkanTravels/1.0'},
|
|
|
|
);
|
|
|
|
|
2024-08-27 10:48:11 +01:00
|
|
|
if (mounted && response.statusCode != 200) {
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Unable to fetch information about this location (HTTP ${response.statusCode})')));
|
2024-08-27 11:16:07 +01:00
|
|
|
debugPrint(response.body);
|
2024-08-27 10:48:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-27 08:55:43 +01:00
|
|
|
location = jsonDecode(response.body);
|
|
|
|
} catch (_) {
|
|
|
|
if (!mounted) return;
|
|
|
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Unable to fetch information about this location')));
|
|
|
|
|
|
|
|
setState(() => _selectedPoint = null);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
2024-08-27 10:48:11 +01:00
|
|
|
if (location['name'] != null && location['display_name'] != null) {
|
|
|
|
await _showLocation(point, location['name'], location['display_name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() => _selectedPoint = null);
|
|
|
|
}
|
|
|
|
|
2024-09-04 10:53:32 +01:00
|
|
|
// Open location bottom menu
|
2024-08-27 10:48:11 +01:00
|
|
|
Future<void> _showLocation(LatLng point, String name, String description) async {
|
2024-08-27 08:55:43 +01:00
|
|
|
await showModalBottomSheet(
|
|
|
|
barrierColor: Colors.black.withOpacity(0.3),
|
|
|
|
context: context,
|
|
|
|
builder: (builder) {
|
2024-08-27 09:40:01 +01:00
|
|
|
return StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) {
|
|
|
|
return Wrap(children: [
|
|
|
|
Container(
|
|
|
|
color: Colors.white,
|
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
child: Row(children: [
|
2024-09-04 10:53:32 +01:00
|
|
|
// Location information
|
2024-08-27 09:40:01 +01:00
|
|
|
Expanded(child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-08-27 10:48:11 +01:00
|
|
|
Text(name, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 24)),
|
2024-08-27 09:40:01 +01:00
|
|
|
const SizedBox(height: 10),
|
2024-08-27 10:48:11 +01:00
|
|
|
Text(description),
|
2024-08-27 09:40:01 +01:00
|
|
|
],
|
|
|
|
)),
|
2024-09-04 10:53:32 +01:00
|
|
|
|
2024-08-27 09:40:01 +01:00
|
|
|
Column(children: [
|
2024-09-04 10:53:32 +01:00
|
|
|
// Toggle favorite button
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.star),
|
|
|
|
iconSize: 32,
|
|
|
|
color: _favorites.where((fav) => fav.lat == point.latitude && fav.lng == point.longitude).isEmpty ? Colors.grey : Colors.yellow,
|
|
|
|
onPressed: () => _toggleFavorite(point, name, description, setModalState, context)
|
|
|
|
),
|
|
|
|
|
|
|
|
// View reviews button
|
2024-08-27 09:40:01 +01:00
|
|
|
IconButton(
|
2024-09-04 10:53:32 +01:00
|
|
|
icon: const Icon(Icons.rate_review),
|
|
|
|
iconSize: 32,
|
2024-09-05 13:55:34 +01:00
|
|
|
color: Colors.grey,
|
2024-09-04 10:53:32 +01:00
|
|
|
onPressed: () =>
|
|
|
|
Navigator.pushReplacementNamed(
|
|
|
|
context,
|
|
|
|
'/reviews',
|
2024-09-05 17:11:35 +01:00
|
|
|
arguments: ReviewList(_reviews.where((review) => review.lat == point.latitude && review.lng == point.longitude).toList(), Place(name, description, point))
|
2024-09-04 10:53:32 +01:00
|
|
|
),
|
2024-08-27 09:40:01 +01:00
|
|
|
),
|
|
|
|
]),
|
2024-08-27 08:55:43 +01:00
|
|
|
]),
|
2024-08-27 09:40:01 +01:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
});
|
2024-08-27 08:55:43 +01:00
|
|
|
},
|
|
|
|
);
|
2024-08-27 08:15:21 +01:00
|
|
|
}
|
2024-08-22 09:20:59 +01:00
|
|
|
|
2024-08-27 09:40:01 +01:00
|
|
|
void _toggleFavorite(LatLng point, String name, String description, StateSetter setModalState, BuildContext context) async {
|
|
|
|
final messenger = ScaffoldMessenger.of(context);
|
2024-08-27 10:06:33 +01:00
|
|
|
final navigator = Navigator.of(context);
|
2024-08-27 09:40:01 +01:00
|
|
|
final favorite = _favorites.where((fav) => fav.lat == point.latitude && fav.lng == point.longitude).firstOrNull;
|
|
|
|
|
|
|
|
if (!await api.isLoggedIn(context)) {
|
2024-08-27 10:06:33 +01:00
|
|
|
messenger.showSnackBar(const SnackBar(content: Text('You need to login to do that'), behavior: SnackBarBehavior.floating));
|
|
|
|
navigator.pop();
|
2024-08-27 09:40:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
|
|
|
if (favorite == null) {
|
2024-08-27 11:16:07 +01:00
|
|
|
final newFavorite = await api.request(
|
|
|
|
context, api.ApiService.app, 'POST', '/favorites',
|
|
|
|
{'lat': point.latitude, 'lng': point.longitude, 'name': name, 'description': description},
|
|
|
|
);
|
|
|
|
|
|
|
|
if (newFavorite == null) {
|
2024-08-27 10:06:33 +01:00
|
|
|
navigator.pop();
|
2024-08-27 09:40:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-27 11:16:07 +01:00
|
|
|
setState(() {
|
|
|
|
_favorites.add(Favorite.fromJson(jsonDecode(newFavorite)));
|
|
|
|
});
|
2024-08-27 09:40:01 +01:00
|
|
|
setModalState(() {});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (await api.request(context, api.ApiService.app, 'DELETE', '/favorites/${favorite.id}', null) == null) {
|
2024-08-27 10:06:33 +01:00
|
|
|
navigator.pop();
|
2024-08-27 09:40:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
_favorites = _favorites.where((fav) => fav.id != favorite.id).toList();
|
|
|
|
});
|
|
|
|
setModalState(() {});
|
|
|
|
}
|
|
|
|
|
2024-08-27 10:48:11 +01:00
|
|
|
Future<void> _fetchFavorites() async {
|
2024-08-27 09:40:01 +01:00
|
|
|
final response = await api.request(context, api.ApiService.app, 'GET', '/favorites', null);
|
|
|
|
if (response == null) return;
|
|
|
|
|
|
|
|
final List<dynamic> favorites = jsonDecode(response);
|
|
|
|
setState(() {
|
2024-08-27 11:16:07 +01:00
|
|
|
_favorites = favorites.map((favorite) => Favorite.fromJson(favorite)).toList();
|
2024-08-27 09:40:01 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-09-03 12:33:50 +01:00
|
|
|
Future<void> _fetchReviews() async {
|
|
|
|
final response = await api.request(context, api.ApiService.app, 'GET', '/reviews', null);
|
|
|
|
if (response == null) return;
|
|
|
|
|
|
|
|
final List<dynamic> reviews = jsonDecode(response);
|
|
|
|
setState(() {
|
|
|
|
_reviews = reviews.map((review) => Review.fromJson(review)).toList();
|
|
|
|
debugPrint(_reviews.length.toString());
|
|
|
|
});
|
|
|
|
}
|
2024-08-22 09:20:59 +01:00
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
Future<void> _onSearch() async {
|
|
|
|
final http.Response response = await http.get(
|
|
|
|
Uri.parse('https://nominatim.openstreetmap.org/search.php?q=${searchBarInput.text}&format=jsonv2'),
|
|
|
|
headers: {'User-Agent': 'SkanTravels/1.0'}
|
|
|
|
);
|
2024-08-29 12:21:00 +01:00
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
final dynamic location = jsonDecode(response.body);
|
2024-09-02 13:39:56 +01:00
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
// Move the map to the center of the first search result
|
|
|
|
_mapController.move(
|
|
|
|
LatLng(double.parse(location[0]['lat']), double.parse(location[0]['lon'])),
|
|
|
|
8
|
|
|
|
);
|
2024-09-02 13:39:56 +01:00
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
// Extract the bounding box and convert to LatLng
|
|
|
|
final List<dynamic> boundingBox = location[0]['boundingbox'];
|
2024-09-02 13:39:56 +01:00
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
_getOpenStreetMapData(LatLng(double.parse(boundingBox[0]), double.parse(boundingBox[2])), LatLng(double.parse(boundingBox[1]), double.parse(boundingBox[3])));
|
2024-08-29 12:21:00 +01:00
|
|
|
}
|
|
|
|
|
2024-08-30 13:58:11 +01:00
|
|
|
Future<void> _getCurrentLocation() async {
|
2024-09-02 13:39:56 +01:00
|
|
|
LocationPermission permission = await Geolocator.checkPermission();
|
2024-09-03 13:05:18 +01:00
|
|
|
if(permission != LocationPermission.always || permission != LocationPermission.whileInUse){
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
await Geolocator.requestPermission();
|
|
|
|
}
|
2024-09-02 13:39:56 +01:00
|
|
|
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
|
|
|
_mapController.move(LatLng(position.latitude, position.longitude), 10);
|
2024-08-30 13:58:11 +01:00
|
|
|
setState(() {
|
2024-09-02 13:39:56 +01:00
|
|
|
_userPosition = LatLng(position.latitude, position.longitude);
|
2024-08-30 13:58:11 +01:00
|
|
|
});
|
2024-09-12 12:29:06 +01:00
|
|
|
LatLngBounds bounds = _mapController.camera.visibleBounds;
|
|
|
|
|
|
|
|
_getOpenStreetMapData(LatLng(bounds.southWest.latitude, bounds.southWest.longitude),LatLng(bounds.northEast.latitude, bounds.northEast.longitude));
|
2024-08-30 13:58:11 +01:00
|
|
|
}
|
|
|
|
|
2024-09-12 12:29:06 +01:00
|
|
|
Future<void> _getOpenStreetMapData(LatLng southWest, LatLng northEast) async {
|
|
|
|
|
|
|
|
final http.Response response;
|
|
|
|
response = await http.get(
|
|
|
|
Uri.parse('https://overpass-api.de/api/interpreter?data=[out:json][timeout:25];node["tourism"="attraction"](${southWest.latitude},${southWest.longitude},${northEast.latitude},${northEast.longitude});out geom;'),
|
|
|
|
);
|
|
|
|
|
|
|
|
final parsed = jsonDecode(utf8.decode(response.bodyBytes));
|
|
|
|
|
|
|
|
List<SearchResults> searchResults = parsed['elements']
|
|
|
|
.where((element) => element['tags'] != null && element['tags']['name'] != null)
|
|
|
|
.map<SearchResults>((json) => SearchResults.fromJson(json))
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
_searchResults = searchResults;
|
|
|
|
});
|
|
|
|
}
|
2024-09-02 13:39:56 +01:00
|
|
|
|
2024-08-29 12:21:00 +01:00
|
|
|
@override
|
2024-08-05 08:00:16 +01:00
|
|
|
Widget build(BuildContext context) {
|
2024-08-21 12:28:48 +01:00
|
|
|
return SideMenu(
|
2024-08-22 12:28:24 +01:00
|
|
|
selectedIndex: 0,
|
2024-08-21 12:28:48 +01:00
|
|
|
body: Scaffold(
|
2024-08-21 13:24:53 +01:00
|
|
|
key: _scaffoldKey,
|
2024-08-29 12:21:00 +01:00
|
|
|
body: Stack(
|
2024-08-21 14:37:44 +01:00
|
|
|
children: [
|
2024-08-29 12:21:00 +01:00
|
|
|
FlutterMap(
|
2024-09-02 13:39:56 +01:00
|
|
|
mapController: _mapController,
|
2024-08-29 12:21:00 +01:00
|
|
|
options: MapOptions(
|
2024-08-30 13:58:11 +01:00
|
|
|
initialCenter: _currentPosition,
|
2024-08-29 12:21:00 +01:00
|
|
|
initialZoom: _zoom,
|
|
|
|
onTap: _onTap,
|
|
|
|
onPositionChanged: (pos, _) => _zoom = pos.zoom,
|
|
|
|
),
|
|
|
|
children: [
|
|
|
|
openStreetMapTileLayer,
|
|
|
|
MarkerLayer(markers: [
|
2024-08-30 13:58:11 +01:00
|
|
|
if (_selectedPoint != null)
|
2024-08-29 12:21:00 +01:00
|
|
|
Marker(
|
|
|
|
point: _selectedPoint!,
|
|
|
|
width: 30,
|
|
|
|
height: 50,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: const Stack(
|
|
|
|
children: [
|
|
|
|
Icon(Icons.location_pin, size: 30, color: Colors.red),
|
|
|
|
Icon(Icons.location_on_outlined, size: 30, color: Colors.black),
|
|
|
|
],
|
|
|
|
),
|
2024-08-30 13:58:11 +01:00
|
|
|
),
|
2024-09-02 13:39:56 +01:00
|
|
|
if(_userPosition != null)
|
|
|
|
Marker(
|
|
|
|
point: _userPosition!,
|
|
|
|
width: 20,
|
|
|
|
height: 20,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: const Icon(Icons.my_location, size: 15, color: Colors.blueAccent),
|
|
|
|
),
|
2024-08-29 12:21:00 +01:00
|
|
|
]),
|
2024-09-02 13:39:56 +01:00
|
|
|
..._searchResults.map((point) => MarkerLayer(
|
|
|
|
markers: [
|
|
|
|
Marker(
|
|
|
|
point: point.location,
|
|
|
|
width: 30,
|
|
|
|
height: 50,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
icon: const Icon(Icons.location_pin, size: 30, color: Colors.red),
|
2024-09-12 12:29:06 +01:00
|
|
|
onPressed: () => _showLocation(point.location, point.name, ""),
|
2024-09-02 13:39:56 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
2024-09-03 12:33:50 +01:00
|
|
|
..._reviews.map((review) => MarkerLayer(
|
|
|
|
markers: [
|
|
|
|
Marker(
|
|
|
|
point: LatLng(review.lat, review.lng),
|
|
|
|
width: 30,
|
|
|
|
height: 50,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.only(bottom: 10),
|
|
|
|
icon: const Icon(Icons.location_pin, size: 30, color:Colors.purpleAccent),
|
|
|
|
onPressed: () => _showLocation(LatLng(review.lat, review.lng), review.place_name, review.place_description),
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.only(bottom: 10),
|
|
|
|
icon: const Icon(Icons.location_on_outlined, size: 30, color: Colors.purple),
|
|
|
|
onPressed: () => _showLocation(LatLng(review.lat, review.lng), review.place_name, review.place_description),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
..._favorites.map((favorite) => MarkerLayer(
|
2024-08-29 12:21:00 +01:00
|
|
|
markers: [
|
|
|
|
Marker(
|
|
|
|
point: LatLng(favorite.lat, favorite.lng),
|
|
|
|
width: 30,
|
|
|
|
height: 50,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.only(bottom: 10),
|
|
|
|
icon: const Icon(Icons.location_pin, size: 30, color: Colors.yellow),
|
|
|
|
onPressed: () => _showLocation(LatLng(favorite.lat, favorite.lng), favorite.name, favorite.description),
|
|
|
|
),
|
|
|
|
IconButton(
|
|
|
|
padding: const EdgeInsets.only(bottom: 10),
|
|
|
|
icon: const Icon(Icons.location_on_outlined, size: 30, color: Colors.black),
|
|
|
|
onPressed: () => _showLocation(LatLng(favorite.lat, favorite.lng), favorite.name, favorite.description),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
bottom: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
child: SafeArea(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
2024-08-27 10:48:11 +01:00
|
|
|
child: Stack(
|
2024-08-27 07:53:56 +01:00
|
|
|
children: [
|
2024-08-29 12:21:00 +01:00
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: CupertinoSearchTextField(
|
|
|
|
controller: searchBarInput,
|
|
|
|
suffixMode: OverlayVisibilityMode.never,
|
2024-09-02 13:39:56 +01:00
|
|
|
placeholder: 'Search city based',
|
2024-09-03 08:47:07 +01:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
color: Colors.white.withOpacity(0.9),
|
|
|
|
boxShadow: const [BoxShadow(color: Color(0x20000000), offset: Offset(0, 1), blurRadius: 4)]
|
|
|
|
),
|
2024-08-29 12:21:00 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2024-08-27 10:48:11 +01:00
|
|
|
),
|
2024-09-03 08:47:07 +01:00
|
|
|
Positioned(
|
|
|
|
right: 2, // Position the button at the bottom-right
|
|
|
|
bottom: 4.5,
|
|
|
|
child:
|
|
|
|
SizedBox(
|
2024-08-30 13:58:11 +01:00
|
|
|
width: 100,
|
|
|
|
height: 28,
|
|
|
|
child: ElevatedButton(
|
2024-09-03 13:05:18 +01:00
|
|
|
onPressed: () {
|
2024-09-12 12:29:06 +01:00
|
|
|
_onSearch();
|
2024-09-03 13:05:18 +01:00
|
|
|
},
|
2024-09-03 08:47:07 +01:00
|
|
|
child: const Text('Search'),
|
|
|
|
),
|
|
|
|
),
|
2024-08-27 10:48:11 +01:00
|
|
|
),
|
2024-08-29 12:21:00 +01:00
|
|
|
],
|
2024-08-27 07:53:56 +01:00
|
|
|
),
|
2024-08-29 12:21:00 +01:00
|
|
|
),
|
|
|
|
),
|
2024-08-27 08:15:21 +01:00
|
|
|
),
|
2024-09-03 08:47:07 +01:00
|
|
|
Positioned(
|
|
|
|
right: 2,
|
|
|
|
bottom: 50,
|
|
|
|
child:
|
|
|
|
SizedBox(
|
|
|
|
width: 50,
|
|
|
|
height: 50,
|
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
children: [
|
|
|
|
const Icon(
|
|
|
|
Icons.circle,
|
|
|
|
color: Colors.white,
|
|
|
|
size: 48.0,
|
|
|
|
shadows: [BoxShadow(color: Color(0x20000000), offset: Offset(0, 1), blurRadius: 4)],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(3),
|
|
|
|
child: IconButton(
|
2024-08-30 13:58:11 +01:00
|
|
|
icon: const Icon(
|
2024-09-02 13:39:56 +01:00
|
|
|
Icons.location_searching,
|
|
|
|
color: Colors.blue,
|
2024-09-03 08:47:07 +01:00
|
|
|
size: 28.0,
|
2024-08-30 13:58:11 +01:00
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
_getCurrentLocation();
|
|
|
|
},
|
|
|
|
),
|
2024-09-03 08:47:07 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-08-30 13:58:11 +01:00
|
|
|
),
|
|
|
|
),
|
2024-08-21 14:37:44 +01:00
|
|
|
],
|
|
|
|
),
|
2024-08-21 12:28:48 +01:00
|
|
|
),
|
2024-08-05 08:00:16 +01:00
|
|
|
);
|
|
|
|
}
|
2024-08-20 15:46:13 +01:00
|
|
|
|
2024-08-21 12:28:48 +01:00
|
|
|
TileLayer get openStreetMapTileLayer => TileLayer(
|
2024-09-03 08:47:07 +01:00
|
|
|
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
|
|
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
|
|
|
|
);
|
2024-08-29 12:21:00 +01:00
|
|
|
}
|