Pārlūkot izejas kodu

[new]首页增加空视图显示

zk 1 gadu atpakaļ
vecāks
revīzija
245f0afb3f

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

@@ -181,4 +181,6 @@
     <string name="copy_success">已复制</string>
     <string name="talk_detail_search_txt">查找</string>
     <string name="talk_search_hint">输入关键词查找</string>
+    <string name="home_agenda_no_data">暂无待办</string>
+    <string name="home_talk_no_data">暂无谈话记录</string>
 </resources>

+ 26 - 22
lib/module/home/agenda/view.dart

@@ -1,5 +1,6 @@
 import 'package:electronic_assistant/base/base_page.dart';
 import 'package:electronic_assistant/data/bean/agenda.dart';
+import 'package:electronic_assistant/module/home/common_view.dart';
 import 'package:electronic_assistant/utils/expand.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/gestures.dart';
@@ -73,31 +74,34 @@ class HomeAgendaView extends BasePage<HomeAgendaController> {
 
   Widget _buildSeeMoreView() {
     return Obx(() {
-      return Visibility(
-        visible: controller.agendaList.isNotEmpty,
-        child: Container(
+      if (controller.agendaList.isNotEmpty) {
+        return Container(
           alignment: Alignment.center,
           padding: EdgeInsets.only(
               top: 16.w, bottom: 100.w + Constants.bottomBarHeight),
-          child: RichText(
-            text: TextSpan(
-              text: StringName.homeTalkTodo1.tr,
-              style: TextStyle(
-                  color: ColorName.secondaryTextColor, fontSize: 12.sp),
-              children: <TextSpan>[
-                TextSpan(
-                    text: StringName.homeTalkTodo2.tr,
-                    style: TextStyle(
-                        color: ColorName.colorPrimary, fontSize: 12.sp),
-                    recognizer: TapGestureRecognizer()
-                      ..onTap = () {
-                        controller.onGoAgendaSeeAll();
-                      }),
-              ],
-            ),
-          ),
-        ),
-      );
+          child: _buildMoreView(),
+        );
+      } else {
+        return homeEmptyView(StringName.homeAgendaNoData.tr, _buildMoreView());
+      }
     });
   }
+
+  Widget _buildMoreView() {
+    return RichText(
+      text: TextSpan(
+        text: StringName.homeTalkTodo1.tr,
+        style: TextStyle(color: ColorName.secondaryTextColor, fontSize: 12.sp),
+        children: <TextSpan>[
+          TextSpan(
+              text: StringName.homeTalkTodo2.tr,
+              style: TextStyle(color: ColorName.colorPrimary, fontSize: 12.sp),
+              recognizer: TapGestureRecognizer()
+                ..onTap = () {
+                  controller.onGoAgendaSeeAll();
+                }),
+        ],
+      ),
+    );
+  }
 }

+ 22 - 0
lib/module/home/common_view.dart

@@ -0,0 +1,22 @@
+import 'package:electronic_assistant/resource/assets.gen.dart';
+import 'package:electronic_assistant/resource/colors.gen.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+
+Widget homeEmptyView(String title, Widget descWidget) {
+  return Column(
+    children: [
+      SizedBox(height: 120.h),
+      Assets.images.iconNoTask.image(width: 100.w, height: 100.w),
+      SizedBox(height: 4.h),
+      Text(title,
+          style: TextStyle(
+            fontSize: 15.sp,
+            fontWeight: FontWeight.bold,
+            color: ColorName.primaryTextColor,
+          )),
+      SizedBox(height: 2.h),
+      descWidget
+    ],
+  );
+}

+ 26 - 22
lib/module/home/talk/view.dart

@@ -11,6 +11,7 @@ import '../../../data/consts/Constants.dart';
 import '../../../resource/assets.gen.dart';
 import '../../../resource/colors.gen.dart';
 import '../../../resource/string.gen.dart';
+import '../common_view.dart';
 import 'controller.dart';
 
 class HomeTalkView extends BasePage<HomeTalkController> {
@@ -49,34 +50,37 @@ class HomeTalkView extends BasePage<HomeTalkController> {
 
   Widget _buildSeeMoreView() {
     return Obx(() {
-      return Visibility(
-        visible: controller.talkList.isNotEmpty,
-        child: Container(
+      if (controller.talkList.isNotEmpty) {
+        return Container(
           alignment: Alignment.center,
           padding: EdgeInsets.only(
               top: 16.w, bottom: 100.w + Constants.bottomBarHeight),
-          child: RichText(
-            text: TextSpan(
-              text: StringName.homeTalkSeeMoreTxt.tr,
-              style: TextStyle(
-                  color: ColorName.secondaryTextColor, fontSize: 12.sp),
-              children: <TextSpan>[
-                TextSpan(
-                    text: StringName.homeTalkAll.tr,
-                    style: TextStyle(
-                        color: ColorName.colorPrimary, fontSize: 12.sp),
-                    recognizer: TapGestureRecognizer()
-                      ..onTap = () {
-                        controller.onGoTalkSeeAll();
-                      }),
-              ],
-            ),
-          ),
-        ),
-      );
+          child: _buildMoreView(),
+        );
+      } else {
+        return homeEmptyView(StringName.homeTalkNoData.tr, _buildMoreView());
+      }
     });
   }
 
+  Widget _buildMoreView() {
+    return RichText(
+      text: TextSpan(
+        text: StringName.homeTalkSeeMoreTxt.tr,
+        style: TextStyle(color: ColorName.secondaryTextColor, fontSize: 12.sp),
+        children: <TextSpan>[
+          TextSpan(
+              text: StringName.homeTalkAll.tr,
+              style: TextStyle(color: ColorName.colorPrimary, fontSize: 12.sp),
+              recognizer: TapGestureRecognizer()
+                ..onTap = () {
+                  controller.onGoTalkSeeAll();
+                }),
+        ],
+      ),
+    );
+  }
+
   Widget _buildTalkView(TalkBean item) {
     return _buildTalkItem(item, onLongPressStart: (details) {
       controller.onLongPressTalkItem(item, details);