ソースを参照

[feat]亲密度分析,页面上的锁图标按钮,对接用户信息中的,是否会员字段

hezihao 7 ヶ月 前
コミット
128eee543e

+ 8 - 7
lib/di/get_it.config.dart

@@ -198,13 +198,6 @@ extension GetItInjectableX on _i174.GetIt {
         gh<_i243.AtmobApi>(),
       ),
     );
-    gh.factory<_i987.IntimacyAnalyseReportController>(
-      () => _i987.IntimacyAnalyseReportController(
-        gh<_i283.IntimacyAnalyzeRepository>(),
-        gh<_i738.IntimacyAnalyzeConfigHelper>(),
-        gh<_i274.KeyboardRepository>(),
-      ),
-    );
     gh.factory<_i922.KeyboardManageController>(
       () => _i922.KeyboardManageController(
         gh<_i274.KeyboardRepository>(),
@@ -310,6 +303,14 @@ extension GetItInjectableX on _i174.GetIt {
     gh.factory<_i15.CharacterCustomController>(
       () => _i15.CharacterCustomController(gh<_i50.ConfigRepository>()),
     );
+    gh.factory<_i987.IntimacyAnalyseReportController>(
+      () => _i987.IntimacyAnalyseReportController(
+        gh<_i283.IntimacyAnalyzeRepository>(),
+        gh<_i738.IntimacyAnalyzeConfigHelper>(),
+        gh<_i274.KeyboardRepository>(),
+        gh<_i83.AccountRepository>(),
+      ),
+    );
     gh.factory<_i888.CharacterController>(
       () => _i888.CharacterController(
         gh<_i421.CharactersRepository>(),

+ 12 - 9
lib/module/intimacy_analyse/analyse_report/intimacy_analyse_report_view.dart

@@ -169,14 +169,17 @@ class IntimacyAnalyseReportView
 
   /// 解锁按钮
   Widget _buildUnlockBtn(BuildContext context) {
-    return Container(
-      margin: EdgeInsets.symmetric(horizontal: 16.w),
-      width: double.maxFinite,
-      child: GradientTextBtn.withUnlock(
-        onPressed: () {
-          controller.clickUnlockBtn(context);
-        },
-      ),
-    );
+    return Obx(() {
+      return Container(
+        margin: EdgeInsets.symmetric(horizontal: 16.w),
+        width: double.maxFinite,
+        child: GradientTextBtn.withUnlock(
+          controller.userInfo.value?.isMember ?? false,
+          onPressed: () {
+            controller.clickUnlockBtn(context);
+          },
+        ),
+      );
+    });
   }
 }

+ 11 - 1
lib/module/intimacy_analyse/analyse_report/intimacy_analyse_report_view_controller.dart

@@ -5,6 +5,8 @@ import 'package:keyboard/base/base_controller.dart';
 import 'package:wechat_assets_picker/wechat_assets_picker.dart';
 import '../../../data/api/response/intimacy_analyze_config_response.dart';
 import '../../../data/bean/keyboard_info.dart';
+import '../../../data/bean/member_info.dart';
+import '../../../data/repository/account_repository.dart';
 import '../../../data/repository/intimacy_analyze_repository.dart';
 import '../../../data/repository/keyboard_repository.dart';
 import '../../../utils/atmob_log.dart';
@@ -27,20 +29,28 @@ class IntimacyAnalyseReportController extends BaseController {
   /// 键盘信息
   KeyboardRepository keyboardRepository;
 
+  /// 用户信息Repository
+  AccountRepository accountRepository;
+
   /// 亲密度配置
   Rxn<IntimacyAnalyzeConfigResponse> get intimacyAnalyzeConfig =>
       intimacyAnalyzeRepository.intimacyAnalyzeConfig;
 
   /// 当前键盘信息
-  Rxn<KeyboardInfo> get currentKeyboardInfo => keyboardRepository.chooseKeyboardInfo;
+  Rxn<KeyboardInfo> get currentKeyboardInfo =>
+      keyboardRepository.chooseKeyboardInfo;
 
   /// 报告预览数据
   RxString reportPreviewData = "".obs;
 
+  /// 当前用户信息
+  Rxn<MemberInfo> get userInfo => accountRepository.memberStatusInfo;
+
   IntimacyAnalyseReportController(
     this.intimacyAnalyzeRepository,
     this.intimacyAnalyzeConfigHelper,
     this.keyboardRepository,
+    this.accountRepository,
   );
 
   @override

+ 3 - 2
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_controller.dart

@@ -16,6 +16,7 @@ import '../../../data/api/response/intimacy_analyze_config_response.dart';
 import '../../../data/api/response/intimacy_analyze_response.dart';
 import '../../../data/bean/ai_model.dart';
 import '../../../data/bean/keyboard_info.dart';
+import '../../../data/bean/member_info.dart';
 import '../../../data/bean/option_select_config.dart';
 import '../../../data/bean/option_select_item.dart';
 import '../../../data/repository/intimacy_analyze_repository.dart';
@@ -77,8 +78,8 @@ class IntimacyAnalyseUploadController extends BaseController {
   /// 是否可以自定义方向
   RxBool isCanCustomDirection = false.obs;
 
-  /// 报告是否已解锁
-  Rx<bool> isReportUnlock = true.obs;
+  /// 当前用户信息
+  Rxn<MemberInfo> get userInfo => accountRepository.memberStatusInfo;
 
   /// 报告是否生成中
   Rx<bool> isReportCreating = false.obs;

+ 28 - 23
lib/module/intimacy_analyse/intimacy_analyse_upload/intimacy_analyse_upload_page.dart

@@ -281,7 +281,7 @@ class IntimacyAnalyseUploadPage
           IntimacyAnalyseReportWidget(
             // 分析结果
             intimacyAnalyzeResult: controller.intimacyAnalyzeResult.value,
-            unlock: controller.isReportUnlock.value,
+            unlock: controller.userInfo.value?.isMember ?? false,
             isReportCreating: controller.isReportCreating.value,
           ),
         ],
@@ -684,32 +684,37 @@ class IntimacyAnalyseUploadPage
 
   /// 下一步按钮
   Widget _buildNextBtn() {
-    return Container(
-      padding: EdgeInsets.only(top: 13.h, bottom: 13.h),
-      child: GradientTextBtn(
-        StringName.nextStep,
-        leftIcon: Assets.images.iconLock.image(width: 22.w, height: 22.h),
-        color: ColorName.colorBrand,
-        onPressed: () {
-          controller.clickNextBtn();
-        },
-      ),
-    );
+    return Obx(() {
+      return Container(
+        padding: EdgeInsets.only(top: 13.h, bottom: 13.h),
+        child: GradientTextBtn.withUnlock(
+          controller.userInfo.value?.isMember ?? false,
+          text: StringName.nextStep,
+          color: ColorName.colorBrand,
+          onPressed: () {
+            controller.clickNextBtn();
+          },
+        ),
+      );
+    });
   }
 
   /// 分析按钮
   Widget _buildAnalyseBtn() {
-    return Container(
-      padding: EdgeInsets.only(top: 7.h, bottom: 6.h),
-      child: GradientTextBtn.withUnlock(
-        text: StringName.intimacyAnalyseAnalysisNow,
-        color: ColorName.colorBrand,
-        desc: StringName.intimacyAnalyseAnalysisUseAiTip,
-        radius: 30.r,
-        padding: EdgeInsets.symmetric(vertical: 7.h),
-        onPressed: () {},
-      ),
-    );
+    return Obx(() {
+      return Container(
+        padding: EdgeInsets.only(top: 7.h, bottom: 6.h),
+        child: GradientTextBtn.withUnlock(
+          controller.userInfo.value?.isMember ?? false,
+          text: StringName.intimacyAnalyseAnalysisNow,
+          color: ColorName.colorBrand,
+          desc: StringName.intimacyAnalyseAnalysisUseAiTip,
+          radius: 30.r,
+          padding: EdgeInsets.symmetric(vertical: 7.h),
+          onPressed: () {},
+        ),
+      );
+    });
   }
 
   /// 构建卡片列表

+ 12 - 9
lib/module/intimacy_analyse/screenshot_reply/conversation_analysis/conversation_analysis_view.dart

@@ -373,15 +373,18 @@ class ConversationAnalysisView
 
   /// 解锁按钮
   Widget _buildUnlockBtn(BuildContext context) {
-    return Container(
-      margin: EdgeInsets.symmetric(horizontal: 16.w),
-      width: double.maxFinite,
-      child: GradientTextBtn.withUnlock(
-        onPressed: () {
-          controller.clickUnlockBtn(context);
-        },
-      ),
-    );
+    return Obx(() {
+      return Container(
+        margin: EdgeInsets.symmetric(horizontal: 16.w),
+        width: double.maxFinite,
+        child: GradientTextBtn.withUnlock(
+          controller.userInfo.value?.isMember ?? false,
+          onPressed: () {
+            controller.clickUnlockBtn(context);
+          },
+        ),
+      );
+    });
   }
 
   /// 上传截图按钮

+ 12 - 5
lib/widget/gradient_btn.dart

@@ -106,7 +106,9 @@ class GradientTextBtn extends StatelessWidget {
   final VoidCallback onPressed;
 
   /// 操作按钮,带解锁按钮
-  static GradientTextBtn withUnlock({
+  /// [isUnlock] 是否已解锁
+  static GradientTextBtn withUnlock(
+    bool isUnlock, {
     String? text,
     Color? color,
     String? desc,
@@ -118,14 +120,19 @@ class GradientTextBtn extends StatelessWidget {
     if (btnText.isEmpty) {
       btnText = StringName.intimacyUnlockAnalyse;
     }
+    // 解锁图标,非VIP会员时,才显示锁图标
+    Image? leftIcon;
+    if (!isUnlock) {
+      leftIcon = Assets.images.iconIntimacyAnalyseUnlock.image(
+        width: 22,
+        height: 22,
+      );
+    }
     return GradientTextBtn(
       btnText,
       desc: desc,
       color: color ?? ColorName.colorBrand,
-      leftIcon: Assets.images.iconIntimacyAnalyseUnlock.image(
-        width: 22,
-        height: 22,
-      ),
+      leftIcon: leftIcon,
       radius: radius,
       padding: padding,
       onPressed: onPressed,