precode_view.dart 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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/config/theme/theme_extensions/theme_extension.dart';
  7. import '../controllers/precode_controller.dart';
  8. class PrecodeView extends BaseView<PrecodeController> {
  9. const PrecodeView({super.key});
  10. @override
  11. Widget buildContent(BuildContext context) {
  12. return Padding(
  13. padding: EdgeInsets.symmetric(horizontal: 14.w),
  14. child: Column(
  15. children: [
  16. // 自定义标题栏
  17. _buildAppBar(),
  18. 40.verticalSpaceFromWidth,
  19. // 说明卡片
  20. _buildInfoCard(),
  21. 40.verticalSpaceFromWidth,
  22. // Pre Code 显示
  23. _buildPreCodeDisplay(),
  24. 20.verticalSpaceFromWidth,
  25. // Preview/Hide 和 Copy 按钮
  26. _buildActionButtons(),
  27. 40.verticalSpaceFromWidth,
  28. // Send to Email 按钮
  29. _buildEmailButton(),
  30. 12.verticalSpaceFromWidth,
  31. // 说明文字
  32. Text(
  33. 'Send your Pre Code to your registered email address',
  34. textAlign: TextAlign.center,
  35. style: TextStyle(
  36. fontSize: 14.sp,
  37. color: Get.reactiveTheme.hintColor.withOpacity(0.6),
  38. ),
  39. ),
  40. 20.verticalSpaceFromWidth,
  41. // Save Local Copy 按钮
  42. _buildSaveButton(),
  43. 12.verticalSpaceFromWidth,
  44. // 说明文字
  45. Text(
  46. 'Store a copy of your Pre Code on this device',
  47. textAlign: TextAlign.center,
  48. style: TextStyle(
  49. fontSize: 14.sp,
  50. color: Get.reactiveTheme.hintColor.withOpacity(0.6),
  51. ),
  52. ),
  53. ],
  54. ),
  55. );
  56. }
  57. /// 自定义标题栏
  58. Widget _buildAppBar() {
  59. return Container(
  60. height: 64.h,
  61. alignment: Alignment.center,
  62. child: Stack(
  63. children: [
  64. // 返回按钮
  65. Positioned(
  66. left: 0,
  67. top: 0,
  68. bottom: 0,
  69. child: ClickOpacity(
  70. onTap: () => Get.back(),
  71. child: Container(
  72. width: 48.w,
  73. height: 48.w,
  74. alignment: Alignment.center,
  75. child: Icon(
  76. Icons.arrow_back,
  77. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  78. size: 24.w,
  79. ),
  80. ),
  81. ),
  82. ),
  83. // 标题
  84. Center(
  85. child: Text(
  86. 'My Pre Code',
  87. style: TextStyle(
  88. fontSize: 20.sp,
  89. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  90. fontWeight: FontWeight.w600,
  91. ),
  92. ),
  93. ),
  94. ],
  95. ),
  96. );
  97. }
  98. /// 说明卡片
  99. Widget _buildInfoCard() {
  100. return Container(
  101. padding: EdgeInsets.all(24.w),
  102. decoration: BoxDecoration(
  103. color: Get.reactiveTheme.highlightColor,
  104. borderRadius: BorderRadius.circular(16.r),
  105. ),
  106. child: Column(
  107. children: [
  108. // 铃铛图标
  109. Container(
  110. width: 48.w,
  111. height: 48.w,
  112. decoration: BoxDecoration(
  113. color: const Color(0xFFFF9500).withOpacity(0.2),
  114. shape: BoxShape.circle,
  115. ),
  116. child: Icon(
  117. Icons.notifications,
  118. color: const Color(0xFFFF9500),
  119. size: 28.w,
  120. ),
  121. ),
  122. 20.verticalSpaceFromWidth,
  123. // 说明文字
  124. Text(
  125. 'Pre Code is your premium user credential.\nUse it to activate benefits or sync your account\non other devices.',
  126. textAlign: TextAlign.center,
  127. style: TextStyle(
  128. fontSize: 16.sp,
  129. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  130. height: 1.5,
  131. ),
  132. ),
  133. 20.verticalSpaceFromWidth,
  134. // 安全提示
  135. Text(
  136. 'Please store it securely !',
  137. textAlign: TextAlign.center,
  138. style: TextStyle(
  139. fontSize: 16.sp,
  140. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  141. fontWeight: FontWeight.w600,
  142. ),
  143. ),
  144. ],
  145. ),
  146. );
  147. }
  148. /// Pre Code 显示
  149. Widget _buildPreCodeDisplay() {
  150. return Obx(
  151. () => Text(
  152. controller.displayCode,
  153. style: TextStyle(
  154. fontSize: 32.sp,
  155. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  156. fontWeight: FontWeight.w700,
  157. letterSpacing: 2,
  158. ),
  159. ),
  160. );
  161. }
  162. /// Preview/Hide 和 Copy 按钮
  163. Widget _buildActionButtons() {
  164. return Row(
  165. mainAxisAlignment: MainAxisAlignment.center,
  166. children: [
  167. // Preview/Hide 按钮
  168. Obx(
  169. () => ClickOpacity(
  170. onTap: controller.togglePreview,
  171. child: Row(
  172. mainAxisSize: MainAxisSize.min,
  173. children: [
  174. Text(
  175. controller.isPreviewMode.value ? 'Hide' : 'Preview',
  176. style: TextStyle(
  177. fontSize: 16.sp,
  178. color: Get.reactiveTheme.hintColor,
  179. ),
  180. ),
  181. 8.horizontalSpace,
  182. Icon(
  183. controller.isPreviewMode.value
  184. ? Icons.visibility_off_outlined
  185. : Icons.remove_red_eye_outlined,
  186. color: Get.reactiveTheme.hintColor,
  187. size: 20.w,
  188. ),
  189. ],
  190. ),
  191. ),
  192. ),
  193. 40.horizontalSpace,
  194. Container(
  195. width: 1,
  196. height: 20.h,
  197. color: Get.reactiveTheme.hintColor.withOpacity(0.3),
  198. ),
  199. 40.horizontalSpace,
  200. // Copy 按钮
  201. ClickOpacity(
  202. onTap: controller.copyCode,
  203. child: Row(
  204. mainAxisSize: MainAxisSize.min,
  205. children: [
  206. Text(
  207. 'Copy',
  208. style: TextStyle(
  209. fontSize: 16.sp,
  210. color: Get.reactiveTheme.hintColor,
  211. ),
  212. ),
  213. 8.horizontalSpace,
  214. Icon(Icons.copy, color: Get.reactiveTheme.hintColor, size: 20.w),
  215. ],
  216. ),
  217. ),
  218. ],
  219. );
  220. }
  221. /// Send to Email 按钮
  222. Widget _buildEmailButton() {
  223. return ClickOpacity(
  224. onTap: controller.sendToEmail,
  225. child: Container(
  226. height: 56.h,
  227. decoration: BoxDecoration(
  228. color: Get.reactiveTheme.highlightColor,
  229. borderRadius: BorderRadius.circular(16.r),
  230. ),
  231. child: Row(
  232. mainAxisAlignment: MainAxisAlignment.center,
  233. children: [
  234. Icon(
  235. Icons.email_outlined,
  236. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  237. size: 24.w,
  238. ),
  239. 12.horizontalSpace,
  240. Text(
  241. 'Send to Email',
  242. style: TextStyle(
  243. fontSize: 16.sp,
  244. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  245. fontWeight: FontWeight.w500,
  246. ),
  247. ),
  248. ],
  249. ),
  250. ),
  251. );
  252. }
  253. /// Save Local Copy 按钮
  254. Widget _buildSaveButton() {
  255. return ClickOpacity(
  256. onTap: controller.saveLocalCopy,
  257. child: Container(
  258. height: 56.h,
  259. decoration: BoxDecoration(
  260. color: Get.reactiveTheme.highlightColor,
  261. borderRadius: BorderRadius.circular(16.r),
  262. ),
  263. child: Row(
  264. mainAxisAlignment: MainAxisAlignment.center,
  265. children: [
  266. Icon(
  267. Icons.save_alt,
  268. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  269. size: 24.w,
  270. ),
  271. 12.horizontalSpace,
  272. Text(
  273. 'Save Local Copy',
  274. style: TextStyle(
  275. fontSize: 16.sp,
  276. color: Get.reactiveTheme.textTheme.bodyLarge!.color,
  277. fontWeight: FontWeight.w500,
  278. ),
  279. ),
  280. ],
  281. ),
  282. ),
  283. );
  284. }
  285. }