initialized Application theme

This commit is contained in:
Mohammad Salameh
2024-02-15 14:00:09 +03:00
parent 16f47f744c
commit 3190361901
98 changed files with 871 additions and 1004 deletions

View File

@ -0,0 +1,76 @@
import 'dart:io';
import 'package:url_launcher/url_launcher.dart';
class URLLauncher {
static Future<void> sendWhatsapp(
{String phoneNumber = '971581497062',
String text = 'Hi%2C%20I%20would%20like%20to',
String from = ''}) async {
Uri launchUri;
launchUri = Uri.parse("whatsapp://send?phone=%2B$phoneNumber&text=$text");
// Launch the App
try {
// SegmentEvents.sendTrackEvent(SegmentEventModel(
// eventName: 'Whatsapp opened', properties: {'From': from}));
//
// if (await canLaunchUrl(launchUri) == false) {
// CustomSnackBar.displaySnackBar('Could not open whatsapp');
// return;
// }
if (Platform.isAndroid) {
await launch(
launchUri.toString(),
);
} else {
await launchUrl(
launchUri,
);
}
} catch (error) {
// CustomSnackBar.displaySnackBar('Could not open whatsapp');
throw 'Could not launch $phoneNumber';
}
}
static Future<void> sendEmail(
{required String email, String subject = '', body = ''}) async {
String? encodeQueryParameters(Map<String, String> params) {
return params.entries
.map((MapEntry<String, String> e) =>
'${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value)}')
.join('&');
}
final emailLaunchUri = Uri(
scheme: 'mailto',
path: email,
query: encodeQueryParameters(<String, String>{
subject: body,
}),
);
try {
bool canLaunch = await canLaunchUrl(emailLaunchUri);
if (canLaunch) {
await launchUrl(emailLaunchUri);
}
} catch (err) {
throw 'Could not launch $emailLaunchUri';
}
}
static Future<void> launch(String url) async {
Uri parsedUrl = Uri.parse(url);
try {
bool canLaunch = await canLaunchUrl(parsedUrl);
if (canLaunch) {
await launchUrl(
parsedUrl,
// mode: LaunchMode.externalApplication,
);
}
} catch (err) {
throw 'Url launcher error: ${err.toString()}';
}
}
}