Browse Source

[new]聊天界面增加人工智能弹窗提醒

zk 1 year ago
parent
commit
cb19be9a20

+ 0 - 1
lib/dialog/alert_dialog.dart

@@ -1,4 +1,3 @@
-import 'package:electronic_assistant/popup/talk_popup.dart';
 import 'package:electronic_assistant/utils/expand.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';

+ 90 - 0
lib/dialog/model_explain_dialog.dart

@@ -0,0 +1,90 @@
+import 'package:electronic_assistant/resource/assets.gen.dart';
+import 'package:electronic_assistant/resource/colors.gen.dart';
+import 'package:electronic_assistant/utils/mmkv_util.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
+import 'package:get/get.dart';
+
+void showModelExplainTipsDialog() {
+  const key = 'isShowModelExplainTipsDialog';
+  if (KVUtil.getBool(key, true)) {
+    final isCheck = false.obs;
+
+    const tag = 'showModelExplainTipsDialog';
+
+    SmartDialog.show(
+        tag: tag,
+        builder: (_) {
+          return Container(
+            padding: EdgeInsets.only(
+                left: 16.w, right: 16.w, top: 37.h, bottom: 20.h),
+            width: 280.w,
+            decoration: BoxDecoration(
+                borderRadius: BorderRadius.circular(12.w),
+                color: ColorName.white),
+            child: IntrinsicHeight(
+              child: Column(
+                children: [
+                  Text(
+                    textAlign: TextAlign.center,
+                    '本应用提供人工智能服务,禁止利用人工智能从事违法犯罪相关活动',
+                    style: TextStyle(
+                        fontWeight: FontWeight.bold,
+                        fontSize: 15.sp,
+                        color: ColorName.primaryTextColor),
+                  ),
+                  SizedBox(height: 8.h),
+                  GestureDetector(
+                    onTap: () {
+                      isCheck.value = !isCheck.value;
+                    },
+                    child: Row(
+                      mainAxisAlignment: MainAxisAlignment.center,
+                      children: [
+                        Obx(() {
+                          return isCheck.value
+                              ? Assets.images.iconSelectTrue
+                                  .image(width: 20.w, height: 20.w)
+                              : Assets.images.iconSelectFalse
+                                  .image(width: 20.w, height: 20.w);
+                        }),
+                        SizedBox(width: 5.w),
+                        Text('以后不再提示',
+                            style: TextStyle(
+                                fontSize: 15.sp,
+                                color: ColorName.tertiaryTextColor))
+                      ],
+                    ),
+                  ),
+                  SizedBox(height: 24.5.h),
+                  GestureDetector(
+                    onTap: () {
+                      if (isCheck.value) {
+                        KVUtil.putBool(key, false);
+                      }
+                      SmartDialog.dismiss(tag: tag);
+                    },
+                    child: Container(
+                      height: 36.h,
+                      decoration: BoxDecoration(
+                          color: ColorName.colorPrimary,
+                          borderRadius: BorderRadius.circular(8.w)),
+                      child: Center(
+                        child: Text(
+                          '知道了',
+                          style: TextStyle(
+                              fontSize: 14.sp,
+                              fontWeight: FontWeight.bold,
+                              color: ColorName.white),
+                        ),
+                      ),
+                    ),
+                  )
+                ],
+              ),
+            ),
+          );
+        });
+  }
+}

+ 9 - 0
lib/module/chat/controller.dart

@@ -22,6 +22,7 @@ import 'package:uuid/uuid.dart';
 import '../../data/bean/stream_chat_origin_data.dart';
 import '../../data/bean/talks.dart';
 import '../../data/consts/error_code.dart';
+import '../../dialog/model_explain_dialog.dart';
 import '../../router/app_pages.dart';
 import '../../utils/http_handler.dart';
 
@@ -55,6 +56,8 @@ class ChatController extends BaseController {
     if (accountRepository.userInfo.value?.profession == null ||
         accountRepository.userInfo.value?.post == null) {
       showStartSheet();
+    } else {
+      _showModelExplainDialog();
     }
   }
 
@@ -157,10 +160,16 @@ class ChatController extends BaseController {
         .then((result) {
       if (result == null || result == false) {
         Get.back();
+      } else {
+        _showModelExplainDialog();
       }
     });
   }
 
+  void _showModelExplainDialog() {
+    showModelExplainTipsDialog();
+  }
+
   void _sendMessage(String chatContent) {
     chatItems.insert(0, createUserChatItem(chatContent));