location picker and ui fixes #17
							
								
								
									
										52
									
								
								frontend/lib/modules/map_chooser.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								frontend/lib/modules/map_chooser.dart
									
									
									
									
									
										Normal 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, | ||||
|                       ), | ||||
|                     ) | ||||
|                   ), | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|         ), | ||||
|       ); | ||||
|     }, | ||||
|   ); | ||||
| } | ||||
| @@ -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: [ | ||||
|   | ||||
| @@ -1,6 +1,14 @@ | ||||
| # Generated by pub | ||||
| # See https://dart.dev/tools/pub/glossary#lockfile | ||||
| packages: | ||||
|   args: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: args | ||||
|       sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.5.0" | ||||
|   async: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @@ -174,6 +182,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.0.21" | ||||
|   flutter_svg: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: flutter_svg | ||||
|       sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.0.10+1" | ||||
|   flutter_test: | ||||
|     dependency: "direct dev" | ||||
|     description: flutter | ||||
| @@ -320,6 +336,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "4.0.0" | ||||
|   map_launcher: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: map_launcher | ||||
|       sha256: af59b9f79f641022e06761c9d4217c6c57b9ef9020af2fdb23155ec87af79e61 | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "3.3.1" | ||||
|   matcher: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @@ -368,6 +392,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.9.0" | ||||
|   path_parsing: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: path_parsing | ||||
|       sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.0.1" | ||||
|   path_provider: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @@ -416,6 +448,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.3.0" | ||||
|   petitparser: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: petitparser | ||||
|       sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "6.0.2" | ||||
|   platform: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @@ -629,6 +669,30 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "4.4.2" | ||||
|   vector_graphics: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: vector_graphics | ||||
|       sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.1.11+1" | ||||
|   vector_graphics_codec: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: vector_graphics_codec | ||||
|       sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.1.11+1" | ||||
|   vector_graphics_compiler: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: vector_graphics_compiler | ||||
|       sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.1.11+1" | ||||
|   vector_math: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @@ -669,6 +733,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.0.4" | ||||
|   xml: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: xml | ||||
|       sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "6.5.0" | ||||
| sdks: | ||||
|   dart: ">=3.4.0 <4.0.0" | ||||
|   flutter: ">=3.22.0" | ||||
|   | ||||
| @@ -45,6 +45,8 @@ dependencies: | ||||
|   widget_to_marker: ^1.0.6 | ||||
|   provider: ^6.1.2 | ||||
|   auto_size_text: ^3.0.0 | ||||
|   map_launcher: ^3.3.1 | ||||
|   flutter_svg: ^2.0.10+1 | ||||
|  | ||||
| dev_dependencies: | ||||
|   flutter_test: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user