Bläddra i källkod

[fix]解决谈话详情首次进入不显示tab栏的问题

zk 1 år sedan
förälder
incheckning
5f347e310a
2 ändrade filer med 60 tillägg och 65 borttagningar
  1. 18 17
      lib/module/talk/controller.dart
  2. 42 48
      lib/module/talk/view.dart

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

@@ -95,9 +95,11 @@ class TalkController extends BaseController {
 
   final Rxn<TalkBarBean> checkTabBean = Rxn();
 
-  final RxList<TalkBarBean> _tabBeans = RxList();
+  final List<TalkBarBean> tabBeans = [];
 
-  List<TalkBarBean> get tabBeans => _tabBeans;
+  final List<Widget> pages = [];
+
+  final isInitializedView = false.obs;
 
   bool get isEditModel => _isEditModel.value;
 
@@ -158,14 +160,11 @@ class TalkController extends BaseController {
 
   RxBool isShowMindMap = false.obs;
 
-  final RxList<Widget> pages = RxList();
-
   @override
-  void onInit() async {
+  void onInit() {
     super.onInit();
     _getArguments();
-    await _analyticWebVersion();
-    checkTabBean.value = _tabBeans[defaultIndex];
+    _analyticWebVersion();
   }
 
   Future<void> _analyticWebVersion() async {
@@ -198,33 +197,35 @@ class TalkController extends BaseController {
     isShowMindMap.value = isShow;
     String? talkId = talkBean.value != null ? talkBean.value!.id : paramId;
     if (isShow) {
-      pages.value = [
+      pages.assignAll([
         SummaryView(talkId),
         MindMapView(talkId),
         TodoView(talkId),
         OriginalView(talkId),
-      ];
-      _tabBeans.value = [
+      ]);
+      tabBeans.assignAll([
         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)
-      ];
+      ]);
       EventHandler.report(EventId.event_101401, params: {EventId.id: version});
     } else {
-      pages.value = [
+      pages.assignAll([
         SummaryView(talkId),
         TodoView(talkId),
         OriginalView(talkId),
-      ];
-      _tabBeans.value = [
+      ]);
+      tabBeans.assignAll([
         TalkBarBean(TalkBarType.summary, StringName.talkTabSummary.tr, true),
         TalkBarBean(TalkBarType.myTask, StringName.talkTabMyTask.tr, true),
-        TalkBarBean(TalkBarType.original, StringName.talkTabOriginal.tr, true)
-      ];
+        TalkBarBean(TalkBarType.original, StringName.talkTabOriginal.tr, false)
+      ]);
       EventHandler.report(EventId.event_101402, params: {EventId.id: version});
     }
+    checkTabBean.value = tabBeans[defaultIndex];
+    isInitializedView.value = true;
   }
 
   @override
@@ -588,7 +589,7 @@ class TalkController extends BaseController {
   }
 
   void updateTabIndex(int index) {
-    checkTabBean.value = _tabBeans[index];
+    checkTabBean.value = tabBeans[index];
   }
 
   void onEditCancel() {

+ 42 - 48
lib/module/talk/view.dart

@@ -70,24 +70,24 @@ class TalkPage extends BasePage<TalkController> {
         }
         return true;
       },
-      child: Obx(() {
-        return DefaultTabController(
-          initialIndex: controller.defaultIndex,
-          length: controller.tabBeans.length,
-          child: Stack(
-            children: [
-              Obx(() {
-                return controller.temporaryController != null
-                    ? DWebViewWidget(
-                        controller: controller.temporaryController!)
-                    : const SizedBox.shrink();
-              }),
-              _buildTalkContentView(),
-              buildBottomView()
-            ],
-          ),
-        );
-      }),
+      child: Stack(
+        children: [
+          Obx(() {
+            return controller.temporaryController != null
+                ? DWebViewWidget(controller: controller.temporaryController!)
+                : const SizedBox.shrink();
+          }),
+          Obx(() {
+            return controller.isInitializedView.value
+                ? DefaultTabController(
+                    initialIndex: controller.defaultIndex,
+                    length: controller.tabBeans.length,
+                    child: _buildTalkContentView())
+                : const SizedBox.shrink();
+          }),
+          buildBottomView()
+        ],
+      ),
     );
   }
 
@@ -142,25 +142,23 @@ class TalkPage extends BasePage<TalkController> {
       if (!controller.isEditModel) {
         return Column(
           children: [
-            controller.tabBeans.isEmpty
-                ? const SizedBox.shrink()
-                : 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()),
+            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)
           ],
@@ -193,17 +191,13 @@ class TalkPage extends BasePage<TalkController> {
 
   Widget buildTabContentView() {
     return Expanded(
-      child: Obx(() {
-        return controller.pages.isEmpty
-            ? const SizedBox.shrink()
-            : TabBarView(
-                physics: controller.isEditModel ||
-                        controller.checkTabBean.value?.isDisallowScroll == true
-                    ? const NeverScrollableScrollPhysics()
-                    : null,
-                children: controller.pages,
-              );
-      }),
+      child: TabBarView(
+        physics: controller.isEditModel ||
+                controller.checkTabBean.value?.isDisallowScroll == true
+            ? const NeverScrollableScrollPhysics()
+            : null,
+        children: controller.pages,
+      ),
     );
   }