Преглед изворни кода

[new]调整谈话记录界面样式

zk пре 1 година
родитељ
комит
434cadbae0

BIN
assets/images/icon_talk_back.webp


BIN
assets/images/icon_talk_edit.webp


BIN
assets/images/icon_talk_edit_title.webp


BIN
assets/images/icon_talk_share.webp


+ 1 - 0
assets/string/base/string.xml

@@ -146,4 +146,5 @@
     <string name="model_explain_name">百度智能云千帆大模型</string>
     <string name="model_explain_record_number">网信算备110108645502801230043号</string>
     <string name="talk_mind_map">思维导图</string>
+    <string name="talk_update_txt">编辑</string>
 </resources>

+ 42 - 18
lib/module/talk/controller.dart

@@ -37,12 +37,12 @@ import '../../data/repositories/agenda_repository.dart';
 import '../../data/repositories/talk_repository.dart';
 import '../../dialog/add_agenda_dialog.dart';
 import '../../dialog/alert_dialog.dart';
+import '../../dialog/rename_dialog.dart';
 import '../../dialog/talk_share_dialog.dart';
 import '../../utils/common_utils.dart';
 import '../../utils/event_bus.dart';
 import '../../utils/system_share_util.dart';
 import '../../utils/toast_util.dart';
-import 'original/view.dart';
 
 class TalkController extends BaseController {
   static const String argumentItem = 'argument_item';
@@ -80,15 +80,16 @@ class TalkController extends BaseController {
 
   final _isEditModel = false.obs;
 
-  final TextEditingController editTalkNameController = TextEditingController();
+  final defaultIndex = 0;
 
-  final tabIndex = 0.obs;
+  final Rxn<TalkBarBean> checkTabBean = Rxn();
 
-  final List<String> tabBeans = [
-    StringName.talkTabSummary.tr,
-    '思维导图',
-    StringName.talkTabMyTask.tr,
-    StringName.talkTabOriginal.tr
+  final List<TalkBarBean> tabBeans = [
+    TalkBarBean(TalkBarType.summary, StringName.talkTabSummary.tr, true),
+    TalkBarBean(TalkBarType.mindMap, StringName.talkMindMap.tr, false,
+        isDisallowScroll: true),
+    TalkBarBean(TalkBarType.myTask, StringName.talkTabMyTask.tr, true),
+    TalkBarBean(TalkBarType.original, StringName.talkTabOriginal.tr, false)
   ];
 
   bool get isEditModel => _isEditModel.value;
@@ -121,6 +122,12 @@ class TalkController extends BaseController {
   final Rxn<TalkBean> summaryBean = Rxn();
 
   @override
+  void onInit() {
+    super.onInit();
+    checkTabBean.value = tabBeans[defaultIndex];
+  }
+
+  @override
   void onReady() {
     super.onReady();
     _initAudioPlayer();
@@ -466,11 +473,10 @@ class TalkController extends BaseController {
       _audioPlayer.pause();
       isAudioPlaying.value = false;
     }
-    editTalkNameController.text = talkBean.value?.title.value ?? '';
   }
 
   void updateTabIndex(int index) {
-    tabIndex.value = index;
+    checkTabBean.value = tabBeans[index];
   }
 
   void onEditCancel() {
@@ -499,14 +505,6 @@ class TalkController extends BaseController {
     }).catchError((error) {
       ErrorHandler.toastError(error);
     });
-    if (tabIndex.value == 0) {
-      String updateName = editTalkNameController.text;
-      talkRepository.talkRename(talkBean.value!.id, updateName).then((data) {
-        talkBean.value?.title.value = updateName;
-      }).catchError((error) {
-        ErrorHandler.toastError(error);
-      });
-    }
   }
 
   void removeTalkAgenda(List<Agenda>? list, Agenda agenda) {
@@ -644,6 +642,18 @@ class TalkController extends BaseController {
     });
   }
 
+  void onEditTitleClick() {
+    reNameDialog(StringName.talkRenameTitle.tr, talkBean.value?.title.value,
+        hintTxt: StringName.talkRenameTitleHint.tr,
+        maxLength: 15, returnBuilder: (newName) {
+      talkRepository.talkRename(talkBean.value!.id, newName).then((data) {
+        talkBean.value?.title.value = newName;
+      }).catchError((error) {
+        ErrorHandler.toastError(error);
+      });
+    });
+  }
+
   @override
   void onClose() {
     super.onClose();
@@ -654,3 +664,17 @@ class TalkController extends BaseController {
     _agendaNameController?.dispose();
   }
 }
+
+enum TalkBarType { summary, mindMap, myTask, original }
+
+class TalkBarBean {
+  final TalkBarType type;
+
+  final String title;
+
+  final bool isShowEdit;
+
+  final bool? isDisallowScroll;
+
+  TalkBarBean(this.type, this.title, this.isShowEdit, {this.isDisallowScroll});
+}

+ 168 - 165
lib/module/talk/view.dart

@@ -77,14 +77,13 @@ class TalkPage extends BasePage<TalkController> {
         return true;
       },
       child: DefaultTabController(
-        initialIndex: controller.tabIndex.value,
+        initialIndex: controller.defaultIndex,
         length: controller.tabBeans.length,
         child: Stack(
           children: [
             buildTopGradient(),
             _buildTalkContentView(),
             buildBottomView(),
-            buildAIAnalysisView()
           ],
         ),
       ),
@@ -98,125 +97,54 @@ class TalkPage extends BasePage<TalkController> {
         actions: [
           _buildEditBtnView(),
         ],
+        leadingWidth: 0.9.sw,
         systemOverlayStyle: SystemUiOverlayStyle.dark,
         backgroundColor: Colors.transparent,
-        leading: _buildAppbarBackView(),
+        leading: _buildAppbarLeftView(),
       ),
       body: Builder(builder: (context) {
         return Column(
           crossAxisAlignment: CrossAxisAlignment.start,
-          children: [
-            _buildHeaderView(),
-            buildTabBar(context),
-            Obx(() {
-              return Visibility(
-                visible: !controller.isEditModel,
-                child: Divider(
-                    height: 1,
-                    color: const Color(0xFFf6f6f6),
-                    indent: 12.w,
-                    endIndent: 12.w),
-              );
-            }),
-            Obx(() {
-              return Visibility(
-                  visible: !controller.isEditModel,
-                  child: SizedBox(height: 8.h));
-            }),
-            buildTalkContentView()
-          ],
+          children: [buildTabBar(context), buildTalkContentView()],
         );
       }),
     );
   }
 
-  Padding _buildHeaderView() {
-    return Padding(
-      padding: EdgeInsets.symmetric(horizontal: 12.w),
-      child: Obx(() {
+  Widget buildTabBar(BuildContext context) {
+    TabController tabController = DefaultTabController.of(context);
+    tabController.addListener(() {
+      controller.updateTabIndex(tabController.index);
+    });
+    return Obx(() {
+      if (!controller.isEditModel) {
         return Column(
-          crossAxisAlignment: CrossAxisAlignment.start,
           children: [
-            SizedBox(height: 8.h),
-            _buildTalkTitle(),
-            SizedBox(height: 4.h),
-            Text(controller.talkBean.value?.createTime ?? '',
-                style: TextStyle(
-                    fontSize: 12.sp, color: ColorName.secondaryTextColor)),
-            SizedBox(height: 14.h),
+            TabBar(
+                labelStyle:
+                    TextStyle(fontSize: 16.sp, fontWeight: FontWeight.bold),
+                unselectedLabelStyle: TextStyle(fontSize: 14.sp),
+                labelColor: ColorName.primaryTextColor,
+                unselectedLabelColor: ColorName.secondaryTextColor,
+                labelPadding: EdgeInsets.only(top: 4.h),
+                dividerHeight: 0,
+                splashFactory: NoSplash.splashFactory,
+                indicator: FixedSizeTabIndicator(
+                    width: 16.w,
+                    height: 3.w,
+                    radius: 3,
+                    color: ColorName.colorPrimary),
+                tabs: controller.tabBeans
+                    .map((bean) => Tab(text: bean.title))
+                    .toList()),
+            SizedBox(height: 6.h),
+            Divider(height: 1, color: '#F2F4F9'.color)
           ],
         );
-      }),
-    );
-  }
-
-  Widget _buildTalkTitle() {
-    if (!controller.isEditModel || controller.tabIndex.value == 1) {
-      return Text(controller.talkBean.value?.title.value ?? '',
-          style: TextStyle(
-              fontSize: 22.sp,
-              fontWeight: FontWeight.bold,
-              color: ColorName.primaryTextColor));
-    } else {
-      return Container(
-        decoration: BoxDecoration(
-          color: ColorName.white,
-          borderRadius: BorderRadius.circular(6.w),
-          border: Border.all(color: "#E7E9F6".toColor(), width: 1),
-        ),
-        child: TextField(
-            maxLines: null,
-            maxLength: 15,
-            decoration: InputDecoration(
-              counterText: '',
-              border: InputBorder.none,
-              fillColor: Colors.transparent,
-              contentPadding:
-                  EdgeInsets.symmetric(vertical: 6.w, horizontal: 8.w),
-            ),
-            style: TextStyle(
-                fontSize: 22.sp,
-                fontWeight: FontWeight.bold,
-                color: ColorName.primaryTextColor),
-            cursorColor: ColorName.primaryTextColor,
-            controller: controller.editTalkNameController),
-      );
-    }
-  }
-
-  Container buildTabBar(BuildContext context) {
-    TabController tabController = DefaultTabController.of(context);
-    tabController.addListener(() {
-      controller.updateTabIndex(tabController.index);
+      } else {
+        return SizedBox(height: 8.h, width: double.infinity);
+      }
     });
-    return Container(
-      decoration: const BoxDecoration(
-          color: Colors.white,
-          borderRadius: BorderRadius.only(
-            topLeft: Radius.circular(12),
-            topRight: Radius.circular(12),
-          )),
-      child: Obx(() {
-        if (!controller.isEditModel) {
-          return TabBar(
-              labelStyle:
-                  TextStyle(fontSize: 16.sp, fontWeight: FontWeight.bold),
-              unselectedLabelStyle: TextStyle(fontSize: 14.sp),
-              labelColor: ColorName.primaryTextColor,
-              unselectedLabelColor: ColorName.secondaryTextColor,
-              labelPadding: EdgeInsets.only(top: 4.h),
-              dividerHeight: 0,
-              indicator: FixedSizeTabIndicator(
-                  width: 16.w,
-                  height: 3.w,
-                  radius: 3,
-                  color: ColorName.colorPrimary),
-              tabs: controller.tabBeans.map((txt) => Tab(text: txt)).toList());
-        } else {
-          return SizedBox(height: 8.h, width: double.infinity);
-        }
-      }),
-    );
   }
 
   @override
@@ -233,7 +161,7 @@ class TalkPage extends BasePage<TalkController> {
             colors: ['#E1E9FF'.toColor(), '#F9FAFE'.toColor()],
             begin: Alignment.topCenter,
             end: Alignment.bottomCenter,
-            stops: const [0.3, 1.0],
+            stops: const [0, 1.0],
           ),
         ));
   }
@@ -256,7 +184,8 @@ class TalkPage extends BasePage<TalkController> {
   Widget buildTabContentView() {
     return Expanded(
       child: TabBarView(
-        physics: controller.isEditModel || controller.tabIndex.value == 1
+        physics: controller.isEditModel ||
+                controller.checkTabBean.value?.isDisallowScroll == true
             ? const NeverScrollableScrollPhysics()
             : null,
         children: _pages,
@@ -359,28 +288,15 @@ class TalkPage extends BasePage<TalkController> {
         child: Align(
           alignment: Alignment.bottomCenter,
           child: Container(
-            margin: EdgeInsets.only(bottom: 20.h), // 设置底部偏移距离
+            margin: EdgeInsets.only(bottom: 20.h),
             child: IntrinsicHeight(
               child: Column(
                 crossAxisAlignment: CrossAxisAlignment.end,
                 children: [
-                  Obx(() {
-                    return Visibility(
-                      visible: controller.talkBean.value?.status.value ==
-                          TalkStatus.analysisSuccess,
-                      child: GestureDetector(
-                        onTap: () {
-                          controller.clickAIAnalysis();
-                        },
-                        child: Container(
-                            margin: EdgeInsets.only(right: 8.w),
-                            width: 64.w,
-                            height: 64.w,
-                            child: Assets.images.iconTalkLogo.image()),
-                      ),
-                    );
-                  }),
-                  SizedBox(height: 24.h),
+                  _buildAIAnalysisView(),
+                  SizedBox(height: 8.h),
+                  _buildTalkEditView(),
+                  SizedBox(height: 10.h),
                   buildAudioView()
                 ],
               ),
@@ -391,8 +307,70 @@ class TalkPage extends BasePage<TalkController> {
     });
   }
 
-  buildAIAnalysisView() {
-    return Container();
+  Widget _buildTalkEditView() {
+    return Obx(() {
+      return Visibility(
+        visible: controller.talkBean.value?.status.value ==
+                TalkStatus.analysisSuccess &&
+            controller.checkTabBean.value?.isShowEdit == true,
+        maintainState: true,
+        maintainAnimation: true,
+        maintainSize: true,
+        child: GestureDetector(
+          onTap: () => controller.onEditModelClick(),
+          child: Align(
+            alignment: Alignment.centerLeft,
+            child: Container(
+              margin: EdgeInsets.only(left: 12.w),
+              padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.w),
+              decoration: BoxDecoration(
+                  color: ColorName.white,
+                  borderRadius: BorderRadius.circular(100),
+                  boxShadow: [
+                    BoxShadow(
+                      color: ColorName.black5.withOpacity(0.08),
+                      spreadRadius: 2,
+                      blurRadius: 12,
+                      offset: const Offset(0, 1),
+                    ),
+                  ]),
+              child: IntrinsicWidth(
+                child: Row(
+                  children: [
+                    Assets.images.iconTalkEdit.image(width: 16.w, height: 16.w),
+                    SizedBox(width: 2.w),
+                    Text(StringName.talkUpdateTxt.tr,
+                        style: TextStyle(
+                            height: 1,
+                            fontSize: 14.sp,
+                            color: ColorName.primaryTextColor))
+                  ],
+                ),
+              ),
+            ),
+          ),
+        ),
+      );
+    });
+  }
+
+  Widget _buildAIAnalysisView() {
+    return Obx(() {
+      return Visibility(
+        visible: controller.talkBean.value?.status.value ==
+            TalkStatus.analysisSuccess,
+        child: GestureDetector(
+          onTap: () {
+            controller.clickAIAnalysis();
+          },
+          child: Container(
+              margin: EdgeInsets.only(right: 8.w),
+              width: 64.w,
+              height: 64.w,
+              child: Assets.images.iconTalkLogo.image()),
+        ),
+      );
+    });
   }
 
   buildAudioView() {
@@ -429,8 +407,6 @@ class TalkPage extends BasePage<TalkController> {
           SizedBox(width: 15.w),
           Builder(builder: (context) {
             return Flexible(
-              // width: 226.w,
-              // height: 18.w,
               child: Obx(() {
                 return SliderTheme(
                   data: SliderTheme.of(context).copyWith(
@@ -464,29 +440,71 @@ class TalkPage extends BasePage<TalkController> {
     );
   }
 
-  Widget _buildAppbarBackView() {
+  Widget _buildAppbarLeftView() {
     return Obx(() {
-      return controller.isEditModel
-          ? IconButton(
-              icon: SizedBox(
-                  width: 24.w,
-                  height: 24.w,
-                  child: Assets.images.iconTalkEditCancel.image()),
-              // Custom icon
-              onPressed: () {
-                controller.onEditCancel();
-              },
-            )
-          : IconButton(
-              icon: SizedBox(
-                  width: 24.w,
-                  height: 24.w,
-                  child: Assets.images.iconBack.image()),
-              // Custom icon
+      if (controller.isEditModel) {
+        return Align(
+          alignment: Alignment.centerLeft,
+          child: IconButton(
+            icon: Assets.images.iconTalkEditCancel
+                .image(width: 24.w, height: 24.w),
+            onPressed: () {
+              controller.onEditCancel();
+            },
+          ),
+        );
+      } else {
+        return Row(
+          children: [
+            IconButton(
+              icon: Assets.images.iconTalkBack.image(width: 24.w, height: 24.w),
               onPressed: () {
                 Get.back();
               },
-            );
+            ),
+            SizedBox(width: 6.w),
+            Obx(() {
+              return GestureDetector(
+                onTap: () {
+                  controller.onEditTitleClick();
+                },
+                child: Column(
+                  mainAxisAlignment: MainAxisAlignment.center,
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    Row(
+                      children: [
+                        ConstrainedBox(
+                          constraints: BoxConstraints(maxWidth: 0.65.sw),
+                          child: Text(
+                            maxLines: 1,
+                            overflow: TextOverflow.ellipsis,
+                            controller.talkBean.value?.title.value ?? '',
+                            style: TextStyle(
+                              fontWeight: FontWeight.bold,
+                              fontSize: 15.sp,
+                              color: ColorName.primaryTextColor,
+                            ),
+                          ),
+                        ),
+                        SizedBox(width: 2.w),
+                        Assets.images.iconTalkEditTitle
+                            .image(width: 16.w, height: 16.w)
+                      ],
+                    ),
+                    SizedBox(height: 2.h),
+                    Text(
+                      controller.talkBean.value?.createTime ?? '',
+                      style: TextStyle(
+                          fontSize: 11.sp, color: ColorName.secondaryTextColor),
+                    )
+                  ],
+                ),
+              );
+            })
+          ],
+        );
+      }
     });
   }
 
@@ -509,28 +527,13 @@ class TalkPage extends BasePage<TalkController> {
               )
             : Row(
                 children: [
-                  Visibility(
-                    visible: controller.tabIndex.value != 2,
-                    child: IconButton(
-                      icon: SizedBox(
-                          width: 24.w,
-                          height: 24.w,
-                          child: Assets.images.iconTalkEdit.image()),
-                      onPressed: () {
-                        controller.onEditModelClick();
-                      },
-                    ),
-                  ),
                   IconButton(
-                    icon: SizedBox(
-                        width: 24.w,
-                        height: 24.w,
-                        child: Assets.images.iconTalkShare.image()),
+                    icon: Assets.images.iconTalkShare
+                        .image(width: 20.w, height: 20.w),
                     onPressed: () {
                       controller.onShareClick();
                     },
                   ),
-                  SizedBox(width: 12.w)
                 ],
               ),
       );