navigation intent gets opened correctly
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m50s

This commit is contained in:
2024-08-11 16:06:20 +02:00
parent 6d3399640e
commit d24bc2470b
4 changed files with 130 additions and 8 deletions

View File

@@ -0,0 +1,52 @@
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,
),
)
),
],
),
),
),
);
},
);
}

View File

@@ -1,5 +1,6 @@
import 'package:anyway/structs/landmark.dart';
import 'package:flutter/material.dart';
import 'package:anyway/modules/map_chooser.dart';
class StepBetweenLandmarks extends StatefulWidget {
final Landmark current;
@@ -18,7 +19,7 @@ class StepBetweenLandmarks extends StatefulWidget {
class _StepBetweenLandmarksState extends State<StepBetweenLandmarks> {
@override
Widget build(BuildContext context) {
int timeRounded = 5 * (widget.current.tripTime?.inMinutes ?? 0) ~/ 5;
int timeRounded = 5 * ((widget.current.tripTime?.inMinutes ?? 0) ~/ 5);
// ~/ is integer division (rounding)
return Container(
margin: EdgeInsets.all(10),
@@ -27,11 +28,6 @@ class _StepBetweenLandmarksState extends State<StepBetweenLandmarks> {
border: Border(
left: BorderSide(width: 3.0, color: Colors.black),
),
// gradient: LinearGradient(
// begin: Alignment.topLeft,
// end: Alignment.bottomRight,
// colors: [Colors.grey, Colors.white, Colors.white],
// ),
),
child: Row(
children: [
@@ -43,8 +39,8 @@ class _StepBetweenLandmarksState extends State<StepBetweenLandmarks> {
),
Spacer(),
ElevatedButton(
onPressed: () {
// Open navigation instructions
onPressed: () async {
showMapChooser(context, widget.current, widget.next);
},
child: Row(
children: [