From 1a055bdca740f7a5d52f30e8dc8470a6b778bf61 Mon Sep 17 00:00:00 2001 From: jyuesong <425698907@qq.com> Date: Wed, 26 Jan 2022 16:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A2=9E=E5=8A=A0=E6=9B=B4?= =?UTF-8?q?=E5=A4=9A=E7=9A=84=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/module/task/task_page.dart | 67 ++++++++++------------------- lib/module/task/task_viewmodel.dart | 6 +++ 2 files changed, 29 insertions(+), 44 deletions(-) diff --git a/lib/module/task/task_page.dart b/lib/module/task/task_page.dart index 3698cc4..8100d0b 100644 --- a/lib/module/task/task_page.dart +++ b/lib/module/task/task_page.dart @@ -41,7 +41,7 @@ class _TaskPageState extends State { searchCell(ref), Expanded( child: DefaultTabController( - length: 3, + length: 5, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -53,6 +53,12 @@ class _TaskPageState extends State { Tab( text: "正在运行", ), + Tab( + text: "从未运行", + ), + Tab( + text: "非脚本类", + ), Tab( text: "已禁用", ), @@ -70,6 +76,8 @@ class _TaskPageState extends State { children: [ body(model, model.list, ref), body(model, model.running, ref), + body(model, model.neverRunning, ref), + body(model, model.notScripts, ref), body(model, model.disabled, ref), ], ), @@ -102,17 +110,9 @@ class _TaskPageState extends State { TaskBean item = list[index]; if (_searchController.text.isEmpty || - (item.name - ?.toLowerCase() - .contains(_searchController.text.toLowerCase()) ?? - false) || - (item.command - ?.toLowerCase() - .contains(_searchController.text.toLowerCase()) ?? - false) || - (item.schedule - ?.contains(_searchController.text.toLowerCase()) ?? - 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(); @@ -183,9 +183,7 @@ class TaskItemCell extends StatelessWidget { child: Text( bean.status! == 1 ? "运行" : "停止运行", ), - trailingIcon: bean.status! == 1 - ? CupertinoIcons.memories - : CupertinoIcons.stop_circle, + trailingIcon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle, onPressed: () { Navigator.of(context).pop(); if (bean.status! == 1) { @@ -207,8 +205,7 @@ class TaskItemCell extends StatelessWidget { child: const Text("编辑"), onPressed: () { Navigator.of(context).pop(); - Navigator.of(context) - .pushNamed(Routes.routeAddTask, arguments: bean); + Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean); }, trailingIcon: CupertinoIcons.pencil_outline, ), @@ -218,9 +215,7 @@ class TaskItemCell extends StatelessWidget { Navigator.of(context).pop(); pinTask(); }, - trailingIcon: bean.isPinned! == 0 - ? CupertinoIcons.pin - : CupertinoIcons.pin_slash, + trailingIcon: bean.isPinned! == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash, ), QLCupertinoContextMenuAction( child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"), @@ -229,9 +224,7 @@ class TaskItemCell extends StatelessWidget { enableTask(); }, isDestructiveAction: true, - trailingIcon: bean.isDisabled! == 0 - ? Icons.dnd_forwardslash - : Icons.check_circle_outline_sharp, + trailingIcon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp, ), QLCupertinoContextMenuAction( child: const Text("删除"), @@ -248,9 +241,7 @@ class TaskItemCell extends StatelessWidget { return ClipRRect( borderRadius: BorderRadius.circular(15), child: Container( - color: isDark - ? const Color(0xff333333) - : Theme.of(context).scaffoldBackgroundColor, + color: isDark ? const Color(0xff333333) : Theme.of(context).scaffoldBackgroundColor, padding: EdgeInsets.only( left: 5, right: 5, @@ -273,9 +264,7 @@ class TaskItemCell extends StatelessWidget { children: [ Container( width: MediaQuery.of(context).size.width, - color: bean.isPinned == 1 - ? ref.watch(themeProvider).themeColor.pinColor() - : Colors.transparent, + color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent, padding: const EdgeInsets.symmetric( horizontal: 15, vertical: 8, @@ -300,8 +289,7 @@ class TaskItemCell extends StatelessWidget { height: 15, child: CircularProgressIndicator( strokeWidth: 2, - color: - ref.watch(themeProvider).primaryColor, + color: ref.watch(themeProvider).primaryColor, ), ), SizedBox( @@ -316,10 +304,7 @@ class TaskItemCell extends StatelessWidget { overflow: TextOverflow.ellipsis, style: TextStyle( overflow: TextOverflow.ellipsis, - color: ref - .watch(themeProvider) - .themeColor - .titleColor(), + color: ref.watch(themeProvider).themeColor.titleColor(), fontSize: 18, ), ), @@ -331,16 +316,11 @@ class TaskItemCell extends StatelessWidget { Material( color: Colors.transparent, child: Text( - (bean.lastExecutionTime == null || - bean.lastExecutionTime == 0) - ? "-" - : Utils.formatMessageTime( - bean.lastExecutionTime!), + (bean.lastExecutionTime == null || bean.lastExecutionTime == 0) ? "-" : Utils.formatMessageTime(bean.lastExecutionTime!), maxLines: 1, style: TextStyle( overflow: TextOverflow.ellipsis, - color: - ref.watch(themeProvider).themeColor.descColor(), + color: ref.watch(themeProvider).themeColor.descColor(), fontSize: 12, ), ), @@ -370,8 +350,7 @@ class TaskItemCell extends StatelessWidget { maxLines: 1, style: TextStyle( overflow: TextOverflow.ellipsis, - color: - ref.watch(themeProvider).themeColor.descColor(), + color: ref.watch(themeProvider).themeColor.descColor(), fontSize: 12, ), ), diff --git a/lib/module/task/task_viewmodel.dart b/lib/module/task/task_viewmodel.dart index 261e1c0..8a3e890 100644 --- a/lib/module/task/task_viewmodel.dart +++ b/lib/module/task/task_viewmodel.dart @@ -10,6 +10,8 @@ var taskProvider = ChangeNotifierProvider((ref) => TaskViewModel()); class TaskViewModel extends BaseViewModel { List list = []; List running = []; + List neverRunning = []; + List notScripts = []; List disabled = []; Future loadData([isLoading = true]) async { @@ -40,6 +42,10 @@ class TaskViewModel extends BaseViewModel { running.clear(); running.addAll(list.where((element) => element.status == 0)); + neverRunning.clear(); + neverRunning.addAll(list.where((element) => element.lastRunningTime == null || element.lastRunningTime == 0)); + notScripts.clear(); + notScripts.addAll(list.where((element) => (element.command != null && (element.command!.startsWith("ql repo") || element.command!.startsWith("ql raw"))))); disabled.clear(); disabled.addAll(list.where((element) => element.isDisabled == 1)); }