diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fce4d8..2edfe89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * 环境变量列表使用体验优化 * 部分页面进入卡顿优化 * 扩大任务的搜索范围 +* 优化暗黑主题 ## 1.0.0 diff --git a/lib/base/theme.dart b/lib/base/theme.dart index c3f58bc..6736283 100644 --- a/lib/base/theme.dart +++ b/lib/base/theme.dart @@ -13,13 +13,14 @@ get primaryColor => _primaryColor; class ThemeViewModel extends ChangeNotifier { ThemeData currentTheme = lightTheme; + bool _isInDarkMode = false; ThemeColors themeColor = LightThemeColors(); ThemeViewModel() { var brightness = SchedulerBinding.instance!.window.platformBrightness; - bool isDarkMode = brightness == Brightness.dark; - changeThemeReal(isDarkMode, false); + _isInDarkMode = brightness == Brightness.dark; + changeThemeReal(_isInDarkMode, false); } bool isInDartMode() { @@ -27,6 +28,7 @@ class ThemeViewModel extends ChangeNotifier { } void changeThemeReal(bool dark, [bool notify = true]) { + _isInDarkMode = dark; SpUtil.putBool(spTheme, dark); if (!dark) { currentTheme = lightTheme; @@ -40,6 +42,8 @@ class ThemeViewModel extends ChangeNotifier { } } + get darkMode => _isInDarkMode; + void changeTheme() { changeThemeReal(!SpUtil.getBool(spTheme, defValue: false), true); } @@ -243,7 +247,7 @@ class DartThemeColors extends ThemeColors { @override Color settingBgColor() { - return Colors.black12; + return Colors.black; } @override diff --git a/lib/module/task/task_detail/task_detail_page.dart b/lib/module/task/task_detail/task_detail_page.dart index d1bf77f..dffda53 100644 --- a/lib/module/task/task_detail/task_detail_page.dart +++ b/lib/module/task/task_detail/task_detail_page.dart @@ -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 { @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 { ), ], ); + return Scaffold( appBar: QlAppBar( canBack: true, @@ -213,106 +332,7 @@ class _TaskDetailPageState extends ConsumerState { ) ], ), - 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, ); } diff --git a/lib/module/task/task_page.dart b/lib/module/task/task_page.dart index b1ffc93..e878295 100644 --- a/lib/module/task/task_page.dart +++ b/lib/module/task/task_page.dart @@ -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(), - ], + ), ), ); },