Browse Source

[new]待办增加筛选浮窗

zk 1 year ago
parent
commit
b0a99e2169

BIN
assets/images/icon_popup_selected.webp


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

@@ -124,4 +124,8 @@
     <string name="store_pay_success">充电成功</string>
     <string name="talk_summary_todo_title">所有待办</string>
     <string name="exit_app_tip">再按一次退出应用</string>
+    <string name="popup_nearly_a_week">近一周</string>
+    <string name="popup_nearly_two_week">近两周</string>
+    <string name="popup_nearly_a_month">近一个月</string>
+    <string name="popup_custom_time">自定义时间</string>
 </resources>

+ 1 - 1
lib/data/consts/constants.dart

@@ -7,7 +7,7 @@ import '../../utils/common_utils.dart';
 class Constants {
   Constants._();
 
-  static const String env = envProd;
+  static const String env = envTest;
 
   static const String envDev = 'dev';
 

+ 8 - 0
lib/module/agenda/controller.dart

@@ -23,12 +23,20 @@ class AgendaController extends BaseController {
   final doneSize = 0.obs;
   final int limit = 10;
 
+  int _timeFilterIndex = 0;
+
+  int get timeFilterIndex => _timeFilterIndex;
+
   @override
   void onReady() {
     refreshTodoTaskList();
     agendaDonePage(0, limit, isClearAll: true);
   }
 
+  void setTimeFilterIndex(int index) {
+    _timeFilterIndex = index;
+  }
+
   void onLoadMoreDoneData() {
     agendaDonePage(agendaDoneList.length, limit);
   }

+ 58 - 47
lib/module/agenda/view.dart

@@ -13,6 +13,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
 
 import '../../data/bean/agenda.dart';
 import '../../data/repositories/account_repository.dart';
+import '../../popup/agenda_time_popup.dart';
 import '../../popup/common_popup.dart';
 import '../../popup/template_utils.dart';
 import '../../resource/assets.gen.dart';
@@ -52,52 +53,7 @@ class AgendaPage extends BasePage<AgendaController> {
                       color: ColorName.primaryTextColor)),
               centerTitle: true,
             ),
-            Row(
-              children: [
-                Expanded(
-                    child: Container(
-                  height: 36.h,
-                  margin: EdgeInsets.only(left: 12.w),
-                  decoration: BoxDecoration(
-                      color: ColorName.white,
-                      borderRadius: BorderRadius.circular(8.w)),
-                  padding: EdgeInsets.only(left: 12.w),
-                  child: Row(
-                    children: [
-                      Assets.images.iconSearch.image(width: 20.w, height: 20.w),
-                      SizedBox(width: 6.w),
-                      Text(
-                        StringName.searchHint.tr,
-                        style: TextStyle(
-                            fontSize: 14.sp,
-                            color: ColorName.tertiaryTextColor),
-                      )
-                    ],
-                  ),
-                )),
-                GestureDetector(
-                  onTap: () {},
-                  child: Column(
-                    mainAxisAlignment: MainAxisAlignment.center,
-                    children: [
-                      Container(
-                          margin: EdgeInsets.symmetric(horizontal: 16.w),
-                          width: 20.w,
-                          height: 20.w,
-                          child: Assets.images.iconSift.image()),
-                      // Replace with your image asset
-                      SizedBox(height: 2.h),
-                      // Add some space between the image and text
-                      Text(
-                        StringName.agendaSift.tr,
-                        style: TextStyle(
-                            fontSize: 10.sp, color: ColorName.primaryTextColor),
-                      ),
-                    ],
-                  ),
-                )
-              ],
-            ),
+            _buildSearchView(),
             SizedBox(height: 12.h),
             Container(
               margin: EdgeInsets.only(left: 12.w),
@@ -172,6 +128,61 @@ class AgendaPage extends BasePage<AgendaController> {
     );
   }
 
+  Widget _buildSearchView() {
+    return Row(
+      children: [
+        Expanded(
+            child: Container(
+          height: 36.h,
+          margin: EdgeInsets.only(left: 12.w),
+          decoration: BoxDecoration(
+              color: ColorName.white, borderRadius: BorderRadius.circular(8.w)),
+          padding: EdgeInsets.only(left: 12.w),
+          child: Row(
+            children: [
+              Assets.images.iconSearch.image(width: 20.w, height: 20.w),
+              SizedBox(width: 6.w),
+              Text(
+                StringName.searchHint.tr,
+                style: TextStyle(
+                    fontSize: 14.sp, color: ColorName.tertiaryTextColor),
+              )
+            ],
+          ),
+        )),
+        Builder(builder: (context) {
+          return GestureDetector(
+            onTap: () {
+              showAgendaTimePopup(
+                  context, Alignment.bottomLeft, controller.timeFilterIndex,
+                  callback: (index) {
+                controller.setTimeFilterIndex(index);
+              });
+            },
+            child: Column(
+              mainAxisAlignment: MainAxisAlignment.center,
+              children: [
+                Container(
+                    margin: EdgeInsets.symmetric(horizontal: 16.w),
+                    width: 20.w,
+                    height: 20.w,
+                    child: Assets.images.iconSift.image()),
+                // Replace with your image asset
+                SizedBox(height: 2.h),
+                // Add some space between the image and text
+                Text(
+                  StringName.agendaSift.tr,
+                  style: TextStyle(
+                      fontSize: 10.sp, color: ColorName.primaryTextColor),
+                ),
+              ],
+            ),
+          );
+        })
+      ],
+    );
+  }
+
   Widget _buildTodoItem(BuildContext context, int index) {
     Agenda item = controller.agendaTodoList[index];
     return Builder(builder: (context) {
@@ -180,7 +191,7 @@ class AgendaPage extends BasePage<AgendaController> {
           if (!accountRepository.isLogin.value) {
             return;
           }
-          showCommonPopup(null, details.globalPosition, Alignment.bottomRight,
+          showPressTouchPopup(details.globalPosition, Alignment.bottomRight,
               _buildListUpdatePopupView(item, controller.agendaDetailPopupTag),
               tag: controller.agendaDetailPopupTag);
         },

+ 26 - 6
lib/popup/agenda_time_popup.dart

@@ -7,14 +7,34 @@ import 'package:get/get.dart';
 import '../resource/string.gen.dart';
 import 'common_popup.dart';
 
-void showAgendaTimePopup(
-  BuildContext context,
-  Alignment alignment,
-) {
-  showCommonPopup(context, const Offset(0, 0), alignment, [
-    createNormalPopupItem(StringName.talkRename.tr, onItemClick: () {
+typedef AgendaPopupCallback = void Function(int index);
+
+void showAgendaTimePopup(BuildContext context, Alignment alignment,
+    int selectIndex,
+    {AgendaPopupCallback? callback}) {
+  showViewTargetPopup(context, alignment, [
+    createSelectItem(StringName.popupNearlyAWeek.tr, selectIndex == 0,
+        onItemClick: () {
+          callback?.call(0);
       SmartDialog.dismiss();
     }),
     createPopupDivider(),
+    createSelectItem(StringName.popupNearlyTwoWeek.tr, selectIndex == 1,
+        onItemClick: () {
+      callback?.call(1);
+      SmartDialog.dismiss();
+    }),
+    createPopupDivider(),
+    createSelectItem(StringName.popupNearlyAMonth.tr, selectIndex == 2,
+        onItemClick: () {
+      callback?.call(2);
+      SmartDialog.dismiss();
+    }),
+    createPopupDivider(),
+    createSelectItem(StringName.popupCustomTime.tr, selectIndex == 3,
+        onItemClick: () {
+      callback?.call(3);
+      SmartDialog.dismiss();
+    }),
   ]);
 }

+ 41 - 3
lib/popup/common_popup.dart

@@ -6,11 +6,11 @@ import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
 
-void showCommonPopup(BuildContext? targetContext, Offset offset,
-    Alignment alignment, List<Widget> childWidget,
+void showPressTouchPopup(
+    Offset offset, Alignment alignment, List<Widget> childWidget,
     {String? tag, BuildContext? bindWidget}) {
   SmartDialog.showAttach(
-    targetContext: targetContext,
+    targetContext: null,
     targetBuilder: (_, __) => offset,
     animationType: SmartAnimationType.fade,
     clickMaskDismiss: true,
@@ -45,3 +45,41 @@ void showCommonPopup(BuildContext? targetContext, Offset offset,
     },
   );
 }
+
+void showViewTargetPopup(
+    BuildContext context, Alignment alignment, List<Widget> childWidget) {
+  SmartDialog.showAttach(
+    targetContext: context,
+    targetBuilder: (targetOffset, targetSize) {
+      return Offset(targetOffset.dx, targetOffset.dy);
+    },
+    alignment: alignment,
+    animationType: SmartAnimationType.fade,
+    clickMaskDismiss: true,
+    maskColor: Colors.transparent,
+    bindPage: true,
+    builder: (_) => IntrinsicWidth(
+      child: Container(
+        constraints: BoxConstraints(
+          minWidth: 128.w,
+        ),
+        decoration: BoxDecoration(
+          color: Colors.white,
+          border: Border.all(color: '#D8D8D8'.toColor(), width: 1), // 边框
+          borderRadius: BorderRadius.circular(8), // 圆角
+          boxShadow: [
+            BoxShadow(
+              color: Colors.black.withOpacity(0.1), // 阴影颜色
+              spreadRadius: 2, // 阴影扩散半径
+              blurRadius: 6, // 阴影模糊半径
+              offset: const Offset(0, 3), // 阴影偏移量
+            ),
+          ],
+        ),
+        child: Column(
+          children: childWidget,
+        ),
+      ),
+    ),
+  );
+}

+ 1 - 1
lib/popup/talk_popup.dart

@@ -10,7 +10,7 @@ import 'common_popup.dart';
 
 void showTalkPopup(Offset offset, Alignment alignment,
     {VoidCallback? onRename, VoidCallback? onDelete}) {
-  showCommonPopup(null, offset, alignment, [
+  showPressTouchPopup(offset, alignment, [
     createNormalPopupItem(StringName.talkRename.tr, onItemClick: () {
       SmartDialog.dismiss();
       onRename?.call();

+ 28 - 2
lib/popup/template_utils.dart

@@ -3,7 +3,6 @@ import 'dart:ui';
 import 'package:electronic_assistant/utils/expand.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
-import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
 import 'package:get/get.dart';
 
 import '../resource/assets.gen.dart';
@@ -36,7 +35,7 @@ Widget createNormalPopupItem(String title, {VoidCallback? onItemClick}) {
   );
 }
 
-GestureDetector createDeletePopupItem(VoidCallback? onDelete) {
+Widget createDeletePopupItem(VoidCallback? onDelete) {
   return GestureDetector(
     onTap: () {
       onDelete?.call();
@@ -63,5 +62,32 @@ GestureDetector createDeletePopupItem(VoidCallback? onDelete) {
   );
 }
 
+Widget createSelectItem(String title, bool isSelect,
+    {VoidCallback? onItemClick}) {
+  return GestureDetector(
+    onTap: onItemClick,
+    child: ConstrainedBox(
+      constraints: BoxConstraints(minWidth: 128.w, minHeight: 48.w),
+      child: Container(
+        color: ColorName.transparent,
+        child: Row(
+          children: [
+            SizedBox(width: 14.w),
+            Text(title,
+                style: TextStyle(
+                    fontSize: 14.sp, color: ColorName.primaryTextColor)),
+            const Spacer(),
+            Visibility(
+                visible: isSelect,
+                child: Assets.images.iconPopupSelected
+                    .image(width: 20.w, height: 20.w)),
+            SizedBox(width: 16.w),
+          ],
+        ),
+      ),
+    ),
+  );
+}
+
 final _itemHeight = 52.h;
 final _itemPadding = 14.w;