precode_view.dart 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:get/get.dart';
  4. import 'package:nomo/app/base/base_view.dart';
  5. import 'package:nomo/app/widgets/click_opacity.dart';
  6. import 'package:nomo/app/widgets/ix_image.dart';
  7. import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
  8. import '../../../../config/theme/dark_theme_colors.dart';
  9. import '../../../constants/assets.dart';
  10. import '../../../constants/iconfont/iconfont.dart';
  11. import '../../../widgets/ix_app_bar.dart';
  12. import '../../../widgets/submit_btn.dart';
  13. import '../controllers/precode_controller.dart';
  14. class PrecodeView extends BaseView<PrecodeController> {
  15. const PrecodeView({super.key});
  16. @override
  17. PreferredSizeWidget? get appBar => IXAppBar(title: 'My Pre Code');
  18. @override
  19. Widget buildContent(BuildContext context) {
  20. return Padding(
  21. padding: EdgeInsets.symmetric(horizontal: 14.w),
  22. child: Column(
  23. children: [
  24. 10.verticalSpaceFromWidth,
  25. // 说明卡片
  26. _buildInfoCard(),
  27. 30.verticalSpaceFromWidth,
  28. // Pre Code 显示
  29. _buildPreCodeDisplay(),
  30. 10.verticalSpaceFromWidth,
  31. // Preview/Hide 和 Copy 按钮
  32. _buildActionButtons(),
  33. 40.verticalSpaceFromWidth,
  34. // Send to Email 按钮
  35. _buildEmailButton(),
  36. 10.verticalSpaceFromWidth,
  37. // 说明文字
  38. Text(
  39. 'Send your Pre Code to your registered email address',
  40. textAlign: TextAlign.center,
  41. style: TextStyle(
  42. fontSize: 13.sp,
  43. height: 1.4,
  44. color: Get.reactiveTheme.hintColor,
  45. ),
  46. ),
  47. 10.verticalSpaceFromWidth,
  48. // Save Local Copy 按钮
  49. _buildSaveButton(),
  50. 12.verticalSpaceFromWidth,
  51. // 说明文字
  52. Text(
  53. 'Store a copy of your Pre Code on this device',
  54. textAlign: TextAlign.center,
  55. style: TextStyle(
  56. fontSize: 13.sp,
  57. height: 1.4,
  58. color: Get.reactiveTheme.hintColor,
  59. ),
  60. ),
  61. ],
  62. ),
  63. );
  64. }
  65. /// 说明卡片
  66. Widget _buildInfoCard() {
  67. return Container(
  68. width: double.infinity,
  69. padding: EdgeInsets.all(10.w),
  70. decoration: BoxDecoration(
  71. color: Get.reactiveTheme.highlightColor,
  72. borderRadius: BorderRadius.circular(8.r),
  73. ),
  74. child: Column(
  75. children: [
  76. // 铃铛图标
  77. Icon(
  78. IconFont.icon67,
  79. color: DarkThemeColors.validTermColor,
  80. size: 30.w,
  81. ),
  82. 10.verticalSpaceFromWidth,
  83. // 说明文字
  84. Text(
  85. 'Pre Code is your premium user credential.\nUse it to activate benefits or sync your account\non other devices.',
  86. textAlign: TextAlign.center,
  87. style: TextStyle(
  88. fontSize: 14.sp,
  89. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  90. height: 1.5,
  91. ),
  92. ),
  93. 20.verticalSpaceFromWidth,
  94. // 安全提示
  95. Text(
  96. 'Please store it securely !',
  97. textAlign: TextAlign.center,
  98. style: TextStyle(
  99. fontSize: 14.sp,
  100. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  101. height: 1.5,
  102. ),
  103. ),
  104. ],
  105. ),
  106. );
  107. }
  108. /// Pre Code 显示
  109. Widget _buildPreCodeDisplay() {
  110. return Obx(
  111. () => Text(
  112. controller.displayCode,
  113. style: TextStyle(
  114. fontSize: 34.sp,
  115. height: 1.2,
  116. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  117. fontWeight: FontWeight.w500,
  118. ),
  119. ),
  120. );
  121. }
  122. /// Preview/Hide 和 Copy 按钮
  123. Widget _buildActionButtons() {
  124. return Row(
  125. mainAxisAlignment: MainAxisAlignment.center,
  126. children: [
  127. // Preview/Hide 按钮
  128. Obx(
  129. () => ClickOpacity(
  130. onTap: controller.togglePreview,
  131. child: Row(
  132. mainAxisSize: MainAxisSize.min,
  133. children: [
  134. Text(
  135. controller.isPreviewMode.value ? 'Hide' : 'Preview',
  136. style: TextStyle(
  137. fontSize: 12.sp,
  138. height: 1.7,
  139. color: Get.reactiveTheme.hintColor,
  140. ),
  141. ),
  142. 8.horizontalSpace,
  143. Icon(
  144. controller.isPreviewMode.value
  145. ? IconFont.icon12
  146. : IconFont.icon13,
  147. color: Get.reactiveTheme.hintColor,
  148. size: 20.w,
  149. ),
  150. ],
  151. ),
  152. ),
  153. ),
  154. 20.horizontalSpace,
  155. Container(
  156. width: 1.w,
  157. height: 20.w,
  158. color: Get.reactiveTheme.dividerColor,
  159. ),
  160. 20.horizontalSpace,
  161. // Copy 按钮
  162. ClickOpacity(
  163. onTap: controller.copyCode,
  164. child: Row(
  165. mainAxisSize: MainAxisSize.min,
  166. children: [
  167. Text(
  168. 'Copy',
  169. style: TextStyle(
  170. fontSize: 12.sp,
  171. height: 1.7,
  172. color: Get.reactiveTheme.hintColor,
  173. ),
  174. ),
  175. 8.horizontalSpace,
  176. Icon(
  177. IconFont.icon57,
  178. color: Get.reactiveTheme.hintColor,
  179. size: 20.w,
  180. ),
  181. ],
  182. ),
  183. ),
  184. ],
  185. );
  186. }
  187. /// Send to Email 按钮
  188. Widget _buildEmailButton() {
  189. return SubmitButton(
  190. prefixIcon: IXImage(
  191. source: Assets.preCodeEmail,
  192. width: 20.w,
  193. height: 20.w,
  194. sourceType: ImageSourceType.asset,
  195. ),
  196. text: 'Send to Email',
  197. bgColor: Get.reactiveTheme.highlightColor,
  198. onPressed: controller.sendToEmail,
  199. );
  200. }
  201. /// Save Local Copy 按钮
  202. Widget _buildSaveButton() {
  203. return SubmitButton(
  204. prefixIcon: IXImage(
  205. source: Assets.preCodeSaveLocal,
  206. width: 20.w,
  207. height: 20.w,
  208. sourceType: ImageSourceType.asset,
  209. ),
  210. text: 'Save Local Copy',
  211. bgColor: Get.reactiveTheme.highlightColor,
  212. onPressed: controller.saveLocalCopy,
  213. );
  214. }
  215. }