110 lines
3.1 KiB
Dart
110 lines
3.1 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../../constant/colors.dart';
|
|
import '../../constant/style.dart';
|
|
import '../../controller/functions/tts.dart';
|
|
import 'elevated_btn.dart';
|
|
|
|
class MyDialog extends GetxController {
|
|
void getDialog(String title, String? midTitle, VoidCallback onPressed) {
|
|
final textToSpeechController = Get.put(TextToSpeechController());
|
|
|
|
Get.dialog(
|
|
BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
|
child: CupertinoAlertDialog(
|
|
title: Text(
|
|
title,
|
|
style: AppStyle.title.copyWith(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
content: Column(
|
|
children: [
|
|
CupertinoButton(
|
|
onPressed: () async {
|
|
await textToSpeechController.speakText(title ?? midTitle!);
|
|
},
|
|
child: const Icon(CupertinoIcons.headphones,
|
|
color: AppColor.primaryColor),
|
|
),
|
|
Text(
|
|
midTitle!,
|
|
style: AppStyle.title.copyWith(fontSize: 16),
|
|
),
|
|
],
|
|
),
|
|
actions: [
|
|
CupertinoDialogAction(
|
|
child: const Text('Cancel',
|
|
style: TextStyle(color: AppColor.redColor)),
|
|
onPressed: () {
|
|
Get.back();
|
|
},
|
|
),
|
|
CupertinoDialogAction(
|
|
onPressed: onPressed,
|
|
child: Text('OK'.tr,
|
|
style: const TextStyle(color: AppColor.greenColor)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
barrierDismissible: false,
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyDialogContent extends GetxController {
|
|
void getDialog(String title, Widget? content, VoidCallback onPressed) {
|
|
final textToSpeechController = Get.put(TextToSpeechController());
|
|
|
|
Get.dialog(
|
|
BackdropFilter(
|
|
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
|
|
child: CupertinoAlertDialog(
|
|
title: Text(
|
|
title,
|
|
style: AppStyle.title.copyWith(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
content: Column(
|
|
children: [
|
|
CupertinoButton(
|
|
onPressed: () async {
|
|
await textToSpeechController.speakText(title);
|
|
},
|
|
child: const Icon(CupertinoIcons.speaker_2,
|
|
color: AppColor.primaryColor),
|
|
),
|
|
content!
|
|
],
|
|
),
|
|
actions: [
|
|
CupertinoDialogAction(
|
|
child: const Text('Cancel',
|
|
style: TextStyle(color: AppColor.redColor)),
|
|
onPressed: () {
|
|
Get.back();
|
|
},
|
|
),
|
|
CupertinoDialogAction(
|
|
onPressed: onPressed,
|
|
child: Text('OK'.tr,
|
|
style: const TextStyle(color: AppColor.greenColor)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
barrierDismissible: false,
|
|
);
|
|
}
|
|
}
|