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.
606 lines
26 KiB
Dart
606 lines
26 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../core/constants/app_assets.dart';
|
|
import '../core/constants/translation_keys.dart';
|
|
import '../core/utils/app_utils.dart';
|
|
import '../models/TransactionSubmitRequestModel.dart';
|
|
import '../res/app_colors.dart';
|
|
import '../res/app_dimensions.dart';
|
|
import '../routes/app_pages.dart';
|
|
import 'custom_button.dart';
|
|
|
|
|
|
class CustomDialog {
|
|
/// SuccessFull Dialog...........Transactions
|
|
|
|
static _showBasicDialog(Widget child) {
|
|
Get.dialog(responsiveWidget(child), barrierDismissible: false);
|
|
}
|
|
|
|
/// Warning Dialog
|
|
static showWarningDialog({
|
|
//required String title,
|
|
required String description,
|
|
// Function()? onTapPositive,
|
|
required Function() onTapNegative,
|
|
}) {
|
|
_showBasicDialog(Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Align(
|
|
alignment: Directionality.of(Get.context!) == TextDirection.rtl ? Alignment.topLeft : Alignment.topRight,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.of(Get.context!, rootNavigator: true).pop();
|
|
},
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_cross,
|
|
height: 14,
|
|
width: 14,
|
|
))),
|
|
Container(
|
|
height: 40,
|
|
width: 40,
|
|
decoration: const BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(50)),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
SvgPicture.asset(
|
|
AppAssets.ic_featured,
|
|
),
|
|
Center(
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_close,
|
|
height: 6,
|
|
width: 6,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textWarning), style: Theme.of(Get.context!).textTheme.titleMedium?.copyWith(color: AppColors.colorDialogBG)),
|
|
const SizedBox(height: 20),
|
|
Text(description, style: Theme.of(Get.context!).textTheme.bodyMedium),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
CustomButton(
|
|
onPressed: () {
|
|
onTapNegative();
|
|
},
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textYes),
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 30),
|
|
textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16, color: AppColors.black),
|
|
buttonColor: AppColors.colorSkipBtn,
|
|
sideBorder: const BorderSide(color: AppColors.colorBorderSkipBtn, width: 1.0),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
/// Error Dialog
|
|
static showErrorDialog({
|
|
//required String title,
|
|
required String description,
|
|
// Function()? onClosePress,
|
|
required Function() onTapNegative,
|
|
}) {
|
|
_showBasicDialog(Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Align(
|
|
alignment: Directionality.of(Get.context!) == TextDirection.rtl ? Alignment.topLeft : Alignment.topRight,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.of(Get.context!, rootNavigator: true).pop();
|
|
},
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_cross,
|
|
height: 14,
|
|
width: 14,
|
|
))),
|
|
Container(
|
|
height: 40,
|
|
width: 40,
|
|
decoration: const BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(50)),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
SvgPicture.asset(
|
|
AppAssets.ic_featured,
|
|
),
|
|
Center(
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_close,
|
|
height: 6,
|
|
width: 6,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 20),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textError), style: Theme.of(Get.context!).textTheme.titleMedium?.copyWith(color: AppColors.colorDialogBG)),
|
|
const SizedBox(height: 20),
|
|
Text(description, style: Theme.of(Get.context!).textTheme.bodyMedium),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
CustomButton(
|
|
onPressed: () {
|
|
onTapNegative();
|
|
},
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textOK),
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 30),
|
|
buttonColor: AppColors.colorButton,
|
|
//sideBorder: const BorderSide(color: AppColors.colorBorderSkipBtn, width: 1.0),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
/// Success Dialog
|
|
static showSuccessDialog({
|
|
String? title,
|
|
required String description,
|
|
required Function() onTapPositive,
|
|
}) {
|
|
_showBasicDialog(Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
height: 60,
|
|
width: 60,
|
|
padding: const EdgeInsets.only(bottom: 5),
|
|
decoration: const BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(50)),
|
|
),
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_congratulations,
|
|
),
|
|
),
|
|
if (title != null) ...[
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Text(
|
|
title,
|
|
style: Theme.of(Get.context!).textTheme.titleMedium?.copyWith(color: AppColors.colorGrey800),
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
],
|
|
Text(description, style: Theme.of(Get.context!).textTheme.bodyMedium),
|
|
const SizedBox(height: 10),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 80.0, right: 80.0),
|
|
child: CustomButton(
|
|
onPressed: () {
|
|
Navigator.of(Get.context!, rootNavigator: true).pop();
|
|
onTapPositive();
|
|
},
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textContinue),
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
|
|
buttonColor: AppColors.colorButton,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
|
|
/// Information Dialog
|
|
static showInfoDialog({
|
|
required String title,
|
|
required String description,
|
|
required Function() onTapPositive,
|
|
}) {
|
|
_showBasicDialog(Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
height: 40,
|
|
width: 40,
|
|
decoration: const BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(50)),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
SvgPicture.asset(
|
|
AppAssets.ic_congratulations,
|
|
),
|
|
Center(
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_correct_icon,
|
|
height: 22,
|
|
width: 22,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Text(TranslationKeys.makeTranslation(TranslationKeys.textInform), style: Theme.of(Get.context!).textTheme.titleMedium?.copyWith(color: AppColors.colorDialogBG)),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(description, style: Theme.of(Get.context!).textTheme.bodyMedium),
|
|
const SizedBox(height: 10),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 80.0, right: 80.0),
|
|
child: CustomButton(
|
|
onPressed: () {
|
|
onTapPositive();
|
|
},
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textContinue),
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
|
buttonColor: AppColors.colorButton,
|
|
//sideBorder: const BorderSide(color: AppColors.colorBorderSkipBtn, width: 1.0),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
/// Information Dialog
|
|
static showLogoutDialog({
|
|
required Function() onTapPositive,
|
|
required Function() onTapNegative,
|
|
required BuildContext context,
|
|
}) {
|
|
_showBasicDialog(Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
height: 60,
|
|
width: 60,
|
|
padding: const EdgeInsets.only(bottom: 5),
|
|
decoration: const BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(50)),
|
|
),
|
|
child: SvgPicture.asset(
|
|
AppAssets.ic_congratulations,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Text(TranslationKeys.makeTranslation(TranslationKeys.textLogOut), style: Theme.of(Get.context!).textTheme.titleMedium?.copyWith(color: AppColors.colorDialogBG)),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textLogOutContent), style: Theme.of(Get.context!).textTheme.bodyMedium),
|
|
const SizedBox(height: 10),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: CustomButton(
|
|
onPressed: onTapNegative,
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textCancel),
|
|
buttonColor: AppColors.red,
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 10),
|
|
),
|
|
),
|
|
SizedBox(width: 15),
|
|
Expanded(
|
|
flex: 1,
|
|
child: CustomButton(
|
|
onPressed: onTapPositive,
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textOK),
|
|
buttonColor: AppColors.colorButton,
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 10),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
/// Alert Dialog
|
|
static showAlertDialog({
|
|
required Function() onTapPositive,
|
|
required Function() onTapNegative,
|
|
required BuildContext context,
|
|
}) {
|
|
_showBasicDialog(Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(AppDimensions.radiusCard)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
height: 60,
|
|
width: 60,
|
|
padding: const EdgeInsets.only(bottom: 5),
|
|
decoration: const BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(50)),
|
|
),
|
|
child: Image.asset(
|
|
AppAssets.ic_warning,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Text(TranslationKeys.makeTranslation(TranslationKeys.textWarning), style: Theme.of(Get.context!).textTheme.titleMedium?.copyWith(color: AppColors.colorDialogBG)),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textWarningContent), style: Theme.of(Get.context!).textTheme.bodyMedium),
|
|
const SizedBox(height: 10),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
Expanded(
|
|
flex: 1,
|
|
child: CustomButton(
|
|
onPressed: onTapNegative,
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textCancel),
|
|
buttonColor: AppColors.red,
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 10),
|
|
),
|
|
),
|
|
const SizedBox(width: 15),
|
|
Expanded(
|
|
flex: 1,
|
|
child: CustomButton(
|
|
onPressed: onTapPositive,
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textDelete),
|
|
buttonColor: AppColors.colorButton,
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 10),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
static showGeneralDialog({
|
|
required String title,
|
|
required String description,
|
|
required Widget child,
|
|
}) {
|
|
_showBasicDialog(child);
|
|
}
|
|
|
|
static void showTransactionSuccessDialog(BuildContext context, String endingBalance, String exchangeRate, TransactionSubmitRequestModel transactionSubmitRequestModel) {
|
|
Get.dialog(
|
|
responsiveWidget(
|
|
Stack(
|
|
children: [
|
|
Dialog(
|
|
backgroundColor: Colors.transparent,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ListView(
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
children: [
|
|
Image.asset(AppAssets.ic_launcher, height: 80, width: 80),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 20),
|
|
child: Align(alignment: Alignment.center, child: Text(TranslationKeys.makeTranslation(TranslationKeys.textSuccess), style: Theme.of(context).textTheme.titleMedium)),
|
|
),
|
|
const SizedBox(height: 15),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
flex: 3,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textRecipient), style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textMessage), style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textSendingAmount), style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textExchangeRate), style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(TranslationKeys.makeTranslation(TranslationKeys.textEndingBalance), style: Theme.of(context).textTheme.bodySmall),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(width: 20),
|
|
Expanded(
|
|
flex: 2,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(transactionSubmitRequestModel.crMbmBkmstitle, style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(transactionSubmitRequestModel.otdTrancomment, style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(AppUtils.showAmountWithCurr(transactionSubmitRequestModel.sgtGntramtfc.toString(), transactionSubmitRequestModel.crPcrCurrcode), style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(exchangeRate, style: Theme.of(context).textTheme.bodySmall),
|
|
const SizedBox(height: 10),
|
|
Text(endingBalance, style: Theme.of(context).textTheme.bodySmall),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 80),
|
|
child: CustomButton(
|
|
onPressed: () {
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
Get.offAllNamed(Routes.DASHBOARD_SCREEN);
|
|
},
|
|
buttonText: TranslationKeys.makeTranslation(TranslationKeys.textOK),
|
|
buttonColor: AppColors.colorButton,
|
|
buttonPadding: const EdgeInsets.symmetric(vertical: 5, horizontal: 10),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
barrierDismissible: false,
|
|
);
|
|
}
|
|
}
|