all_dialog.dart 4.8 KB

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