all_dialog.dart 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:nomo/app/constants/assets.dart';
  4. import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
  5. import 'package:nomo/config/translations/strings_enum.dart';
  6. import '../../config/theme/dark_theme_colors.dart';
  7. import '../constants/iconfont/iconfont.dart';
  8. import 'custom_dialog.dart';
  9. /// 弹窗使用示例
  10. class AllDialog {
  11. /// 显示绑定邮箱/会员权益弹窗
  12. static void showBindEmailMemberBenefits() {
  13. CustomDialog.showInfo(
  14. title: Strings.bindEmailMemberBenefits.tr,
  15. message: Strings.bindingAccountEmailProtectsPreRights.tr,
  16. icon: IconFont.icon23,
  17. iconColor: DarkThemeColors.subscriptionColor,
  18. );
  19. }
  20. /// 显示Premium激活成功弹窗
  21. static void showPremiumActivated() {
  22. CustomDialog.showSuccess(
  23. title: Strings.premiumActivated.tr,
  24. message: Strings.premiumActivatedMessage.tr,
  25. buttonText: Strings.gotIt.tr,
  26. icon: Icons.workspace_premium,
  27. iconColor: const Color(0xFFFF9500),
  28. onPressed: () {
  29. // 处理激活成功后的逻辑
  30. Navigator.of(Get.context!).pop();
  31. },
  32. );
  33. }
  34. /// 显示邮件发送成功弹窗
  35. static void showEmailSent() {
  36. CustomDialog.showInfo(
  37. title: Strings.emailSent.tr,
  38. message: Strings.emailSentMessage.tr,
  39. buttonText: Strings.ok.tr,
  40. icon: Icons.mark_email_read,
  41. iconColor: Colors.white,
  42. onPressed: () {
  43. // 处理邮件发送成功后的逻辑
  44. Navigator.of(Get.context!).pop();
  45. },
  46. );
  47. }
  48. /// 显示网络连接错误弹窗
  49. static void showNetworkError() {
  50. CustomDialog.showError(
  51. title: Strings.noInternetConnection.tr,
  52. message: Strings.noInternetMessage.tr,
  53. buttonText: Strings.retry.tr,
  54. cancelText: Strings.cancel.tr,
  55. icon: Icons.wifi_off,
  56. iconColor: const Color.fromARGB(255, 231, 152, 5),
  57. confirmButtonColor: Get.reactiveTheme.primaryColor,
  58. errorCode: '',
  59. onPressed: () {
  60. // 处理重试逻辑
  61. Navigator.of(Get.context!).pop();
  62. },
  63. onCancel: () {
  64. // 处理取消逻辑
  65. Navigator.of(Get.context!).pop();
  66. },
  67. );
  68. }
  69. /// 显示退出登录确认弹窗
  70. static void showLogoutConfirm(Function() onLogout) {
  71. CustomDialog.showError(
  72. title: Strings.logOut.tr,
  73. message: Strings.logOutConfirmMessage.tr,
  74. buttonText: Strings.logOut.tr,
  75. cancelText: Strings.cancel.tr,
  76. icon: Icons.info_outline,
  77. iconColor: const Color(0xFFFF3B30),
  78. confirmButtonColor: const Color(0xFFFF3B30),
  79. onPressed: () {
  80. // 处理退出登录逻辑
  81. Navigator.of(Get.context!).pop();
  82. onLogout();
  83. },
  84. onCancel: () {
  85. // 处理取消退出逻辑
  86. Navigator.of(Get.context!).pop();
  87. },
  88. );
  89. }
  90. /// 显示反馈弹窗
  91. static void showFeedback() {
  92. CustomDialog.showInfo(
  93. title: Strings.thankYouFeedback.tr,
  94. message: Strings.feedbackMessage.tr,
  95. buttonText: Strings.done.tr,
  96. icon: Icons.favorite_border,
  97. iconColor: Get.theme.textTheme.bodyLarge!.color,
  98. onPressed: () {
  99. // 处理邮件发送成功后的逻辑
  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: Strings.whatIsUid.tr,
  110. message: Strings.uidMessage.tr,
  111. buttonText: Strings.ok.tr,
  112. onPressed: () {
  113. // 处理邮件发送成功后的逻辑
  114. print('UID info dialog closed');
  115. Navigator.of(Get.context!).pop();
  116. },
  117. );
  118. }
  119. /// 显示无效授权码弹窗
  120. static void showInvalidAuthorizationCode() {
  121. CustomDialog.showError(
  122. title: Strings.invalidAuthorizationCode.tr,
  123. message: Strings.invalidAuthorizationCodeMessage.tr,
  124. buttonText: Strings.invalidAuthorizationCodeButton.tr,
  125. onPressed: () {
  126. // 处理重试逻辑
  127. Navigator.of(Get.context!).pop();
  128. },
  129. onCancel: () {
  130. // 处理取消逻辑
  131. Navigator.of(Get.context!).pop();
  132. },
  133. );
  134. }
  135. // 显示删除账户确认弹窗
  136. static void showDeleteAccountConfirm(Function() onDeleteAccount) {
  137. CustomDialog.showError(
  138. title: Strings.deleteAccount.tr,
  139. message: Strings.deleteAccountConfirmMessage.tr,
  140. buttonText: Strings.deleteAccount.tr,
  141. cancelText: Strings.cancel.tr,
  142. icon: IconFont.icon40,
  143. iconColor: DarkThemeColors.deleteAccountIconColor,
  144. onPressed: () {
  145. // 处理删除账户逻辑
  146. Navigator.of(Get.context!).pop();
  147. onDeleteAccount();
  148. },
  149. onCancel: () {
  150. // 处理取消删除账户逻辑
  151. Navigator.of(Get.context!).pop();
  152. },
  153. );
  154. }
  155. /// 显示更新弹窗
  156. static void showUpdate({bool hasForceUpdate = false}) {
  157. CustomDialog.showUpdateDialog(
  158. title: Strings.newVersionAvailable.tr,
  159. message:
  160. "A newer version of the app is ready.\nThis update improves stability and performance, and fixes known issues.",
  161. buttonText: Strings.upgradeNow.tr,
  162. cancelText: hasForceUpdate ? null : Strings.cancel.tr,
  163. onCancel: () {
  164. Navigator.of(Get.context!).pop();
  165. },
  166. svgPath: Assets.update,
  167. onPressed: () {
  168. Navigator.of(Get.context!).pop();
  169. },
  170. );
  171. }
  172. /// 显示自定义成功弹窗
  173. static void showCustomSuccess({
  174. required String title,
  175. required String message,
  176. String? buttonText,
  177. VoidCallback? onPressed,
  178. }) {
  179. CustomDialog.showSuccess(
  180. title: title,
  181. message: message,
  182. buttonText: buttonText ?? Strings.gotIt.tr,
  183. onPressed: onPressed,
  184. );
  185. }
  186. /// 显示自定义信息弹窗
  187. static void showCustomInfo({
  188. required String title,
  189. required String message,
  190. String? buttonText,
  191. VoidCallback? onPressed,
  192. }) {
  193. CustomDialog.showInfo(
  194. title: title,
  195. message: message,
  196. buttonText: buttonText ?? Strings.ok.tr,
  197. onPressed: onPressed,
  198. );
  199. }
  200. /// 显示自定义错误弹窗
  201. static void showCustomError({
  202. required String title,
  203. required String message,
  204. String? buttonText,
  205. String? cancelText,
  206. VoidCallback? onPressed,
  207. VoidCallback? onCancel,
  208. String? errorCode,
  209. }) {
  210. CustomDialog.showError(
  211. title: title,
  212. message: message,
  213. buttonText: buttonText ?? Strings.retry.tr,
  214. cancelText: cancelText,
  215. onPressed: onPressed,
  216. onCancel: onCancel,
  217. errorCode: errorCode,
  218. );
  219. }
  220. /// 显示自定义确认弹窗
  221. static void showCustomConfirm({
  222. required String title,
  223. required String message,
  224. String? confirmText,
  225. String? cancelText,
  226. required VoidCallback onConfirm,
  227. VoidCallback? onCancel,
  228. Color? confirmButtonColor,
  229. }) {
  230. CustomDialog.showConfirm(
  231. title: title,
  232. message: message,
  233. confirmText: confirmText ?? Strings.confirm.tr,
  234. cancelText: cancelText ?? Strings.cancel.tr,
  235. onConfirm: onConfirm,
  236. onCancel: onCancel,
  237. confirmButtonColor: confirmButtonColor,
  238. );
  239. }
  240. }