Forráskód Böngészése

fix(measure): 修复多幅vid注释tab拉取失败的问题 #0009378

gavin.chen 2 éve
szülő
commit
184be77f32

+ 9 - 0
lib/process/workspace/measure_handler.dart

@@ -74,6 +74,8 @@ abstract class IMeasureHandler {
 
   late FEventHandler<bool> onChangeFullScreenState;
 
+  late FEventHandler<void> commentsLoaded;
+
   /// 切换图像传递数据
   ChangeImageInfo get imageChanged;
   set imageChanged(ChangeImageInfo value);
@@ -137,6 +139,9 @@ class MeasureHandler implements IMeasureHandler {
   @override
   FEventHandler<bool> onChangeFullScreenState = FEventHandler<bool>();
 
+  @override
+  var commentsLoaded = FEventHandler<void>();
+
   @override
   ChangeImageInfo get imageChanged => _imageChanged;
 
@@ -240,4 +245,8 @@ class MeasureHandler implements IMeasureHandler {
   void _onChangedAnnotation() {
     onChangedAnnotationType.emit(this, changedAnnotationType);
   }
+
+  void onCommentsLoaded() {
+    commentsLoaded.emit(this, null);
+  }
 }

+ 1 - 0
lib/view/measure/measure_tool.dart

@@ -160,6 +160,7 @@ class LeftSiderSelectMeasureState extends FState<LeftSiderSelectMeasure> {
       commentsList.add(element.text ?? '');
     });
     measureData.getCommentsList = commentsList;
+    measureHandler.onCommentsLoaded();
   }
 
   /// 测量项列表变化事件监听

+ 6 - 3
lib/view/measure/measure_view.dart

@@ -358,11 +358,14 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
   bool isMeasureTool = true;
   bool get isArrowMeasureAnnotationType =>
       measureHandler.changedAnnotationType == AnnotationType.arrow;
+  TabEnum curSelectedTab = TabEnum.tabMeasureTool;
   void _onChangedTab(
     Object sender,
-    TabEnum? e,
+    TabEnum e,
   ) {
-    setState(() {});
+    setState(() {
+      curSelectedTab = e;
+    });
   }
 
   void _onCurItemMetaListChanged(sender, e) {
@@ -434,7 +437,7 @@ class _MeasureLeftBoardState extends State<_MeasureLeftBoard> {
       children: [
         if (showMeasureItems) ...[
           LeftSiderHold(ifHideConfig: showCarotid2DSelectMeasure),
-          if (!(measureHandler.changedTab == TabEnum.tabMeasureTool)) ...[
+          if ((curSelectedTab == TabEnum.tabNodesTool)) ...[
             FContainer(
               width: 300,
               key: UniqueKey(),

+ 24 - 23
lib/view/measure/tool_chest_title.dart

@@ -133,49 +133,44 @@ class _LeftSiderTabBarState extends State<_LeftSiderTabBar>
   @override
   void initState() {
     super.initState();
-    initTab();
+    measureHandler.commentsLoaded.addListener(onCommentsLoaded);
     measureController.imageLoaded.addListener(onImageLoaded);
   }
 
   @override
   void dispose() {
     super.dispose();
+    measureHandler.commentsLoaded.removeListener(onCommentsLoaded);
     measureController.imageLoaded.removeListener(onImageLoaded);
     tabController.dispose();
   }
 
   void initTab() {
-    Future.delayed(const Duration(milliseconds: 500), () {
-      application = Get.find<IApplication>();
-      if (application.isSingleFrame) {
-        if (application.visuals.length > 1) {
-          //多幅vid
-          tabs = [i18nBook.measure.annotationTool.t]
-              .map((e) => Center(child: Tab(text: e)))
-              .toList();
-          changeTabTo(TabEnum.tabNodesTool);
-        } else {
-          tabs = [
-            i18nBook.measure.measureTool.t,
-            i18nBook.measure.annotationTool.t
-          ].map((e) => Center(child: Tab(text: e))).toList();
-          changeTabTo(TabEnum.tabNodesTool);
-        }
+    application = Get.find<IApplication>();
+    if (application.isSingleFrame) {
+      if (application.visuals.length > 1) {
+        //多幅vid
+        tabs = [i18nBook.measure.annotationTool.t]
+            .map((e) => Center(child: Tab(text: e)))
+            .toList();
+        changeTabTo(TabEnum.tabNodesTool);
       } else {
         tabs = [
           i18nBook.measure.measureTool.t,
           i18nBook.measure.annotationTool.t
         ].map((e) => Center(child: Tab(text: e))).toList();
-        changeTabTo(TabEnum.tabNodesTool);
+        changeTabTo(TabEnum.tabMeasureTool);
       }
-      setState(() {});
-    });
+    } else {
+      tabs = [i18nBook.measure.measureTool.t, i18nBook.measure.annotationTool.t]
+          .map((e) => Center(child: Tab(text: e)))
+          .toList();
+      changeTabTo(TabEnum.tabMeasureTool);
+    }
+    setState(() {});
   }
 
   void changeTabTo(e) {
-    if (measureHandler.changedTab == e) {
-      return;
-    }
     measureHandler.changedTab = e;
     if (e == TabEnum.tabMeasureTool) {
       final measureMetaController = Get.find<MeasureMetaController>();
@@ -187,6 +182,12 @@ class _LeftSiderTabBarState extends State<_LeftSiderTabBar>
     }
   }
 
+  // 应该在图像注释获取完成后再触发initTab
+  void onCommentsLoaded(Object sender, _) {
+    if (!mounted) return;
+    initTab();
+  }
+
   void onImageLoaded(Object sender, ExamImageInfo? e) {
     if (!mounted) return;
     initTab();