161 lines
4.3 KiB
Dart
161 lines
4.3 KiB
Dart
import 'package:discover_module/contacts_module/custom_widget/clickable_row.dart';
|
|
import 'package:discover_module/contacts_module/custom_widget/custiom_profilepic.dart';
|
|
import 'package:discover_module/contacts_module/custom_widget/custom_card.dart';
|
|
import 'package:discover_module/contacts_module/custom_widget/text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../constants.dart';
|
|
|
|
class ProfileCard extends StatefulWidget {
|
|
final String? name;
|
|
final String? spl;
|
|
final String? imgurl;
|
|
final String? email;
|
|
final String? pno;
|
|
final String? address;
|
|
const ProfileCard(
|
|
{super.key,
|
|
this.name,
|
|
this.spl,
|
|
this.imgurl,
|
|
this.email,
|
|
this.pno,
|
|
this.address});
|
|
|
|
@override
|
|
State<ProfileCard> createState() => _ProfileCardState();
|
|
}
|
|
|
|
class _ProfileCardState extends State<ProfileCard> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomCard(
|
|
elevation: 6,
|
|
color: Constants.profilecard,
|
|
bradius: 28,
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 15.0, right: 15.0, top: 15.0, bottom: 15.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Flexible(
|
|
flex: 7,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text1(
|
|
title: widget.name ?? " ",
|
|
txtcolor: Colors.white,
|
|
fontweight: FontWeight.bold,
|
|
txtfont: 18.0),
|
|
Text1(
|
|
title: widget.spl ?? "",
|
|
txtcolor: Colors.white,
|
|
fontweight: FontWeight.normal,
|
|
txtfont: 14.0),
|
|
],
|
|
),
|
|
),
|
|
Flexible(
|
|
flex: 3,
|
|
child: Container(
|
|
child: CustomProfile(
|
|
imgstring: widget.imgurl,
|
|
fontsize: 12.0,
|
|
radius: 32,
|
|
name: widget.name,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
ClickRow(
|
|
icon: Icons.email,
|
|
text: widget.email ?? "",
|
|
onTap: () async {
|
|
await emailSend(widget.email);
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 8.0,
|
|
),
|
|
ClickRow(
|
|
icon: Icons.phone,
|
|
text: widget.pno ?? "",
|
|
onTap: () async {
|
|
await callinfo(widget.pno);
|
|
},
|
|
),
|
|
SizedBox(
|
|
height: 8.0,
|
|
),
|
|
ClickRow(
|
|
icon: Icons.location_pin,
|
|
text: widget.address ??
|
|
"Icahn School of Medicine at mount sinai, United States 580047",
|
|
onTap: _openMapsByAddress,
|
|
),
|
|
SizedBox(
|
|
height: 8.0,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<void> _openMapsByAddress() async {
|
|
final address = 'Italy';
|
|
final Uri mapsUri = Uri(
|
|
scheme: 'https',
|
|
host: 'www.google.com',
|
|
path: 'maps/search/',
|
|
query: address,
|
|
);
|
|
|
|
if (!await launchUrl(mapsUri)) {
|
|
throw 'Could not launch $mapsUri';
|
|
}
|
|
}
|
|
|
|
Future<void> emailSend(email) async {
|
|
String? encodeQueryParameters(Map<String, String> params) {
|
|
return params.entries
|
|
.map((MapEntry<String, String> entry) =>
|
|
Uri.encodeComponent(entry.key) +
|
|
'=' +
|
|
Uri.encodeComponent(entry.value))
|
|
.join('&');
|
|
}
|
|
|
|
final Uri emailLaunchUri = Uri(
|
|
scheme: 'mailto',
|
|
path: email,
|
|
query: encodeQueryParameters(<String, String>{
|
|
'subject': 'Example Subject',
|
|
'body': 'Hello, this is a sample body text.',
|
|
}),
|
|
);
|
|
|
|
if (await launchUrl(emailLaunchUri)) {
|
|
launchUrl(emailLaunchUri);
|
|
} else {
|
|
throw 'Could not launch $emailLaunchUri';
|
|
}
|
|
}
|
|
|
|
Future<void> callinfo(pno) async {
|
|
final call = Uri.parse('tel:$pno');
|
|
if (await canLaunchUrl(call)) {
|
|
launchUrl(call);
|
|
} else {
|
|
throw 'Could not launch $call';
|
|
}
|
|
}
|