Update: 2026-06-14 05:48:58

This commit is contained in:
Hamza-Ayed
2026-06-14 05:48:58 +03:00
parent 2645ed0cf1
commit 8e3b9eca4d
22 changed files with 789 additions and 179 deletions

View File

@@ -7,6 +7,7 @@ import 'package:get/get.dart';
import '../../constant/colors.dart';
import '../../constant/style.dart';
import '../../controller/functions/tts.dart';
import '../../controller/functions/translate_helper.dart';
// ─────────────────────────────────────────────────────────────────────────────
// Config
@@ -417,6 +418,167 @@ class MyDialog extends GetxController {
barrierColor: _DC.barrierColor,
);
}
void getChatDialog(
String title,
String messageContent,
VoidCallback onPressed, {
IconData? icon,
}) {
HapticFeedback.mediumImpact();
String displayedText = messageContent;
bool isTranslated = false;
bool isLoading = false;
Get.dialog(
StatefulBuilder(
builder: (dialogContext, setState) {
return _DialogShell(
child: _GlassCard(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// ── Body ──────────────────────────────────────────────
Padding(
padding: const EdgeInsets.fromLTRB(24, 28, 24, 20),
child: Column(
children: [
// Icon badge
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: AppColor.primaryColor.withOpacity(0.1),
border: Border.all(
color: AppColor.primaryColor.withOpacity(0.2),
),
),
child: Icon(
icon ?? Icons.chat_bubble_outline_rounded,
color: AppColor.primaryColor,
size: 26,
),
),
const SizedBox(height: 16),
// Title
Text(
title.tr,
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(
fontSize: 18,
fontWeight: FontWeight.w700,
letterSpacing: -0.4,
color: AppColor.writeColor,
),
),
const SizedBox(height: 10),
if (isLoading)
const Padding(
padding: EdgeInsets.symmetric(vertical: 20),
child: Center(
child: CupertinoActivityIndicator(radius: 12),
),
)
else
Text(
displayedText,
textAlign: TextAlign.center,
style: AppStyle.subtitle.copyWith(
fontSize: 14.5,
height: 1.5,
color: Colors.grey[600],
),
),
const SizedBox(height: 16),
// TTS button
_SpeakButton(
texts: [title.tr, displayedText],
),
],
),
),
// ── Actions ───────────────────────────────────────────
Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Colors.grey.withOpacity(0.15), width: 1),
),
),
child: Row(
children: [
// Translate Toggle
Expanded(
child: _ActionButton(
label: isTranslated ? 'Original'.tr : 'Translate'.tr,
color: AppColor.blueColor,
backgroundColor: AppColor.blueColor.withOpacity(0.07),
onPressed: () async {
if (isLoading) return;
HapticFeedback.lightImpact();
if (isTranslated) {
setState(() {
displayedText = messageContent;
isTranslated = false;
});
} else {
setState(() {
isLoading = true;
});
try {
final targetLang = Get.locale?.languageCode ?? 'ar';
final translated = await TranslateHelper.translateText(messageContent, targetLang);
setState(() {
displayedText = translated;
isTranslated = true;
isLoading = false;
});
} catch (e) {
setState(() {
isLoading = false;
});
}
}
},
isLeft: true,
),
),
Container(width: 1, height: 52, color: Colors.grey.withOpacity(0.15)),
// Confirm
Expanded(
child: _ActionButton(
label: 'OK'.tr,
color: AppColor.primaryColor,
backgroundColor: AppColor.primaryColor.withOpacity(0.07),
onPressed: () {
HapticFeedback.mediumImpact();
Navigator.of(dialogContext, rootNavigator: true).pop();
Future.delayed(const Duration(milliseconds: 100), () {
onPressed();
});
},
isLeft: false,
isBold: true,
),
),
],
),
),
],
),
),
);
},
),
barrierDismissible: true,
barrierColor: _DC.barrierColor,
);
}
}
// ─────────────────────────────────────────────────────────────────────────────