diff --git a/CHANGELOG.md b/CHANGELOG.md index 8feb19f..9fce4d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * 增加环境变量详情页 * 环境变量列表使用体验优化 * 部分页面进入卡顿优化 +* 扩大任务的搜索范围 ## 1.0.0 diff --git a/lib/module/home/home_page.dart b/lib/module/home/home_page.dart index 7af45df..4bee986 100644 --- a/lib/module/home/home_page.dart +++ b/lib/module/home/home_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:qinglong_app/base/ql_app_bar.dart'; import 'package:qinglong_app/base/routes.dart'; @@ -7,6 +8,7 @@ import 'package:qinglong_app/module/config/config_page.dart'; import 'package:qinglong_app/module/env/env_page.dart'; import 'package:qinglong_app/module/others/other_page.dart'; import 'package:qinglong_app/module/task/task_page.dart'; +import 'package:move_to_background/move_to_background.dart'; class HomePage extends ConsumerStatefulWidget { const HomePage({Key? key}) : super(key: key); @@ -100,48 +102,54 @@ class _HomePageState extends ConsumerState { )); } - return Scaffold( - appBar: QlAppBar( - canBack: false, - title: _title, - actions: actions, - ), - body: IndexedStack( - index: _index, - children: [ - const Positioned.fill( - child: TaskPage(), - ), - const Positioned.fill( - child: EnvPage(), - ), - Positioned.fill( - child: ConfigPage( - key: configKey, + return WillPopScope( + onWillPop: () async { + await MoveToBackground.moveTaskToBack(); + return false; + }, + child: Scaffold( + appBar: QlAppBar( + canBack: false, + title: _title, + actions: actions, + ), + body: IndexedStack( + index: _index, + children: [ + const Positioned.fill( + child: TaskPage(), ), - ), - const Positioned.fill( - child: OtherPage(), - ), - ], - ), - bottomNavigationBar: BottomNavigationBar( - items: titles - .map( - (e) => BottomNavigationBarItem( - icon: Icon(e.icon), - activeIcon: Icon(e.checkedIcon), - label: e.title, + const Positioned.fill( + child: EnvPage(), + ), + Positioned.fill( + child: ConfigPage( + key: configKey, ), - ) - .toList(), - currentIndex: _index, - onTap: (index) { - _index = index; - _title = titles[index].title; - setState(() {}); - }, - type: BottomNavigationBarType.fixed, + ), + const Positioned.fill( + child: OtherPage(), + ), + ], + ), + bottomNavigationBar: BottomNavigationBar( + items: titles + .map( + (e) => BottomNavigationBarItem( + icon: Icon(e.icon), + activeIcon: Icon(e.checkedIcon), + label: e.title, + ), + ) + .toList(), + currentIndex: _index, + onTap: (index) { + _index = index; + _title = titles[index].title; + setState(() {}); + }, + type: BottomNavigationBarType.fixed, + ), ), ); } diff --git a/lib/module/task/task_page.dart b/lib/module/task/task_page.dart index 07b5723..b1ffc93 100644 --- a/lib/module/task/task_page.dart +++ b/lib/module/task/task_page.dart @@ -23,7 +23,6 @@ class TaskPage extends StatefulWidget { } class _TaskPageState extends State { - String? _searchKey; final TextEditingController _searchController = TextEditingController(); @override @@ -102,9 +101,9 @@ class _TaskPageState extends State { TaskBean item = list[index]; if (_searchController.text.isEmpty || - (item.name?.contains(_searchController.text) ?? false) || - (item.command?.contains(_searchController.text) ?? false) || - (item.schedule?.contains(_searchController.text) ?? false)) { + (item.name?.toLowerCase().contains(_searchController.text.toLowerCase()) ?? false) || + (item.command?.toLowerCase().contains(_searchController.text.toLowerCase()) ?? false) || + (item.schedule?.contains(_searchController.text.toLowerCase()) ?? false)) { return TaskItemCell(item, ref); } else { return const SizedBox.shrink(); @@ -162,7 +161,7 @@ class TaskItemCell extends StatelessWidget { final TaskBean bean; final WidgetRef ref; - TaskItemCell(this.bean, this.ref, {Key? key}) : super(key: key); + const TaskItemCell(this.bean, this.ref, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/pubspec.yaml b/pubspec.yaml index ea190e9..280c82d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: flutter_highlight: ^0.7.0 drag_and_drop_lists: ^0.3.2+2 fluttertoast: ^8.0.8 + move_to_background: ^1.0.2 dev_dependencies: flutter_native_splash: ^1.3.3