all_dialog.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
  4. import '../constants/iconfont/iconfont.dart';
  5. import 'custom_dialog.dart';
  6. /// 弹窗使用示例
  7. class AllDialog {
  8. /// 显示Premium激活成功弹窗
  9. static void showPremiumActivated() {
  10. CustomDialog.showSuccess(
  11. title: 'Premium Activated Successfully !',
  12. message:
  13. 'You\'ve been upgraded to Premium. Enjoy all advanced features and an enhanced browsing experience.',
  14. buttonText: 'Got it',
  15. icon: Icons.workspace_premium,
  16. iconColor: const Color(0xFFFF9500),
  17. onPressed: () {
  18. // 处理激活成功后的逻辑
  19. print('Premium activated successfully');
  20. Navigator.of(Get.context!).pop();
  21. },
  22. );
  23. }
  24. /// 显示邮件发送成功弹窗
  25. static void showEmailSent() {
  26. CustomDialog.showInfo(
  27. title: 'Email Sent Successfully',
  28. message:
  29. 'Your Pre Code has been sent to your email.\nPlease check your inbox (and spam folder).',
  30. buttonText: 'OK',
  31. icon: Icons.mark_email_read,
  32. iconColor: Colors.white,
  33. onPressed: () {
  34. // 处理邮件发送成功后的逻辑
  35. print('Email sent successfully');
  36. Navigator.of(Get.context!).pop();
  37. },
  38. );
  39. }
  40. /// 显示网络连接错误弹窗
  41. static void showNetworkError() {
  42. CustomDialog.showError(
  43. title: 'No Internet Connection',
  44. message:
  45. 'It looks like you\'re offline. Please check your internet connection and try again.',
  46. buttonText: 'Retry',
  47. cancelText: 'Cancel',
  48. icon: Icons.wifi_off,
  49. iconColor: const Color.fromARGB(255, 231, 152, 5),
  50. confirmButtonColor: Get.reactiveTheme.primaryColor,
  51. errorCode: '',
  52. onPressed: () {
  53. // 处理重试逻辑
  54. print('Retry network connection');
  55. Navigator.of(Get.context!).pop();
  56. },
  57. onCancel: () {
  58. // 处理取消逻辑
  59. print('Cancel network retry');
  60. Navigator.of(Get.context!).pop();
  61. },
  62. );
  63. }
  64. /// 显示退出登录确认弹窗
  65. static void showLogoutConfirm() {
  66. CustomDialog.showError(
  67. title: 'Log Out?',
  68. message:
  69. 'Are you sure you want to log out? You\'ll need to sign in again to access your Premium features.',
  70. buttonText: 'Log Out',
  71. cancelText: 'Cancel',
  72. icon: Icons.info_outline,
  73. iconColor: const Color(0xFFFF3B30),
  74. confirmButtonColor: const Color(0xFFFF3B30),
  75. onPressed: () {
  76. // 处理退出登录逻辑
  77. print('User confirmed logout');
  78. // 这里可以调用退出登录的API
  79. Navigator.of(Get.context!).pop();
  80. },
  81. onCancel: () {
  82. // 处理取消退出逻辑
  83. print('User cancelled logout');
  84. Navigator.of(Get.context!).pop();
  85. },
  86. );
  87. }
  88. /// 显示反馈弹窗
  89. static void showFeedback() {
  90. CustomDialog.showInfo(
  91. title: 'Thank you for your feedback!',
  92. message:
  93. 'We’re sorry you’re not enjoying your experience. We’ll do our best to improve it soon.',
  94. buttonText: 'Done',
  95. icon: Icons.favorite_border,
  96. iconColor: Get.theme.textTheme.bodyLarge!.color,
  97. onPressed: () {
  98. // 处理邮件发送成功后的逻辑
  99. print('Feedback submitted successfully');
  100. Navigator.of(Get.context!).pop();
  101. },
  102. );
  103. }
  104. /// 显示UID信息弹窗
  105. static void showUidInfo() {
  106. CustomDialog.showInfo(
  107. icon: IconFont.icon14,
  108. iconColor: Get.theme.textTheme.bodyLarge!.color,
  109. title: 'What is UID?',
  110. message:
  111. 'Device ID (UID) This is your device\'s unique identifier. Providing this ID helps our support team verify your device and resolve your issues more quickly.',
  112. buttonText: 'OK',
  113. onPressed: () {
  114. // 处理邮件发送成功后的逻辑
  115. print('UID info dialog closed');
  116. Navigator.of(Get.context!).pop();
  117. },
  118. );
  119. }
  120. /// 显示自定义成功弹窗
  121. static void showCustomSuccess({
  122. required String title,
  123. required String message,
  124. String? buttonText,
  125. VoidCallback? onPressed,
  126. }) {
  127. CustomDialog.showSuccess(
  128. title: title,
  129. message: message,
  130. buttonText: buttonText ?? 'Got it',
  131. onPressed: onPressed,
  132. );
  133. }
  134. /// 显示自定义信息弹窗
  135. static void showCustomInfo({
  136. required String title,
  137. required String message,
  138. String? buttonText,
  139. VoidCallback? onPressed,
  140. }) {
  141. CustomDialog.showInfo(
  142. title: title,
  143. message: message,
  144. buttonText: buttonText ?? 'OK',
  145. onPressed: onPressed,
  146. );
  147. }
  148. /// 显示自定义错误弹窗
  149. static void showCustomError({
  150. required String title,
  151. required String message,
  152. String? buttonText,
  153. String? cancelText,
  154. VoidCallback? onPressed,
  155. VoidCallback? onCancel,
  156. String? errorCode,
  157. }) {
  158. CustomDialog.showError(
  159. title: title,
  160. message: message,
  161. buttonText: buttonText ?? 'Retry',
  162. cancelText: cancelText,
  163. onPressed: onPressed,
  164. onCancel: onCancel,
  165. errorCode: errorCode,
  166. );
  167. }
  168. /// 显示自定义确认弹窗
  169. static void showCustomConfirm({
  170. required String title,
  171. required String message,
  172. String? confirmText,
  173. String? cancelText,
  174. required VoidCallback onConfirm,
  175. VoidCallback? onCancel,
  176. Color? confirmButtonColor,
  177. }) {
  178. CustomDialog.showConfirm(
  179. title: title,
  180. message: message,
  181. confirmText: confirmText ?? 'Confirm',
  182. cancelText: cancelText ?? 'Cancel',
  183. onConfirm: onConfirm,
  184. onCancel: onCancel,
  185. confirmButtonColor: confirmButtonColor,
  186. );
  187. }
  188. }