anyway/frontend/lib/modules/map_chooser.dart
Remy Moll d24bc2470b
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m50s
navigation intent gets opened correctly
2024-08-11 16:06:20 +02:00

53 lines
1.6 KiB
Dart

import 'package:anyway/structs/landmark.dart';
import 'package:flutter/material.dart';
import 'package:map_launcher/map_launcher.dart';
import 'package:flutter_svg/flutter_svg.dart';
showMapChooser(BuildContext context, Landmark current, Landmark next) async {
List availableMaps = [];
try {
availableMaps = await MapLauncher.installedMaps;
} catch (e) {
print(e);
}
if (availableMaps.isEmpty) {
return;
}
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return SafeArea(
child: SingleChildScrollView(
child: Container(
child: Wrap(
children: <Widget>[
for (var map in availableMaps)
ListTile(
onTap: () => map.showDirections(
origin: Coords(current.location[0], current.location[1]),
originTitle: current.name,
destination: Coords(next.location[0], next.location[1]),
destinationTitle: current.name,
directionsMode: DirectionsMode.walking
),
title: Text(map.mapName),
// rounded corners
leading: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: SvgPicture.asset(
map.icon,
height: 30.0,
width: 30.0,
),
)
),
],
),
),
),
);
},
);
}