You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.4KB

  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/svg.dart';
  3. import '../../themes/app_dimension.dart';
  4. import '../../themes/app_colors.dart';
  5. import '../../themes/styles_text.dart';
  6. class DialogWidget extends StatelessWidget {
  7. final String icon;
  8. final Color? iconColor;
  9. final String title;
  10. final String message;
  11. final String confirmTitle;
  12. final String? cancelTitle;
  13. final String? otherTitle;
  14. final Widget? customWidget;
  15. final Function onPressedConfirm;
  16. final Function? onPressedCancel;
  17. final Function? onPressedOther;
  18. final Color? colorConfirmButton;
  19. const DialogWidget({
  20. Key? key,
  21. required this.icon,
  22. required this.title,
  23. required this.message,
  24. required this.confirmTitle,
  25. required this.onPressedConfirm,
  26. this.iconColor,
  27. this.customWidget,
  28. this.onPressedCancel,
  29. this.cancelTitle,
  30. this.onPressedOther,
  31. this.otherTitle,
  32. this.colorConfirmButton,
  33. }) : super(key: key);
  34. @override
  35. Widget build(BuildContext context) {
  36. return SingleChildScrollView(
  37. child: Column(
  38. mainAxisSize: MainAxisSize.min,
  39. children: [
  40. SizedBox(
  41. height: 35.h,
  42. ),
  43. SvgPicture.asset(icon, color: iconColor),
  44. SizedBox(
  45. height: 13.h,
  46. ),
  47. Padding(
  48. padding: EdgeInsets.only(left: 30.0.w, right: 30.0.w),
  49. child: Text(
  50. title,
  51. style: StylesText.header1,
  52. textAlign: TextAlign.center,
  53. ),
  54. ),
  55. const SizedBox(
  56. height: 10,
  57. ),
  58. Padding(
  59. padding: EdgeInsets.only(left: 30.0.w, right: 30.0.w),
  60. child: Text(
  61. message,
  62. style: StylesText.body3,
  63. textAlign: TextAlign.center,
  64. ),
  65. ),
  66. Container(
  67. padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 16.h),
  68. child: customWidget ?? const SizedBox.shrink(),
  69. ),
  70. Padding(
  71. padding: EdgeInsets.only(left: 30.0.w, right: 30.w, top: customWidget != null ? 0 : 40.h, bottom: 10.h),
  72. child: SizedBox(
  73. height: 48.h,
  74. width: double.infinity.w,
  75. child: ElevatedButton(
  76. onPressed: () {
  77. onPressedConfirm();
  78. },
  79. style: ButtonStyle(
  80. backgroundColor: MaterialStateProperty.resolveWith(
  81. (states) {
  82. return colorConfirmButton ?? AppColors.primary1;
  83. },
  84. ),
  85. shadowColor: MaterialStateProperty.resolveWith(
  86. (states) {
  87. return Colors.transparent;
  88. },
  89. ),
  90. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  91. RoundedRectangleBorder(
  92. borderRadius: BorderRadius.circular(0.0),
  93. ),
  94. ),
  95. ),
  96. child: Text(
  97. confirmTitle.toUpperCase(),
  98. style: StylesText.body5.copyWith(
  99. color: AppColors.white,
  100. ),
  101. ),
  102. ),
  103. ),
  104. ),
  105. cancelTitle != null
  106. ? Padding(
  107. padding: EdgeInsets.only(left: 30.0.w, right: 30.w, top: 0.h, bottom: 10.h),
  108. child: SizedBox(
  109. height: 48.h,
  110. width: double.infinity.w,
  111. child: ElevatedButton(
  112. onPressed: () {
  113. onPressedCancel!();
  114. },
  115. style: ButtonStyle(
  116. backgroundColor: MaterialStateProperty.resolveWith(
  117. (states) {
  118. return AppColors.white;
  119. },
  120. ),
  121. shadowColor: MaterialStateProperty.resolveWith(
  122. (states) {
  123. return Colors.transparent;
  124. },
  125. ),
  126. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  127. RoundedRectangleBorder(
  128. borderRadius: BorderRadius.circular(0.0),
  129. side: BorderSide(
  130. color: AppColors.primary1,
  131. ),
  132. ),
  133. ),
  134. ),
  135. child: Text(
  136. cancelTitle!.toUpperCase(),
  137. style: StylesText.body5.copyWith(
  138. color: AppColors.neutral1,
  139. ),
  140. ),
  141. ),
  142. ),
  143. )
  144. : const SizedBox.shrink(),
  145. otherTitle != null
  146. ? Padding(
  147. padding: EdgeInsets.only(left: 30.0.w, right: 30.w, top: 0.h, bottom: 10.h),
  148. child: SizedBox(
  149. height: 48.h,
  150. width: double.infinity.w,
  151. child: ElevatedButton(
  152. onPressed: () {
  153. onPressedOther!();
  154. },
  155. style: ButtonStyle(
  156. backgroundColor: MaterialStateProperty.resolveWith(
  157. (states) {
  158. return AppColors.white;
  159. },
  160. ),
  161. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  162. RoundedRectangleBorder(
  163. borderRadius: BorderRadius.circular(0.0),
  164. side: BorderSide(
  165. color: AppColors.primary1,
  166. ),
  167. ),
  168. ),
  169. ),
  170. child: Text(
  171. otherTitle!.toUpperCase(),
  172. style: StylesText.body5.copyWith(
  173. color: AppColors.neutral1,
  174. ),
  175. ),
  176. ),
  177. ),
  178. )
  179. : const SizedBox.shrink(),
  180. SizedBox(
  181. height: 40.h,
  182. )
  183. ],
  184. ),
  185. );
  186. }
  187. }