mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add theme
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
||||||
|
import 'package:qinglong_app/module/env/add_env_page.dart';
|
||||||
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
import 'package:qinglong_app/module/home/home_page.dart';
|
import 'package:qinglong_app/module/home/home_page.dart';
|
||||||
import 'package:qinglong_app/module/login/login_page.dart';
|
import 'package:qinglong_app/module/login/login_page.dart';
|
||||||
import 'package:qinglong_app/module/task/add_task_page.dart';
|
import 'package:qinglong_app/module/task/add_task_page.dart';
|
||||||
@@ -10,6 +12,7 @@ class Routes {
|
|||||||
static const String route_HomePage = "/home/homepage";
|
static const String route_HomePage = "/home/homepage";
|
||||||
static const String route_LOGIN = "/login";
|
static const String route_LOGIN = "/login";
|
||||||
static const String route_AddTask = "/task/add";
|
static const String route_AddTask = "/task/add";
|
||||||
|
static const String route_AddEnv = "/env/add";
|
||||||
static const String route_ConfigEdit = "/config/edit";
|
static const String route_ConfigEdit = "/config/edit";
|
||||||
|
|
||||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||||
@@ -27,6 +30,15 @@ class Routes {
|
|||||||
} else {
|
} else {
|
||||||
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
||||||
}
|
}
|
||||||
|
case route_AddEnv:
|
||||||
|
if (settings.arguments != null) {
|
||||||
|
return CupertinoPageRoute(
|
||||||
|
builder: (context) => AddEnvPage(
|
||||||
|
taskBean: settings.arguments as EnvBean,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
return CupertinoPageRoute(builder: (context) => const AddEnvPage());
|
||||||
|
}
|
||||||
case route_ConfigEdit:
|
case route_ConfigEdit:
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
builder: (context) => ConfigEditPage(
|
builder: (context) => ConfigEditPage(
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMi
|
|||||||
child: HighlightView(
|
child: HighlightView(
|
||||||
model.content[e.title] ?? "",
|
model.content[e.title] ?? "",
|
||||||
language: "sh",
|
language: "sh",
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||||
tabSize: 14,
|
tabSize: 14,
|
||||||
),
|
),
|
||||||
|
|||||||
199
lib/module/env/add_env_page.dart
vendored
Normal file
199
lib/module/env/add_env_page.dart
vendored
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:qinglong_app/base/common_dialog.dart';
|
||||||
|
import 'package:qinglong_app/base/http/api.dart';
|
||||||
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
|
import 'package:qinglong_app/module/env/env_viewmodel.dart';
|
||||||
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
|
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
||||||
|
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
||||||
|
|
||||||
|
class AddEnvPage extends ConsumerStatefulWidget {
|
||||||
|
final EnvBean? taskBean;
|
||||||
|
|
||||||
|
const AddEnvPage({Key? key, this.taskBean}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<AddEnvPage> createState() => _AddEnvPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AddEnvPageState extends ConsumerState<AddEnvPage> {
|
||||||
|
late EnvBean envBean;
|
||||||
|
|
||||||
|
final TextEditingController _nameController = TextEditingController();
|
||||||
|
final TextEditingController _valueController = TextEditingController();
|
||||||
|
final TextEditingController _remarkController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.taskBean != null) {
|
||||||
|
envBean = widget.taskBean!;
|
||||||
|
_nameController.text = envBean.name ?? "";
|
||||||
|
_valueController.text = envBean.value ?? "";
|
||||||
|
_remarkController.text = envBean.remarks ?? "";
|
||||||
|
} else {
|
||||||
|
envBean = EnvBean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: envBean.name == null ? "新增环境变量" : "编辑环境变量",
|
||||||
|
actions: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
submit();
|
||||||
|
},
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text("提交"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"名称:",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _nameController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||||
|
hintText: "请输入名称",
|
||||||
|
),
|
||||||
|
autofocus: false,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"值:",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _valueController,
|
||||||
|
maxLines: 8,
|
||||||
|
minLines: 1,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||||
|
hintText: "请输入值",
|
||||||
|
),
|
||||||
|
autofocus: false,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"备注:",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _remarkController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||||
|
hintText: "请输入备注",
|
||||||
|
),
|
||||||
|
autofocus: false,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void submit() async {
|
||||||
|
if (_nameController.text.isEmpty) {
|
||||||
|
failDialog(context, "名称不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_valueController.text.isEmpty) {
|
||||||
|
failDialog(context, "值不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
envBean.name = _nameController.text;
|
||||||
|
envBean.value = _valueController.text;
|
||||||
|
envBean.remarks = _remarkController.text;
|
||||||
|
HttpResponse<EnvBean> response = await Api.addEnv(_nameController.text, _valueController.text, _remarkController.text, id: envBean.sId);
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
successDialog(context, "操作成功").then((value) {
|
||||||
|
ref.read(envProvider).updateEnv(envBean);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
failDialog(context, response.message ?? "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
206
lib/module/env/env_page.dart
vendored
206
lib/module/env/env_page.dart
vendored
@@ -5,6 +5,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
import 'package:qinglong_app/base/base_state_widget.dart';
|
import 'package:qinglong_app/base/base_state_widget.dart';
|
||||||
import 'package:qinglong_app/base/common_dialog.dart';
|
import 'package:qinglong_app/base/common_dialog.dart';
|
||||||
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
import 'package:qinglong_app/base/ui/empty_widget.dart';
|
import 'package:qinglong_app/base/ui/empty_widget.dart';
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
@@ -31,7 +32,11 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
(value.name?.contains(_searchController.text) ?? false) ||
|
(value.name?.contains(_searchController.text) ?? false) ||
|
||||||
(value.value?.contains(_searchController.text) ?? false) ||
|
(value.value?.contains(_searchController.text) ?? false) ||
|
||||||
(value.remarks?.contains(_searchController.text) ?? false)) {
|
(value.remarks?.contains(_searchController.text) ?? false)) {
|
||||||
list.add(EnvItemCell(value, ref,key: ValueKey(value.sId),));
|
list.add(EnvItemCell(
|
||||||
|
value,
|
||||||
|
ref,
|
||||||
|
key: ValueKey(value.sId),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,112 +131,117 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Slidable(
|
return ColoredBox(
|
||||||
key: ValueKey(bean.sId),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
endActionPane: ActionPane(
|
child: Slidable(
|
||||||
motion: const ScrollMotion(),
|
key: ValueKey(bean.sId),
|
||||||
extentRatio: 0.45,
|
endActionPane: ActionPane(
|
||||||
children: [
|
motion: const ScrollMotion(),
|
||||||
SlidableAction(
|
extentRatio: 0.45,
|
||||||
backgroundColor: Colors.grey,
|
|
||||||
flex: 1,
|
|
||||||
onPressed: (_) {},
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
icon: CupertinoIcons.pencil_outline,
|
|
||||||
),
|
|
||||||
SlidableAction(
|
|
||||||
backgroundColor: Colors.orange,
|
|
||||||
flex: 1,
|
|
||||||
onPressed: (_) {
|
|
||||||
enableEnv();
|
|
||||||
},
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
|
||||||
),
|
|
||||||
SlidableAction(
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
flex: 1,
|
|
||||||
onPressed: (_) {
|
|
||||||
delEnv(context, ref);
|
|
||||||
},
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
icon: CupertinoIcons.delete,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
SlidableAction(
|
||||||
padding: const EdgeInsets.symmetric(
|
backgroundColor: Colors.grey,
|
||||||
horizontal: 15,
|
flex: 1,
|
||||||
vertical: 8,
|
onPressed: (_) {
|
||||||
),
|
Navigator.of(context).pushNamed(Routes.route_AddEnv, arguments: bean);
|
||||||
child: Column(
|
},
|
||||||
mainAxisSize: MainAxisSize.min,
|
foregroundColor: Colors.white,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
icon: CupertinoIcons.pencil,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
children: [
|
SlidableAction(
|
||||||
Row(
|
backgroundColor: Colors.orange,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
flex: 1,
|
||||||
children: [
|
onPressed: (_) {
|
||||||
Expanded(
|
enableEnv();
|
||||||
child: Material(
|
},
|
||||||
color: Colors.transparent,
|
foregroundColor: Colors.white,
|
||||||
child: Text(
|
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
bean.name ?? "",
|
),
|
||||||
maxLines: 1,
|
SlidableAction(
|
||||||
style: TextStyle(
|
backgroundColor: Colors.red,
|
||||||
overflow: TextOverflow.ellipsis,
|
flex: 1,
|
||||||
color: bean.status == 1 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
onPressed: (_) {
|
||||||
fontSize: 18,
|
delEnv(context, ref);
|
||||||
|
},
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
icon: CupertinoIcons.delete,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
bean.name ?? "",
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: bean.status == 1 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
width: 5,
|
||||||
width: 5,
|
),
|
||||||
),
|
Material(
|
||||||
Material(
|
color: Colors.transparent,
|
||||||
color: Colors.transparent,
|
child: Text(
|
||||||
child: Text(
|
bean.remarks ?? "-",
|
||||||
bean.remarks ?? "-",
|
maxLines: 1,
|
||||||
maxLines: 1,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
fontSize: 12,
|
||||||
fontSize: 12,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(
|
||||||
const SizedBox(
|
height: 8,
|
||||||
height: 8,
|
),
|
||||||
),
|
Material(
|
||||||
Material(
|
color: Colors.transparent,
|
||||||
color: Colors.transparent,
|
child: Text(
|
||||||
child: Text(
|
bean.value ?? "",
|
||||||
bean.value ?? "",
|
maxLines: 1,
|
||||||
maxLines: 1,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
fontSize: 12,
|
||||||
fontSize: 12,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
const Divider(
|
||||||
const Divider(
|
height: 1,
|
||||||
height: 1,
|
indent: 15,
|
||||||
indent: 15,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
|
||||||
import 'package:qinglong_app/module/config/config_page.dart';
|
import 'package:qinglong_app/module/config/config_page.dart';
|
||||||
import 'package:qinglong_app/module/env/env_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/others/other_page.dart';
|
||||||
@@ -54,6 +53,25 @@ class _HomePageState extends ConsumerState<HomePage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
} else if (_index == 1) {
|
||||||
|
actions.add(InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
Routes.route_AddEnv,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.add,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
} else if (_index == 2) {
|
} else if (_index == 2) {
|
||||||
actions.add(InkWell(
|
actions.add(InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ class _TaskPageState extends State<TaskPage> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
TaskBean item = list[index];
|
TaskBean item = list[index];
|
||||||
|
|
||||||
if ((item.name == null || item.name!.contains(_searchKey ?? "")) || (item.command == null || item.command!.contains(_searchKey ?? ""))) {
|
if (_searchController.text.isEmpty ||
|
||||||
|
(item.name?.contains(_searchController.text) ?? false) ||
|
||||||
|
(item.command?.contains(_searchController.text) ?? false) ||
|
||||||
|
(item.schedule?.contains(_searchController.text) ?? false)) {
|
||||||
return TaskItemCell(item, ref);
|
return TaskItemCell(item, ref);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@@ -163,157 +166,160 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CupertinoContextMenu(
|
return ColoredBox(
|
||||||
actions: [
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
QLCupertinoContextMenuAction(
|
child: CupertinoContextMenu(
|
||||||
child: Text(
|
actions: [
|
||||||
bean.status! == 1 ? "运行" : "停止运行",
|
QLCupertinoContextMenuAction(
|
||||||
),
|
|
||||||
trailingIcon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
startCron(context, ref);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
QLCupertinoContextMenuAction(
|
|
||||||
child: const Text("查看日志"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
logCron(context, ref);
|
|
||||||
},
|
|
||||||
trailingIcon: CupertinoIcons.clock,
|
|
||||||
),
|
|
||||||
QLCupertinoContextMenuAction(
|
|
||||||
child: const Text("编辑"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Navigator.of(context).pushNamed(Routes.route_AddTask, arguments: bean);
|
|
||||||
},
|
|
||||||
trailingIcon: CupertinoIcons.pencil_outline,
|
|
||||||
),
|
|
||||||
QLCupertinoContextMenuAction(
|
|
||||||
child: Text(bean.isPinned! == 0 ? "置顶" : "取消置顶"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
pinTask();
|
|
||||||
},
|
|
||||||
trailingIcon: bean.isPinned! == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
|
||||||
),
|
|
||||||
QLCupertinoContextMenuAction(
|
|
||||||
child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
enableTask();
|
|
||||||
},
|
|
||||||
isDestructiveAction: true,
|
|
||||||
trailingIcon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
|
||||||
),
|
|
||||||
QLCupertinoContextMenuAction(
|
|
||||||
child: const Text("删除"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
delTask(context, ref);
|
|
||||||
},
|
|
||||||
isDestructiveAction: true,
|
|
||||||
trailingIcon: CupertinoIcons.delete,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
previewBuilder: (context, anima, child) {
|
|
||||||
return IntrinsicWidth(
|
|
||||||
child: Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
child: Text(
|
||||||
bean.name ?? "",
|
bean.status! == 1 ? "运行" : "停止运行",
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: bean.isDisabled == 1 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
|
||||||
fontSize: 18,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
trailingIcon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
startCron(context, ref);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
QLCupertinoContextMenuAction(
|
||||||
},
|
child: const Text("查看日志"),
|
||||||
child: Column(
|
onPressed: () {
|
||||||
mainAxisSize: MainAxisSize.min,
|
Navigator.of(context).pop();
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
logCron(context, ref);
|
||||||
children: [
|
},
|
||||||
Container(
|
trailingIcon: CupertinoIcons.clock,
|
||||||
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 15,
|
|
||||||
vertical: 8,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
|
||||||
bean.name ?? "",
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: bean.isDisabled == 1 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
|
||||||
fontSize: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
bean.status == 1
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: const SizedBox(
|
|
||||||
width: 15,
|
|
||||||
height: 15,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
|
||||||
(bean.lastExecutionTime == null || bean.lastExecutionTime == 0) ? "-" : Utils.formatMessageTime(bean.lastExecutionTime!),
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
|
||||||
bean.schedule ?? "",
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const Divider(
|
QLCupertinoContextMenuAction(
|
||||||
height: 1,
|
child: const Text("编辑"),
|
||||||
indent: 15,
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pushNamed(Routes.route_AddTask, arguments: bean);
|
||||||
|
},
|
||||||
|
trailingIcon: CupertinoIcons.pencil_outline,
|
||||||
|
),
|
||||||
|
QLCupertinoContextMenuAction(
|
||||||
|
child: Text(bean.isPinned! == 0 ? "置顶" : "取消置顶"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
pinTask();
|
||||||
|
},
|
||||||
|
trailingIcon: bean.isPinned! == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
||||||
|
),
|
||||||
|
QLCupertinoContextMenuAction(
|
||||||
|
child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
enableTask();
|
||||||
|
},
|
||||||
|
isDestructiveAction: true,
|
||||||
|
trailingIcon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
|
),
|
||||||
|
QLCupertinoContextMenuAction(
|
||||||
|
child: const Text("删除"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
delTask(context, ref);
|
||||||
|
},
|
||||||
|
isDestructiveAction: true,
|
||||||
|
trailingIcon: CupertinoIcons.delete,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
previewBuilder: (context, anima, child) {
|
||||||
|
return IntrinsicWidth(
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
bean.name ?? "",
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: bean.isDisabled == 1 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
bean.name ?? "",
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: bean.isDisabled == 1 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
bean.status == 1
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
height: 15,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
(bean.lastExecutionTime == null || bean.lastExecutionTime == 0) ? "-" : Utils.formatMessageTime(bean.lastExecutionTime!),
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
bean.schedule ?? "",
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
height: 1,
|
||||||
|
indent: 15,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -380,7 +386,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
content: InTimeLogPage(bean.sId!, bean.status == 0),
|
content: InTimeLogPage(bean.sId!, bean.status == 0),
|
||||||
actions: [
|
actions: [
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: Text(
|
child: Text(
|
||||||
"知道了",
|
"知道了",
|
||||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user