25-12-1/1

This commit is contained in:
Hamza-Ayed
2025-12-01 07:53:52 +03:00
parent 1a0bf1ee32
commit 11dfe94bbb
49 changed files with 19013 additions and 15915 deletions

View File

@@ -1,3 +1,4 @@
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
@@ -7,10 +8,9 @@ import '../../../constant/colors.dart';
import '../functions/launch.dart';
class ContactUsController extends GetxController {
final String phone1 = '+201018805430';
final String phone2 = '+201080182934';
final TimeOfDay workStartTime = const TimeOfDay(hour: 12, minute: 0);
final TimeOfDay workEndTime = const TimeOfDay(hour: 19, minute: 0);
/// WORKING HOURS (10:00 → 16:00)
final TimeOfDay workStartTime = const TimeOfDay(hour: 10, minute: 0);
final TimeOfDay workEndTime = const TimeOfDay(hour: 16, minute: 0);
bool _isWithinWorkTime(TimeOfDay now) {
return (now.hour > workStartTime.hour ||
@@ -20,8 +20,23 @@ class ContactUsController extends GetxController {
(now.hour == workEndTime.hour && now.minute <= workEndTime.minute));
}
/// PHONE LIST (USED FOR CALLS + WHATSAPP)
final List<String> phoneNumbers = [
'+963952475734',
'+963952475740',
'+963952475742'
];
/// RANDOM PHONE SELECTOR
String getRandomPhone() {
final random = Random();
return phoneNumbers[random.nextInt(phoneNumbers.length)];
}
/// SHOW DIALOG
void showContactDialog(BuildContext context) {
TimeOfDay now = TimeOfDay.now();
bool withinHours = _isWithinWorkTime(now);
showCupertinoModalPopup(
context: context,
@@ -29,25 +44,34 @@ class ContactUsController extends GetxController {
title: Text('Contact Us'.tr),
message: Text('Choose a contact option'.tr),
actions: <Widget>[
if (_isWithinWorkTime(now))
/// 📞 CALL (RANDOM) — ONLY DURING WORK HOURS
if (withinHours)
CupertinoActionSheetAction(
child: Text(phone1),
onPressed: () => makePhoneCall(
phone1,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(CupertinoIcons.phone),
Text('Call Support'.tr),
],
),
onPressed: () {
final phone = getRandomPhone();
makePhoneCall(phone);
},
),
if (_isWithinWorkTime(now))
CupertinoActionSheetAction(
child: Text(phone2),
onPressed: () => makePhoneCall(phone2),
),
if (!_isWithinWorkTime(now))
/// ⛔ OUTSIDE WORK HOURS — SHOW INFO
if (!withinHours)
CupertinoActionSheetAction(
child: Text(
'Work time is from 12:00 - 19:00.\nYou can send a WhatsApp message or email.'
.tr),
'Work time is from 10:00 AM to 16:00 PM.\nYou can send a WhatsApp message or email.'
.tr,
textAlign: TextAlign.center,
),
onPressed: () => Navigator.pop(context),
),
/// 💬 WHATSAPP (RANDOM)
CupertinoActionSheetAction(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@@ -59,15 +83,21 @@ class ContactUsController extends GetxController {
Text('Send WhatsApp Message'.tr),
],
),
onPressed: () =>
launchCommunication('whatsapp', phone1, 'Hello'.tr),
onPressed: () {
final phone = getRandomPhone();
launchCommunication('whatsapp', phone, 'Hello'.tr);
},
),
/// 📧 EMAIL
CupertinoActionSheetAction(
child: Text('Send Email'.tr),
onPressed: () =>
launchCommunication('email', 'support@sefer.live', 'Hello'.tr),
onPressed: () => launchCommunication(
'email', 'support@intaleqapp.com', 'Hello'.tr),
),
],
/// ❌ CANCEL BUTTON
cancelButton: CupertinoActionSheetAction(
child: Text('Cancel'.tr),
onPressed: () => Navigator.pop(context),