Application/medcify/lib/pages/main/home/whatsapp_share.dart

63 lines
2.3 KiB
Dart
Raw Normal View History

2022-09-26 06:33:52 +00:00
import 'package:flutter/material.dart';
import 'package:medcify/storage/storage.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../constants.dart';
class WhatsappShare extends StatelessWidget {
String url;
String name;
WhatsappShare(this.url, this.name);
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Constants.primaryColor,
borderRadius: BorderRadius.circular(4)
),
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 16,vertical: 24),
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async{
await launch(Storage.instance.storeUrl);
},
child: Center(
child: Text("Your URL: $url",style: const TextStyle(color: Colors.white, height: 1.6,fontSize: 16),textAlign: TextAlign.center,)
),
),
const SizedBox(height: 16,),
const Text("Share your online pharmacy with everyone and get orders",style: TextStyle(color: Colors.white, height: 1.6,fontSize: 16, fontWeight: FontWeight.w500),textAlign: TextAlign.center,),
const SizedBox(height: 16,),
MaterialButton(
onPressed: () async{
String text = "Hello, $name has launched its online pharmacy which lets you order medicines online and get doorstep delivery or self pickup option. To order medicines online , go to ";
await launch("https://wa.me/?text=$text$url");
},
elevation: 0,
height: 50,
minWidth: double.infinity,
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30)
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
ImageIcon(AssetImage("assets/images/whatsapp.png"),color: Colors.green,),
SizedBox(width: 8,),
Text("Share On Whatsapp",style: TextStyle(color: Colors.green,fontWeight: FontWeight.w600, fontSize: 15),)
],
),
),
],
),
);
}
}