From 5e53737d6d3efe5bd27e5be46feacdd9023f6acb Mon Sep 17 00:00:00 2001 From: Deepanshu Saini Date: Mon, 27 Feb 2023 23:32:35 +0530 Subject: [PATCH 1/4] added button to Open Circuit Link in Browser, issue#261 --- lib/ui/views/projects/project_details_view.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 21b5228d..42531836 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -14,11 +14,13 @@ import 'package:mobile_app/ui/views/profile/profile_view.dart'; import 'package:mobile_app/ui/views/projects/edit_project_view.dart'; import 'package:mobile_app/ui/views/projects/project_preview_fullscreen_view.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; +import 'package:mobile_app/utils/url_launcher.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/viewmodels/projects/project_details_viewmodel.dart'; import 'package:photo_view/photo_view.dart'; import 'package:share/share.dart'; import 'package:transparent_image/transparent_image.dart'; +import 'package:url_launcher/url_launcher.dart'; class ProjectDetailsView extends StatefulWidget { const ProjectDetailsView({Key? key, required this.project}) : super(key: key); @@ -64,6 +66,20 @@ class _ProjectDetailsViewState extends State { ); } + Widget _buildOpenActionButton() { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: IconButton( + onPressed: () async { + final url = Uri.parse( + 'https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}'); + await launchUrl(url); + }, + icon: const Icon(Icons.link_rounded), + ), + ); + } + Widget _buildProjectPreview() { return Container( height: 400, @@ -585,6 +601,7 @@ class _ProjectDetailsViewState extends State { appBar: AppBar( title: const Text('Project Details'), actions: [ + _buildOpenActionButton(), _buildShareActionButton(), ], ), From 80289f8913fb67ca6ced6b4c7c7634a65d3c6c4d Mon Sep 17 00:00:00 2001 From: Deepanshu Saini Date: Mon, 27 Feb 2023 23:35:32 +0530 Subject: [PATCH 2/4] added button to Open Circuit Link in Browser, issue#261 --- lib/ui/views/projects/project_details_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 42531836..d6183cee 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -73,7 +73,7 @@ class _ProjectDetailsViewState extends State { onPressed: () async { final url = Uri.parse( 'https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}'); - await launchUrl(url); + await launchUrl(url, mode: LaunchMode.externalApplication); }, icon: const Icon(Icons.link_rounded), ), From 97fc95d2af5fee658179fc8ea3e5e0245460b02e Mon Sep 17 00:00:00 2001 From: Deepanshu Saini <114583893+sainideepanshu199@users.noreply.github.com> Date: Sat, 4 Mar 2023 11:58:47 +0530 Subject: [PATCH 3/4] added url_launcher utility to open circuit link --- lib/ui/views/projects/project_details_view.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index d6183cee..75a1d65a 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -20,8 +20,6 @@ import 'package:mobile_app/viewmodels/projects/project_details_viewmodel.dart'; import 'package:photo_view/photo_view.dart'; import 'package:share/share.dart'; import 'package:transparent_image/transparent_image.dart'; -import 'package:url_launcher/url_launcher.dart'; - class ProjectDetailsView extends StatefulWidget { const ProjectDetailsView({Key? key, required this.project}) : super(key: key); @@ -71,9 +69,9 @@ class _ProjectDetailsViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 8), child: IconButton( onPressed: () async { - final url = Uri.parse( + final url = ( 'https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}'); - await launchUrl(url, mode: LaunchMode.externalApplication); + launchURL(url), }, icon: const Icon(Icons.link_rounded), ), From c869ae9421ada5ec353149edad52bf9c528c53a4 Mon Sep 17 00:00:00 2001 From: Deepanshu Saini Date: Sat, 4 Mar 2023 12:01:38 +0530 Subject: [PATCH 4/4] fixed a minor launch issue --- lib/ui/views/projects/project_details_view.dart | 7 ++++--- lib/utils/url_launcher.dart | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 75a1d65a..7c2e8255 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -20,6 +20,7 @@ import 'package:mobile_app/viewmodels/projects/project_details_viewmodel.dart'; import 'package:photo_view/photo_view.dart'; import 'package:share/share.dart'; import 'package:transparent_image/transparent_image.dart'; + class ProjectDetailsView extends StatefulWidget { const ProjectDetailsView({Key? key, required this.project}) : super(key: key); @@ -69,9 +70,9 @@ class _ProjectDetailsViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 8), child: IconButton( onPressed: () async { - final url = ( - 'https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}'); - launchURL(url), + final url = + ('https://circuitverse.org/users/${widget.project.relationships.author.data.id}/projects/${widget.project.id}'); + launchURL(url); }, icon: const Icon(Icons.link_rounded), ), diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index 1284793e..444b11b8 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -2,7 +2,7 @@ import 'package:url_launcher/url_launcher_string.dart'; void launchURL(String url) async { if (await canLaunchUrlString(url)) { - await launchUrlString(url); + await launchUrlString(url, mode: LaunchMode.externalApplication); } else { throw 'Could not launch $url'; }