Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Button to Open Circuit Link in Browser #271

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/ui/views/projects/project_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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';
Expand Down Expand Up @@ -64,6 +65,20 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
);
}

Widget _buildOpenActionButton() {
return Padding(
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);
},
icon: const Icon(Icons.link_rounded),
),
);
}

Widget _buildProjectPreview() {
return Container(
height: 400,
Expand Down Expand Up @@ -585,6 +600,7 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
appBar: AppBar(
title: const Text('Project Details'),
actions: [
_buildOpenActionButton(),
_buildShareActionButton(),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/url_launcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default , keep it launchUrlString(url) without mode: LaunchMode.externalApplication

Pass an varibale in function openInExternalApplication with default value False

Do the necessary changes, in the mode: LaunchMode.externalApplication also.

} else {
throw 'Could not launch $url';
}
Expand Down