Frontend UX improvements #37
| @@ -23,6 +23,15 @@ class LandmarkCard extends StatefulWidget { | |||||||
| class _LandmarkCardState extends State<LandmarkCard> { | class _LandmarkCardState extends State<LandmarkCard> { | ||||||
|   @override |   @override | ||||||
|   Widget build(BuildContext context) { |   Widget build(BuildContext context) { | ||||||
|  |     if (widget.landmark.type == typeStart || widget.landmark.type == typeFinish) { | ||||||
|  |       return TextButton.icon( | ||||||
|  |         onPressed: () {}, | ||||||
|  |         icon: widget.landmark.type.icon, | ||||||
|  |         label: Text(widget.landmark.name), | ||||||
|  |       ); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |     // else: | ||||||
|     return Container( |     return Container( | ||||||
|       child: Card( |       child: Card( | ||||||
|         shape: RoundedRectangleBorder( |         shape: RoundedRectangleBorder( | ||||||
| @@ -93,7 +102,10 @@ class _LandmarkCardState extends State<LandmarkCard> { | |||||||
|                 ) |                 ) | ||||||
|               ], |               ], | ||||||
|             ), |             ), | ||||||
|           SingleChildScrollView( |           Padding(padding: EdgeInsets.only(top: 10)), | ||||||
|  |           Align( | ||||||
|  |             alignment: Alignment.centerLeft, | ||||||
|  |             child: SingleChildScrollView( | ||||||
|               // allows the buttons to be scrolled |               // allows the buttons to be scrolled | ||||||
|               scrollDirection: Axis.horizontal, |               scrollDirection: Axis.horizontal, | ||||||
|               child: Wrap( |               child: Wrap( | ||||||
| @@ -120,15 +132,6 @@ class _LandmarkCardState extends State<LandmarkCard> { | |||||||
|                       icon: Icon(Icons.link), |                       icon: Icon(Icons.link), | ||||||
|                       label: Text('Website'), |                       label: Text('Website'), | ||||||
|                     ), |                     ), | ||||||
|                 // if (widget.landmark.wikipediaURL != null) |  | ||||||
|                 //   TextButton.icon( |  | ||||||
|                 //     onPressed: () async { |  | ||||||
|                 //       // open a browser with the wikipedia link |  | ||||||
|                 //       await launchUrl(Uri.parse(widget.landmark.wikipediaURL!)); |  | ||||||
|                 //     }, |  | ||||||
|                 //     icon: Icon(Icons.book), |  | ||||||
|                 //   label: Text('Wikipedia'), |  | ||||||
|                 // ), |  | ||||||
|                   PopupMenuButton( |                   PopupMenuButton( | ||||||
|                     icon: Icon(Icons.settings), |                     icon: Icon(Icons.settings), | ||||||
|                     style: TextButtonTheme.of(context).style, |                     style: TextButtonTheme.of(context).style, | ||||||
| @@ -138,14 +141,10 @@ class _LandmarkCardState extends State<LandmarkCard> { | |||||||
|                           leading: Icon(Icons.delete), |                           leading: Icon(Icons.delete), | ||||||
|                           title: Text('Delete'), |                           title: Text('Delete'), | ||||||
|                           onTap: () async { |                           onTap: () async { | ||||||
|                           setState(() { |  | ||||||
|                             widget.parentTrip.removeLandmark(widget.landmark); |                             widget.parentTrip.removeLandmark(widget.landmark); | ||||||
|                           }); |  | ||||||
|                             rootScaffoldMessengerKey.currentState!.showSnackBar( |                             rootScaffoldMessengerKey.currentState!.showSnackBar( | ||||||
|                               SnackBar(content: Text("We won't show ${widget.landmark.name} again")) |                               SnackBar(content: Text("We won't show ${widget.landmark.name} again")) | ||||||
|                             ); |                             ); | ||||||
|  |  | ||||||
|  |  | ||||||
|                           }, |                           }, | ||||||
|                         ), |                         ), | ||||||
|                       ), |                       ), | ||||||
| @@ -156,17 +155,16 @@ class _LandmarkCardState extends State<LandmarkCard> { | |||||||
|                           onTap: () async { |                           onTap: () async { | ||||||
|                             // delete the landmark |                             // delete the landmark | ||||||
|                             // await deleteLandmark(widget.landmark); |                             // await deleteLandmark(widget.landmark); | ||||||
|  |  | ||||||
|                           }, |                           }, | ||||||
|                         ), |                         ), | ||||||
|                       ), |                       ), | ||||||
|  |  | ||||||
|                     ], |                     ], | ||||||
|                   ) |                   ) | ||||||
|                      |                      | ||||||
|                 ], |                 ], | ||||||
|               ), |               ), | ||||||
|             ), |             ), | ||||||
|  |           ), | ||||||
|         ], |         ], | ||||||
|       ), |       ), | ||||||
|     ); |     ); | ||||||
|   | |||||||
| @@ -93,6 +93,11 @@ patchLandmarkImage(Landmark landmark) async { | |||||||
|     if (newUrl != null) { |     if (newUrl != null) { | ||||||
|       landmark.imageURL = newUrl; |       landmark.imageURL = newUrl; | ||||||
|     } |     } | ||||||
|  |   } else if (landmark.imageURL!.contains("photos.app.goo.gl")) { | ||||||
|  |     // the image is a google photos link, we should get the image behind the link | ||||||
|  |     String? newUrl = await getImageUrlFromGooglePhotos(landmark.imageURL!); | ||||||
|  |     // also set the new url if it is null | ||||||
|  |     landmark.imageURL = newUrl;  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -58,3 +58,14 @@ Future<String?> getImageUrlFromName(String title) async { | |||||||
|     } |     } | ||||||
|     return await getImageUrl(pageId); |     return await getImageUrl(pageId); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Future<String?> getImageUrlFromGooglePhotos(String url) async { | ||||||
|  |     // this is a very simple implementation that just gets the image behind the link | ||||||
|  |     // it is not guaranteed to work for all google photos links | ||||||
|  |     final response = await dio.get(url); | ||||||
|  |     final data = response.toString(); | ||||||
|  |     final int start = data.indexOf("https://lh3.googleusercontent.com"); | ||||||
|  |     final int end = data.indexOf('"', start); | ||||||
|  |     return data.substring(start, end); | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user