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

Open Urls in Company Detail Page . #189

Merged
merged 3 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 44 additions & 3 deletions lib/src/pages/company_details.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

import '../models/company_model.dart';
import 'package:url_launcher/url_launcher.dart';

/// Popup page for viewing company details when a company
/// is clicked on the Company Scoreboard page.
Expand All @@ -19,6 +19,43 @@ class CompanyDetailPage extends StatefulWidget {
class _CompanyDetailPageState extends State<CompanyDetailPage> {
late Color companyColor;

Future<void> sendEmail(BuildContext context,Company company) async{
fredfalcon marked this conversation as resolved.
Show resolved Hide resolved
SnackBar emailSnack = SnackBar(
content: Text("This company has not provided their email ."),
duration: Duration(seconds: 2),
);
if(company.email == null){
ScaffoldMessenger.of(context).showSnackBar(emailSnack);
}else{
String email = Uri.encodeComponent(company.email!);
Uri mail = Uri.parse("mailto:${email}");
try {
await launchUrl(mail);
}
catch(e){}
}
}

Future<void> redirectSite(BuildContext context,Company company) async{
SnackBar siteSnack = SnackBar(
content: Text("This company has not provided their site ."),
duration: Duration(seconds: 2),
);
if(company.url == null){
ScaffoldMessenger.of(context).showSnackBar(siteSnack);
}
else{
String siteUrl = Uri.encodeComponent(company.url!);
Uri site = Uri.parse(siteUrl);
try {
await launchUrl(site);
}
catch(e){}

}
}


Widget buildOpenIssueList(Size size) {
return Container(
width: size.width,
Expand Down Expand Up @@ -177,7 +214,9 @@ class _CompanyDetailPageState extends State<CompanyDetailPage> {
alignment: MainAxisAlignment.start,
children: [
TextButton.icon(
onPressed: () {},
onPressed: () {
sendEmail(context, widget.company);
fredfalcon marked this conversation as resolved.
Show resolved Hide resolved
},
icon: Icon(
Icons.email,
color: Colors.white,
Expand All @@ -198,7 +237,9 @@ class _CompanyDetailPageState extends State<CompanyDetailPage> {
),
),
TextButton.icon(
onPressed: () {},
onPressed: () {
redirectSite(context, widget.company);
},
icon: Icon(
Icons.public,
color: Colors.white,
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
intl: ^0.17.0
flutter_secure_storage: ^5.0.2
smooth_page_indicator: ^1.0.0+2
url_launcher: ^6.1.10
#flutter_lints: ^1.0.4

dev_dependencies:
Expand Down