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
Changes from 2 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
17 changes: 17 additions & 0 deletions lib/ui/views/projects/project_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -64,6 +66,20 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
);
}

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, mode: LaunchMode.externalApplication);
Copy link
Member

@tanmoysrt tanmoysrt Feb 28, 2023

Choose a reason for hiding this comment

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

There is already an predefined function for launchUrl in lib/utils/url_launcher.dart, kindly use that function to open the link and do require changes if required.

Copy link
Author

Choose a reason for hiding this comment

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

i have changed the code accordingly , please review the code.

},
icon: const Icon(Icons.link_rounded),
),
);
}

Widget _buildProjectPreview() {
return Container(
height: 400,
Expand Down Expand Up @@ -585,6 +601,7 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
appBar: AppBar(
title: const Text('Project Details'),
actions: [
_buildOpenActionButton(),
_buildShareActionButton(),
],
),
Expand Down