Ver código fonte

[New]新增沉浸式控制

zhipeng 1 ano atrás
pai
commit
9ea9478134

+ 8 - 2
lib/base/base_page.dart

@@ -16,7 +16,9 @@ abstract class BasePage<T extends GetxController> extends GetView<T> {
       ),
       child: Container(
         color: backgroundColor(),
-        child: buildBody(context),
+        child: immersive()
+            ? buildBody(context)
+            : SafeArea(child: buildBody(context)),
       ),
     );
   }
@@ -29,7 +31,11 @@ abstract class BasePage<T extends GetxController> extends GetView<T> {
     return true;
   }
 
-  Widget? buildBody(BuildContext context);
+  bool immersive() {
+    return false;
+  }
+
+  Widget buildBody(BuildContext context);
 
   Color backgroundColor() {
     return ColorName.bgColorPrimary;

+ 32 - 0
lib/module/files/search/view.dart

@@ -0,0 +1,32 @@
+import 'package:electronic_assistant/base/base_page.dart';
+import 'package:electronic_assistant/resource/assets.gen.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_screenutil/flutter_screenutil.dart';
+
+class FileSearchPage extends BasePage {
+  const FileSearchPage({super.key});
+
+  @override
+  Widget buildBody(BuildContext context) {
+    return Column(children: [
+      Row(
+        children: [
+          Expanded(
+              child: CupertinoSearchTextField(
+            placeholder: '搜索所有文件标题 / 内容',
+            prefixIcon:
+                ImageIcon(Assets.images.iconSearch.provider(), size: 20.w),
+          )),
+          const TextButton(onPressed: null, child: Text('取消')),
+        ],
+      ),
+    ]);
+  }
+
+  @override
+  bool immersive() {
+    // TODO: implement immersive
+    return true;
+  }
+}

+ 23 - 17
lib/module/files/view.dart

@@ -10,25 +10,28 @@ class FilesPage extends BasePage<FilesController> {
   const FilesPage({super.key});
 
   @override
-  Widget? buildBody(BuildContext context) {
+  Widget buildBody(BuildContext context) {
     return Scaffold(
+      backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
+      appBar: AppBar(
+        title: const Text('文件夹'),
+        backgroundColor: const Color.fromRGBO(246, 245, 248, 1),
+        scrolledUnderElevation: 0,
+        actions: [
+          IconButton(
+            onPressed: () {},
+            icon: ImageIcon(Assets.images.iconFilesNewDir.provider()),
+          ),
+          IconButton(
+            onPressed: () {},
+            icon: ImageIcon(Assets.images.iconMore.provider()),
+          ),
+        ],
+      ),
       body: Column(
         children: [
           Column(
             children: [
-              AppBar(
-                title: const Text('文件夹'),
-                actions: [
-                  IconButton(
-                    onPressed: () {},
-                    icon: ImageIcon(Assets.images.iconFilesNewDir.provider()),
-                  ),
-                  IconButton(
-                    onPressed: () {},
-                    icon: ImageIcon(Assets.images.iconMore.provider()),
-                  ),
-                ],
-              ),
               Container(
                 margin: EdgeInsets.symmetric(horizontal: 12.w),
                 padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 8.w),
@@ -40,11 +43,12 @@ class FilesPage extends BasePage<FilesController> {
                 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),
+                    iconColor: const Color.fromRGBO(95, 95, 97, 1)
                   ),
                   style: TextStyle(fontSize: 14.sp),
                 ),
@@ -168,15 +172,17 @@ class FilesPage extends BasePage<FilesController> {
                     Container(
                       margin: EdgeInsets.only(top: 6.w),
                       child: Row(
+                        crossAxisAlignment: CrossAxisAlignment.center,
                         children: [
                           Text("1m12s",
                               style: TextStyle(
                                   fontSize: 12.sp,
                                   color: ColorName.tertiaryTextColor)),
-                          Text(" | ",
+                          Text("  |  ",
                               style: TextStyle(
                                   fontSize: 12.sp,
-                                  color: ColorName.tertiaryTextColor)),
+                                  color: ColorName.tertiaryTextColor,
+                                  fontWeight: FontWeight.bold)),
                           Text("2021-09-09 12:00:00",
                               style: TextStyle(
                                   fontSize: 12.sp,

+ 1 - 1
lib/module/home/view.dart

@@ -18,7 +18,7 @@ class HomePage extends BasePage<HomePageController> {
   BuildContext? todoTargetContext;
 
   @override
-  Widget? buildBody(BuildContext context) {
+  Widget buildBody(BuildContext context) {
     return Stack(
       children: [
         buildBgBox(),

+ 1 - 1
lib/module/login/view.dart

@@ -5,7 +5,7 @@ class LoginPage extends BasePage {
   const LoginPage({super.key});
 
   @override
-  Widget? buildBody(BuildContext context) {
+  Widget buildBody(BuildContext context) {
     // TODO: implement buildBody
     throw UnimplementedError();
   }

+ 1 - 1
lib/module/main/view.dart

@@ -19,7 +19,7 @@ class MainTabPage extends BasePage<MainController> {
   ];
 
   @override
-  Widget? buildBody(BuildContext context) {
+  Widget buildBody(BuildContext context) {
     return Scaffold(
       body: Obx(() {
         return pages[controller.currentIndex];

+ 1 - 1
lib/module/splash/view.dart

@@ -12,7 +12,7 @@ class SplashPage extends BasePage {
   final splashDelayedTime = 1;
 
   @override
-  Widget? buildBody(BuildContext context) {
+  Widget buildBody(BuildContext context) {
     Timer(Duration(seconds: splashDelayedTime), () {
       Get.offNamed(RoutePath.mainTab);
     });

+ 4 - 0
lib/router/app_pages.dart

@@ -1,6 +1,7 @@
 import 'package:electronic_assistant/module/main/controller.dart';
 import 'package:get/get.dart';
 
+import '../module/files/search/view.dart';
 import '../module/files/view.dart';
 import '../module/home/controller.dart';
 import '../module/login/view.dart';
@@ -21,6 +22,8 @@ abstract class RoutePath {
   static const mainTab = '/mainTab';
 
   static const files = '/files';
+
+  static const fileSearch = '/fileSearch';
 }
 
 class AppBinding extends Bindings {
@@ -40,4 +43,5 @@ final generalPages = [
   GetPage(name: RoutePath.login, page: () => const LoginPage()),
   GetPage(name: RoutePath.mainTab, page: () => MainTabPage()),
   GetPage(name: RoutePath.files, page: () => const FilesPage()),
+  GetPage(name: RoutePath.fileSearch, page: () => const FileSearchPage()),
 ];

+ 8 - 0
pubspec.lock

@@ -270,6 +270,14 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "5.9.3"
+  flutter_smart_dialog:
+    dependency: "direct main"
+    description:
+      name: flutter_smart_dialog
+      sha256: "3d376ba47f64391cc657f706815b32dd6ff2e0f80553a5c9f33b812ba7c59462"
+      url: "https://pub.dev"
+    source: hosted
+    version: "4.9.8"
   flutter_test:
     dependency: "direct dev"
     description: flutter