优化暗黑体验

This commit is contained in:
jyuesong
2022-01-19 16:38:02 +08:00
parent 4fe730d414
commit fe3e0f1d50
4 changed files with 147 additions and 130 deletions

View File

@@ -12,8 +12,9 @@ import '../task_viewmodel.dart';
class TaskDetailPage extends ConsumerStatefulWidget {
final TaskBean taskBean;
final bool hideAppbar;
const TaskDetailPage(this.taskBean, {Key? key}) : super(key: key);
const TaskDetailPage(this.taskBean, {Key? key, this.hideAppbar = false}) : super(key: key);
@override
_TaskDetailPageState createState() => _TaskDetailPageState();
@@ -29,6 +30,123 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
@override
Widget build(BuildContext context) {
Widget body = Material(
color: Colors.transparent,
child: Container(
color: Theme.of(context).scaffoldBackgroundColor,
child: SingleChildScrollView(
child: Column(
children: [
Container(
margin: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 15,
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
),
decoration: BoxDecoration(
color: ref.watch(themeProvider).themeColor.settingBgColor(),
borderRadius: BorderRadius.circular(15),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TaskDetailCell(
title: "名称",
desc: widget.taskBean.name ?? "",
),
TaskDetailCell(
title: "ID",
desc: widget.taskBean.sId ?? "",
),
TaskDetailCell(
title: "任务",
desc: widget.taskBean.command ?? "",
),
TaskDetailCell(
title: "创建时间",
desc: Utils.formatMessageTime(widget.taskBean.created ?? 0),
),
TaskDetailCell(
title: "更新时间",
desc: Utils.formatGMTTime(widget.taskBean.timestamp ?? ""),
),
TaskDetailCell(
title: "任务定时",
desc: widget.taskBean.schedule ?? "",
),
TaskDetailCell(
title: "最后运行时间",
desc: Utils.formatMessageTime(widget.taskBean.lastExecutionTime ?? 0),
),
TaskDetailCell(
title: "最后运行时长",
desc: widget.taskBean.lastRunningTime == null ? "-" : "${widget.taskBean.lastRunningTime ?? "-"}",
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
showLog();
},
child: TaskDetailCell(
title: "日志路径",
desc: widget.taskBean.logPath ?? "-",
taped: () {
showLog();
},
),
),
TaskDetailCell(
title: "运行状态",
desc: widget.taskBean.status == 0 ? "正在运行" : "空闲",
),
TaskDetailCell(
title: "脚本状态",
desc: widget.taskBean.isDisabled == 1 ? "已禁用" : "已启用",
),
TaskDetailCell(
title: "是否置顶",
desc: widget.taskBean.isPinned == 1 ? "已置顶" : "未置顶",
hideDivide: true,
),
],
),
),
widget.hideAppbar
? const SizedBox.shrink()
: SizedBox(
width: MediaQuery.of(context).size.width - 80,
child: CupertinoButton(
padding: const EdgeInsets.symmetric(
vertical: 5,
),
color: Colors.red,
child: const Text(
"删 除",
style: TextStyle(
fontSize: 16,
),
),
onPressed: () {
delTask(context, ref);
}),
),
const SizedBox(
height: 15,
),
],
),
),
),
);
if (widget.hideAppbar) {
return body;
}
actions.clear();
actions.addAll(
[
@@ -146,6 +264,7 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
),
],
);
return Scaffold(
appBar: QlAppBar(
canBack: true,
@@ -213,106 +332,7 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
)
],
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
margin: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 15,
),
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
),
decoration: BoxDecoration(
color: ref.watch(themeProvider).themeColor.settingBgColor(),
borderRadius: BorderRadius.circular(15),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TaskDetailCell(
title: "ID",
desc: widget.taskBean.sId ?? "",
),
TaskDetailCell(
title: "任务",
desc: widget.taskBean.command ?? "",
),
TaskDetailCell(
title: "创建时间",
desc: Utils.formatMessageTime(widget.taskBean.created ?? 0),
),
TaskDetailCell(
title: "更新时间",
desc: Utils.formatGMTTime(widget.taskBean.timestamp ?? ""),
),
TaskDetailCell(
title: "任务定时",
desc: widget.taskBean.schedule ?? "",
),
TaskDetailCell(
title: "最后运行时间",
desc: Utils.formatMessageTime(widget.taskBean.lastExecutionTime ?? 0),
),
TaskDetailCell(
title: "最后运行时长",
desc: widget.taskBean.lastRunningTime == null ? "-" : "${widget.taskBean.lastRunningTime ?? "-"}",
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
showLog();
},
child: TaskDetailCell(
title: "日志路径",
desc: widget.taskBean.logPath ?? "-",
taped: () {
showLog();
},
),
),
TaskDetailCell(
title: "运行状态",
desc: widget.taskBean.status == 0 ? "正在运行" : "空闲",
),
TaskDetailCell(
title: "脚本状态",
desc: widget.taskBean.isDisabled == 1 ? "已禁用" : "已启用",
),
TaskDetailCell(
title: "是否置顶",
desc: widget.taskBean.isPinned == 1 ? "已置顶" : "未置顶",
hideDivide: true,
),
],
),
),
SizedBox(
width: MediaQuery.of(context).size.width - 80,
child: CupertinoButton(
padding: const EdgeInsets.symmetric(
vertical: 5,
),
color: Colors.red,
child: const Text(
"删 除",
style: TextStyle(
fontSize: 16,
),
),
onPressed: () {
delTask(context, ref);
}),
),
const SizedBox(
height: 15,
),
],
),
),
body: body,
);
}

View File

@@ -12,6 +12,7 @@ import 'package:qinglong_app/base/ui/menu.dart';
import 'package:qinglong_app/base/ui/ql_context_menu.dart';
import 'package:qinglong_app/module/task/intime_log/intime_log_page.dart';
import 'package:qinglong_app/module/task/task_bean.dart';
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
import 'package:qinglong_app/module/task/task_viewmodel.dart';
import 'package:qinglong_app/utils/utils.dart';
@@ -224,33 +225,24 @@ class TaskItemCell extends StatelessWidget {
),
],
previewBuilder: (context, anima, child) {
return IntrinsicWidth(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Material(
color: Colors.transparent,
child: Text(
bean.name ?? "",
maxLines: 1,
style: TextStyle(
overflow: TextOverflow.ellipsis,
color: ref.watch(themeProvider).themeColor.titleColor(),
fontSize: 18,
),
),
bool isDark = ref.watch(themeProvider).darkMode;
return ClipRRect(
borderRadius: BorderRadius.circular(15),
child: Container(
color: isDark ? const Color(0xff333333) : Theme.of(context).scaffoldBackgroundColor,
padding: EdgeInsets.only(
left: 5,
right: 5,
top: 5,
bottom: isDark ? 5 : 20,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: TaskDetailPage(
bean,
hideAppbar: true,
),
const SizedBox(
width: 5,
),
bean.isDisabled == 1
? const Icon(
Icons.dnd_forwardslash,
size: 16,
color: Colors.red,
)
: const SizedBox.shrink(),
],
),
),
);
},