79 lines
2.6 KiB
Dart
Executable File
79 lines
2.6 KiB
Dart
Executable File
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_font_icons/flutter_font_icons.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../../constant/colors.dart';
|
|
import '../../functions/launch.dart';
|
|
|
|
class ContactUsController extends GetxController {
|
|
final String phone1 = '+963992952235';
|
|
final String phone2 = '+963992952235';
|
|
final TimeOfDay workStartTime = const TimeOfDay(hour: 12, minute: 0);
|
|
final TimeOfDay workEndTime = const TimeOfDay(hour: 19, minute: 0);
|
|
|
|
bool _isWithinWorkTime(TimeOfDay now) {
|
|
return (now.hour > workStartTime.hour ||
|
|
(now.hour == workStartTime.hour &&
|
|
now.minute >= workStartTime.minute)) &&
|
|
(now.hour < workEndTime.hour ||
|
|
(now.hour == workEndTime.hour && now.minute <= workEndTime.minute));
|
|
}
|
|
|
|
void showContactDialog(BuildContext context) {
|
|
TimeOfDay now = TimeOfDay.now();
|
|
|
|
showCupertinoModalPopup(
|
|
context: context,
|
|
builder: (context) => CupertinoActionSheet(
|
|
title: Text('Contact Us'.tr),
|
|
message: Text('Choose a contact option'.tr),
|
|
actions: <Widget>[
|
|
if (_isWithinWorkTime(now))
|
|
CupertinoActionSheetAction(
|
|
child: Text(phone1),
|
|
onPressed: () => makePhoneCall(
|
|
phone1,
|
|
),
|
|
),
|
|
if (_isWithinWorkTime(now))
|
|
CupertinoActionSheetAction(
|
|
child: Text(phone2),
|
|
onPressed: () => makePhoneCall(phone2),
|
|
),
|
|
if (!_isWithinWorkTime(now))
|
|
CupertinoActionSheetAction(
|
|
child: Text(
|
|
'Work time is from 10:00 - 17:00.\nYou can send a WhatsApp message or email.'
|
|
.tr),
|
|
onPressed: () => Navigator.pop(context),
|
|
),
|
|
CupertinoActionSheetAction(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
const Icon(
|
|
FontAwesome.whatsapp,
|
|
color: AppColor.greenColor,
|
|
),
|
|
Text('Send WhatsApp Message'.tr),
|
|
],
|
|
),
|
|
onPressed: () =>
|
|
launchCommunication('whatsapp', phone1, 'Hello'.tr),
|
|
),
|
|
CupertinoActionSheetAction(
|
|
child: Text('Send Email'.tr),
|
|
onPressed: () =>
|
|
launchCommunication('email', 'support@sefer.live', 'Hello'.tr),
|
|
),
|
|
],
|
|
cancelButton: CupertinoActionSheetAction(
|
|
child: Text('Cancel'.tr),
|
|
onPressed: () => Navigator.pop(context),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|