You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.4 KiB
Dart
109 lines
3.4 KiB
Dart
|
1 month ago
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:get/get.dart';
|
||
|
|
import 'package:quickalert/models/quickalert_type.dart';
|
||
|
|
import 'package:quickalert/widgets/quickalert_dialog.dart';
|
||
|
|
|
||
|
|
import '../core/constants/translation_keys.dart';
|
||
|
|
import '../core/extensions/build_context_ext.dart';
|
||
|
|
import '../res/app_colors.dart';
|
||
|
|
|
||
|
|
|
||
|
|
class PopDialog {
|
||
|
|
static late BuildContext dialogContext;
|
||
|
|
|
||
|
|
static successDialog(
|
||
|
|
BuildContext context, {
|
||
|
|
String title = "",
|
||
|
|
String description = "An Success occurred",
|
||
|
|
String positiveButtonText = "",
|
||
|
|
Function()? onPositiveTap,
|
||
|
|
}) {
|
||
|
|
QuickAlert.show(
|
||
|
|
context: context,
|
||
|
|
title: title.isEmpty ? TranslationKeys.makeTranslation(TranslationKeys.textSuccess) : title,
|
||
|
|
text: description,
|
||
|
|
confirmBtnColor: AppColors.colorButton,
|
||
|
|
confirmBtnTextStyle: Theme.of(context).textTheme.titleMedium?.copyWith(color: AppColors.colorSecondary),
|
||
|
|
confirmBtnText: positiveButtonText.isEmpty ? TranslationKeys.makeTranslation(TranslationKeys.textOK) : positiveButtonText,
|
||
|
|
onConfirmBtnTap: () {
|
||
|
|
Navigator.of(context, rootNavigator: true).pop();
|
||
|
|
if (onPositiveTap != null) {
|
||
|
|
onPositiveTap();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
disableBackBtn: true,
|
||
|
|
type: QuickAlertType.success,
|
||
|
|
barrierDismissible: false,
|
||
|
|
showConfirmBtn: true,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
static warningDialog(
|
||
|
|
BuildContext context, {
|
||
|
|
String title = "",
|
||
|
|
String description = "",
|
||
|
|
String positiveButtonText = "",
|
||
|
|
String negativeButtonText = "",
|
||
|
|
Function()? onPositiveTap,
|
||
|
|
Function()? onNegativeTap,
|
||
|
|
}) {
|
||
|
|
QuickAlert.show(
|
||
|
|
showCancelBtn: true,
|
||
|
|
context: context,
|
||
|
|
title: title.isEmpty ? TranslationKeys.makeTranslation(TranslationKeys.textWarning) : title,
|
||
|
|
confirmBtnColor: AppColors.colorButton,
|
||
|
|
text: description,
|
||
|
|
confirmBtnTextStyle: Theme.of(context).textTheme.titleMedium?.copyWith(color: AppColors.colorSecondary),
|
||
|
|
confirmBtnText: positiveButtonText.isEmpty ? TranslationKeys.makeTranslation(TranslationKeys.textOK) : positiveButtonText,
|
||
|
|
cancelBtnText: negativeButtonText.isEmpty ? TranslationKeys.makeTranslation(TranslationKeys.textCancel) : negativeButtonText,
|
||
|
|
onCancelBtnTap: () {
|
||
|
|
Navigator.of(context, rootNavigator: true).pop();
|
||
|
|
if (onNegativeTap != null) {
|
||
|
|
onNegativeTap();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
onConfirmBtnTap: () {
|
||
|
|
Navigator.of(context, rootNavigator: true).pop();
|
||
|
|
if (onPositiveTap != null) {
|
||
|
|
onPositiveTap();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
disableBackBtn: true,
|
||
|
|
type: QuickAlertType.warning,
|
||
|
|
barrierDismissible: false,
|
||
|
|
showConfirmBtn: true,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
static Card buildButton({
|
||
|
|
required onTap,
|
||
|
|
required title,
|
||
|
|
required text,
|
||
|
|
required leadingImage,
|
||
|
|
}) {
|
||
|
|
return Card(
|
||
|
|
shape: const StadiumBorder(),
|
||
|
|
margin: const EdgeInsets.symmetric(
|
||
|
|
horizontal: 20,
|
||
|
|
),
|
||
|
|
clipBehavior: Clip.antiAlias,
|
||
|
|
elevation: 1,
|
||
|
|
child: ListTile(
|
||
|
|
onTap: onTap,
|
||
|
|
leading: CircleAvatar(
|
||
|
|
backgroundImage: AssetImage(
|
||
|
|
leadingImage,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
title: Text(
|
||
|
|
title ?? "",
|
||
|
|
),
|
||
|
|
subtitle: Text(text ?? "", style: Get.context.textTheme.bodySmall),
|
||
|
|
trailing: const Icon(
|
||
|
|
Icons.keyboard_arrow_right_rounded,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|