Browse Source

[New]新增文件搜索页

zhipeng 1 year ago
parent
commit
c4b7c428e0

BIN
assets/images/icon_arrow_down.webp


BIN
assets/images/icon_files_order_selected.webp


+ 1 - 1
lib/base/base_page.dart

@@ -40,4 +40,4 @@ abstract class BasePage<T extends GetxController> extends GetView<T> {
   Color backgroundColor() {
   Color backgroundColor() {
     return ColorName.bgColorPrimary;
     return ColorName.bgColorPrimary;
   }
   }
-}
+}

+ 255 - 9
lib/module/files/search/view.dart

@@ -1,8 +1,11 @@
 import 'package:electronic_assistant/base/base_page.dart';
 import 'package:electronic_assistant/base/base_page.dart';
 import 'package:electronic_assistant/resource/assets.gen.dart';
 import 'package:electronic_assistant/resource/assets.gen.dart';
+import 'package:electronic_assistant/resource/colors.gen.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:get/get.dart';
+import 'package:get/get_core/src/get_main.dart';
 
 
 class FileSearchPage extends BasePage {
 class FileSearchPage extends BasePage {
   const FileSearchPage({super.key});
   const FileSearchPage({super.key});
@@ -13,20 +16,263 @@ class FileSearchPage extends BasePage {
       Row(
       Row(
         children: [
         children: [
           Expanded(
           Expanded(
-              child: CupertinoSearchTextField(
-            placeholder: '搜索所有文件标题 / 内容',
-            prefixIcon:
-                ImageIcon(Assets.images.iconSearch.provider(), size: 20.w),
-          )),
-          const TextButton(onPressed: null, child: Text('取消')),
+              child: Padding(
+                padding: EdgeInsets.only(left: 12.w),
+                child: CupertinoSearchTextField(
+                  placeholder: '搜索所有文件标题 / 内容',
+                  prefixIcon:
+                  ImageIcon(Assets.images.iconSearch.provider(), size: 20.w),
+                  backgroundColor: const Color(0xFFF6F6F6),
+                  style:
+                  TextStyle(fontSize: 14.w, color: ColorName.primaryTextColor),
+                  placeholderStyle:
+                  TextStyle(fontSize: 14.w, color: const Color(0xFFAFAFAF)),
+                ),
+              )),
+          TextButton(
+              onPressed: () {
+                Get.back();
+              },
+              child: Text('取消',
+                  style: TextStyle(
+                      fontSize: 14.w, color: ColorName.secondaryTextColor))),
         ],
         ],
       ),
       ),
+      Padding(
+        padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 12.w),
+        child: Row(children: [
+          Text(
+            "搜索结果",
+            style: TextStyle(
+                fontSize: 15.w,
+                color: ColorName.primaryTextColor,
+                fontWeight: FontWeight.bold),
+          ),
+          Expanded(
+              child: Row(
+                mainAxisAlignment: MainAxisAlignment.end,
+                children: [
+                  Text("更新时间排序",
+                      style: TextStyle(
+                          fontSize: 14.w,
+                          fontWeight: FontWeight.bold,
+                          color: ColorName.primaryTextColor)),
+                  Image(
+                      image: Assets.images.iconArrowDown.provider(),
+                      width: 16.w,
+                      height: 16.w)
+                ],
+              ))
+        ]),
+      ),
+      Visibility(
+        visible: true,
+        child: Expanded(
+            child: Stack(
+              fit: StackFit.expand,
+              children: [
+                Padding(
+                  padding: EdgeInsets.symmetric(horizontal: 12.w),
+                  child: CustomScrollView(
+                    slivers: [
+                      SliverToBoxAdapter(
+                          child: Text("文件夹",
+                              style: TextStyle(
+                                  fontSize: 14.w,
+                                  color: ColorName.secondaryTextColor))),
+                      SliverAnimatedList(
+                        itemBuilder: _dirItemBuilder,
+                        initialItemCount: 5,
+                      ),
+                      SliverToBoxAdapter(
+                          child: Container(
+                            margin: EdgeInsets.only(top: 8.w),
+                            child: Text("谈话",
+                                style: TextStyle(
+                                    fontSize: 14.w,
+                                    color: ColorName.secondaryTextColor)),
+                          )),
+                      SliverAnimatedList(
+                        itemBuilder: _fileItemBuilder,
+                        initialItemCount: 5,
+                      ),
+                    ],
+                  ),
+                ),
+                Visibility(
+                  visible: false,
+                  child: Stack(
+                    children: [
+                      Container(
+                        color: ColorName.black55,
+                      ),
+                      Container(
+                        // color: ColorName.white,
+                        width: double.infinity,
+                        decoration: BoxDecoration(
+                            color: ColorName.white,
+                            borderRadius: BorderRadius.only(
+                                bottomLeft: Radius.circular(16.w),
+                                bottomRight: Radius.circular(16.w))),
+                        child: Padding(
+                          padding:
+                          EdgeInsets.symmetric(horizontal: 12.w, vertical: 12
+                              .w),
+                          child: IntrinsicHeight(
+                            child: Column(
+                              children: [
+                                Container(
+                                  margin: EdgeInsets.only(bottom: 22.w),
+                                  child: Row(
+                                    children: [
+                                      const Expanded(
+                                          child: Text('更新时间排序',
+                                              style: TextStyle(
+                                                  fontSize: 14,
+                                                  fontWeight: FontWeight.bold,
+                                                  color: ColorName
+                                                      .colorPrimary))),
+                                      ImageIcon(
+                                          Assets.images.iconFilesOrderSelected
+                                              .provider(),
+                                          size: 20.w,
+                                          color: ColorName.colorPrimary)
+                                    ],
+                                  ),
+                                ),
+                                Container(
+                                  margin: EdgeInsets.only(bottom: 6.w),
+                                  child: Row(
+                                    children: [
+                                      const Expanded(
+                                          child: Text('创建时间排序')),
+                                      ImageIcon(
+                                          Assets.images.iconFilesOrderSelected
+                                              .provider(),
+                                          size: 20.w)
+                                    ],
+                                  ),
+                                )
+                              ],
+                            ),
+                          ),
+                        ),
+                      )
+                    ],
+                  ),
+                )
+              ],
+            )),
+      )
     ]);
     ]);
   }
   }
 
 
   @override
   @override
   bool immersive() {
   bool immersive() {
-    // TODO: implement immersive
-    return true;
+    return false;
+  }
+
+  Widget _dirItemBuilder(BuildContext context, int index,
+      Animation<double> animation) {
+    return Padding(
+      padding: EdgeInsets.symmetric(vertical: 12.w),
+      child: Row(
+        crossAxisAlignment: CrossAxisAlignment.center,
+        children: [
+          Image(
+            image: Assets.images.iconFilesDir.provider(),
+            width: 32.w,
+            height: 32.w,
+          ),
+          Expanded(
+            child: Container(
+              margin: EdgeInsets.only(left: 8.w),
+              child: Column(
+                mainAxisAlignment: MainAxisAlignment.center,
+                crossAxisAlignment: CrossAxisAlignment.start,
+                children: [
+                  Text('文件夹 $index',
+                      maxLines: 1,
+                      style: TextStyle(
+                          fontSize: 15.w,
+                          color: ColorName.primaryTextColor,
+                          fontWeight: FontWeight.bold,
+                          overflow: TextOverflow.ellipsis)),
+                  Text('日期 $index',
+                      maxLines: 1,
+                      style: TextStyle(
+                          fontSize: 12.w,
+                          color: ColorName.secondaryTextColor,
+                          overflow: TextOverflow.ellipsis)),
+                ],
+              ),
+            ),
+          )
+        ],
+      ),
+    );
+  }
+
+  Widget _fileItemBuilder(BuildContext context, int index,
+      Animation<double> animation) {
+    return Padding(
+      padding: EdgeInsets.symmetric(vertical: 12.w),
+      child: Row(
+        crossAxisAlignment: CrossAxisAlignment.start,
+        children: [
+          Image(
+            image: Assets.images.iconFilesFile.provider(),
+            width: 32.w,
+            height: 32.w,
+          ),
+          Expanded(
+            child: Container(
+              margin: EdgeInsets.only(left: 8.w),
+              child: Column(
+                mainAxisAlignment: MainAxisAlignment.center,
+                crossAxisAlignment: CrossAxisAlignment.start,
+                children: [
+                  Text('文件夹 $index',
+                      maxLines: 1,
+                      style: TextStyle(
+                          fontSize: 15.w,
+                          color: ColorName.primaryTextColor,
+                          fontWeight: FontWeight.bold,
+                          overflow: TextOverflow.ellipsis)),
+                  Text('缩略 $index',
+                      maxLines: 1,
+                      style: TextStyle(
+                          fontSize: 12.w,
+                          color: ColorName.secondaryTextColor,
+                          overflow: TextOverflow.ellipsis)),
+                  Container(
+                    margin: EdgeInsets.only(top: 6.w),
+                    child: Row(
+                      children: [
+                        Text('1m12s',
+                            maxLines: 1,
+                            style: TextStyle(
+                                fontSize: 12.w, color: ColorName
+                                .tertiaryTextColor)),
+                        Text(' | ',
+                            maxLines: 1,
+                            style: TextStyle(
+                                fontSize: 12.w, color: ColorName
+                                .tertiaryTextColor)),
+                        Text('2024-04-15 10:04',
+                            maxLines: 1,
+                            style: TextStyle(
+                                fontSize: 12.w, color: ColorName
+                                .tertiaryTextColor)),
+                      ],
+                    ),
+                  )
+                ],
+              ),
+            ),
+          )
+        ],
+      ),
+    );
   }
   }
-}
+}

+ 27 - 18
lib/module/files/view.dart

@@ -1,8 +1,11 @@
 import 'package:electronic_assistant/base/base_page.dart';
 import 'package:electronic_assistant/base/base_page.dart';
 import 'package:electronic_assistant/module/files/controller.dart';
 import 'package:electronic_assistant/module/files/controller.dart';
 import 'package:electronic_assistant/resource/colors.gen.dart';
 import 'package:electronic_assistant/resource/colors.gen.dart';
+import 'package:electronic_assistant/router/app_pages.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
+import 'package:get/get.dart';
+import 'package:get/get_core/src/get_main.dart';
 
 
 import '../../resource/assets.gen.dart';
 import '../../resource/assets.gen.dart';
 
 
@@ -37,25 +40,31 @@ class FilesPage extends BasePage<FilesController> {
         children: [
         children: [
           Column(
           Column(
             children: [
             children: [
-              Container(
-                margin: EdgeInsets.symmetric(horizontal: 12.w),
-                padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
-                height: 36.w,
-                decoration: BoxDecoration(
-                  color: Colors.white,
-                  borderRadius: BorderRadius.circular(8.w),
-                ),
-                child: TextField(
-                  maxLines: 1,
-                  textAlignVertical: TextAlignVertical.center,
-                  textInputAction: TextInputAction.search,
-                  decoration: InputDecoration(
-                    hintText: '搜索所有文件标题 / 内容',
-                    border: InputBorder.none,
-                    icon: ImageIcon(Assets.images.iconSearch.provider()),
-                    iconColor: const Color.fromRGBO(95, 95, 97, 1)
+              GestureDetector(
+                onTap: () {
+                  Get.toNamed(RoutePath.fileSearch);
+                },
+                child: Container(
+                  margin: EdgeInsets.symmetric(horizontal: 12.w),
+                  padding:
+                      EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
+                  height: 36.w,
+                  decoration: BoxDecoration(
+                    color: Colors.white,
+                    borderRadius: BorderRadius.circular(8.w),
+                  ),
+                  child: TextField(
+                    maxLines: 1,
+                    textAlignVertical: TextAlignVertical.center,
+                    textInputAction: TextInputAction.search,
+                    decoration: InputDecoration(
+                        hintText: '搜索所有文件标题 / 内容',
+                        border: InputBorder.none,
+                        icon: ImageIcon(Assets.images.iconSearch.provider()),
+                        iconColor: const Color.fromRGBO(95, 95, 97, 1),
+                        enabled: false),
+                    style: TextStyle(fontSize: 14.sp),
                   ),
                   ),
-                  style: TextStyle(fontSize: 14.sp),
                 ),
                 ),
               ),
               ),
             ],
             ],