优化Android返回键体验

This commit is contained in:
jyuesong
2022-01-19 15:54:06 +08:00
parent 346ebd68cf
commit 4fe730d414
4 changed files with 54 additions and 45 deletions

View File

@@ -4,6 +4,7 @@
* 增加环境变量详情页
* 环境变量列表使用体验优化
* 部分页面进入卡顿优化
* 扩大任务的搜索范围
## 1.0.0

View File

@@ -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<HomePage> {
));
}
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,
),
),
);
}

View File

@@ -23,7 +23,6 @@ class TaskPage extends StatefulWidget {
}
class _TaskPageState extends State<TaskPage> {
String? _searchKey;
final TextEditingController _searchController = TextEditingController();
@override
@@ -102,9 +101,9 @@ class _TaskPageState extends State<TaskPage> {
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) {

View File

@@ -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