| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:get/get.dart';
- import 'package:nomo/app/base/base_view.dart';
- import 'package:nomo/app/widgets/click_opacity.dart';
- import 'package:nomo/app/widgets/ix_image.dart';
- import 'package:nomo/config/theme/theme_extensions/theme_extension.dart';
- import '../../../../config/theme/dark_theme_colors.dart';
- import '../../../constants/assets.dart';
- import '../../../constants/iconfont/iconfont.dart';
- import '../../../widgets/ix_app_bar.dart';
- import '../../../widgets/submit_btn.dart';
- import '../controllers/precode_controller.dart';
- class PrecodeView extends BaseView<PrecodeController> {
- const PrecodeView({super.key});
- @override
- PreferredSizeWidget? get appBar => IXAppBar(title: 'My Pre Code');
- @override
- Widget buildContent(BuildContext context) {
- return Padding(
- padding: EdgeInsets.symmetric(horizontal: 14.w),
- child: Column(
- children: [
- 10.verticalSpaceFromWidth,
- // 说明卡片
- _buildInfoCard(),
- 30.verticalSpaceFromWidth,
- // Pre Code 显示
- _buildPreCodeDisplay(),
- 10.verticalSpaceFromWidth,
- // Preview/Hide 和 Copy 按钮
- _buildActionButtons(),
- 40.verticalSpaceFromWidth,
- // Send to Email 按钮
- _buildEmailButton(),
- 10.verticalSpaceFromWidth,
- // 说明文字
- Text(
- 'Send your Pre Code to your registered email address',
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 13.sp,
- height: 1.4,
- color: Get.reactiveTheme.hintColor,
- ),
- ),
- 10.verticalSpaceFromWidth,
- // Save Local Copy 按钮
- _buildSaveButton(),
- 12.verticalSpaceFromWidth,
- // 说明文字
- Text(
- 'Store a copy of your Pre Code on this device',
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 13.sp,
- height: 1.4,
- color: Get.reactiveTheme.hintColor,
- ),
- ),
- ],
- ),
- );
- }
- /// 说明卡片
- Widget _buildInfoCard() {
- return Container(
- width: double.infinity,
- padding: EdgeInsets.all(10.w),
- decoration: BoxDecoration(
- color: Get.reactiveTheme.highlightColor,
- borderRadius: BorderRadius.circular(8.r),
- ),
- child: Column(
- children: [
- // 铃铛图标
- Icon(
- IconFont.icon67,
- color: DarkThemeColors.validTermColor,
- size: 30.w,
- ),
- 10.verticalSpaceFromWidth,
- // 说明文字
- Text(
- 'Pre Code is your premium user credential.\nUse it to activate benefits or sync your account\non other devices.',
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 14.sp,
- color: Get.reactiveTheme.textTheme.bodyLarge!.color,
- height: 1.5,
- ),
- ),
- 20.verticalSpaceFromWidth,
- // 安全提示
- Text(
- 'Please store it securely !',
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 14.sp,
- color: Get.reactiveTheme.textTheme.bodyLarge!.color,
- height: 1.5,
- ),
- ),
- ],
- ),
- );
- }
- /// Pre Code 显示
- Widget _buildPreCodeDisplay() {
- return Obx(
- () => Text(
- controller.displayCode,
- style: TextStyle(
- fontSize: 34.sp,
- height: 1.2,
- color: Get.reactiveTheme.textTheme.bodyLarge!.color,
- fontWeight: FontWeight.w500,
- ),
- ),
- );
- }
- /// Preview/Hide 和 Copy 按钮
- Widget _buildActionButtons() {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- // Preview/Hide 按钮
- Obx(
- () => ClickOpacity(
- onTap: controller.togglePreview,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- controller.isPreviewMode.value ? 'Hide' : 'Preview',
- style: TextStyle(
- fontSize: 12.sp,
- height: 1.7,
- color: Get.reactiveTheme.hintColor,
- ),
- ),
- 8.horizontalSpace,
- Icon(
- controller.isPreviewMode.value
- ? IconFont.icon12
- : IconFont.icon13,
- color: Get.reactiveTheme.hintColor,
- size: 20.w,
- ),
- ],
- ),
- ),
- ),
- 20.horizontalSpace,
- Container(
- width: 1.w,
- height: 20.w,
- color: Get.reactiveTheme.dividerColor,
- ),
- 20.horizontalSpace,
- // Copy 按钮
- ClickOpacity(
- onTap: controller.copyCode,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- 'Copy',
- style: TextStyle(
- fontSize: 12.sp,
- height: 1.7,
- color: Get.reactiveTheme.hintColor,
- ),
- ),
- 8.horizontalSpace,
- Icon(
- IconFont.icon57,
- color: Get.reactiveTheme.hintColor,
- size: 20.w,
- ),
- ],
- ),
- ),
- ],
- );
- }
- /// Send to Email 按钮
- Widget _buildEmailButton() {
- return SubmitButton(
- prefixIcon: IXImage(
- source: Assets.preCodeEmail,
- width: 20.w,
- height: 20.w,
- sourceType: ImageSourceType.asset,
- ),
- text: 'Send to Email',
- bgColor: Get.reactiveTheme.highlightColor,
- onPressed: controller.sendToEmail,
- );
- }
- /// Save Local Copy 按钮
- Widget _buildSaveButton() {
- return SubmitButton(
- prefixIcon: IXImage(
- source: Assets.preCodeSaveLocal,
- width: 20.w,
- height: 20.w,
- sourceType: ImageSourceType.asset,
- ),
- text: 'Save Local Copy',
- bgColor: Get.reactiveTheme.highlightColor,
- onPressed: controller.saveLocalCopy,
- );
- }
- }
|