支持上传脚本
BIN
assets/images/add_btn_svip.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/images/icon_add_file.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/images/js.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/json.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/other.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/py.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/images/shell.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/ts.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
@@ -24,7 +24,9 @@ class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
|||||||
_BaseStateWidgetState<T> createState() => _BaseStateWidgetState<T>();
|
_BaseStateWidgetState<T> createState() => _BaseStateWidgetState<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseStateWidget<T>> with LazyLoadState<BaseStateWidget<T>> {
|
class _BaseStateWidgetState<T extends BaseViewModel>
|
||||||
|
extends ConsumerState<BaseStateWidget<T>>
|
||||||
|
with LazyLoadState<BaseStateWidget<T>> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var viewModel = ref.watch<T>(widget.model);
|
var viewModel = ref.watch<T>(widget.model);
|
||||||
|
|||||||
@@ -89,21 +89,24 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> startTasks(List<String> crons) async {
|
static Future<HttpResponse<NullResponse>> startTasks(
|
||||||
|
List<String> crons) async {
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.runTasks,
|
Url.runTasks,
|
||||||
crons,
|
crons,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
static Future<HttpResponse<NullResponse>> stopTasks(
|
||||||
|
List<String> crons) async {
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.stopTasks,
|
Url.stopTasks,
|
||||||
crons,
|
crons,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> updatePassword(String name, String password) async {
|
static Future<HttpResponse<NullResponse>> updatePassword(
|
||||||
|
String name, String password) async {
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.updatePassword,
|
Url.updatePassword,
|
||||||
{
|
{
|
||||||
@@ -127,7 +130,11 @@ class Api {
|
|||||||
int? id,
|
int? id,
|
||||||
String? nId,
|
String? nId,
|
||||||
}) async {
|
}) async {
|
||||||
var data = <String, dynamic>{"name": name, "command": command, "schedule": cron};
|
var data = <String, dynamic>{
|
||||||
|
"name": name,
|
||||||
|
"command": command,
|
||||||
|
"schedule": cron
|
||||||
|
};
|
||||||
|
|
||||||
if (id != null || nId != null) {
|
if (id != null || nId != null) {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@@ -195,7 +202,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> saveFile(String name, String content) async {
|
static Future<HttpResponse<NullResponse>> saveFile(
|
||||||
|
String name, String content) async {
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.saveFile,
|
Url.saveFile,
|
||||||
{"content": content, "name": name},
|
{"content": content, "name": name},
|
||||||
@@ -260,7 +268,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> moveEnv(String id, int fromIndex, int toIndex) async {
|
static Future<HttpResponse<NullResponse>> moveEnv(
|
||||||
|
String id, int fromIndex, int toIndex) async {
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.envMove(id),
|
Url.envMove(id),
|
||||||
{"fromIndex": fromIndex, "toIndex": toIndex},
|
{"fromIndex": fromIndex, "toIndex": toIndex},
|
||||||
@@ -275,10 +284,12 @@ class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
|
||||||
return await Http.get<List<TaskLogBean>>(Url.taskLog, null, serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs");
|
return await Http.get<List<TaskLogBean>>(Url.taskLog, null,
|
||||||
|
serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs");
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> taskLogDetail(String name, String path) async {
|
static Future<HttpResponse<String>> taskLogDetail(
|
||||||
|
String name, String path) async {
|
||||||
if (Utils.isUpperVersion2_13_0()) {
|
if (Utils.isUpperVersion2_13_0()) {
|
||||||
return await Http.get<String>(
|
return await Http.get<String>(
|
||||||
Url.taskLogDetail + name + "?path=" + path,
|
Url.taskLogDetail + name + "?path=" + path,
|
||||||
@@ -300,7 +311,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> updateScript(String name, String path, String content) async {
|
static Future<HttpResponse<NullResponse>> updateScript(
|
||||||
|
String name, String path, String content) async {
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.scriptDetail,
|
Url.scriptDetail,
|
||||||
{
|
{
|
||||||
@@ -311,7 +323,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> delScript(String name, String path) async {
|
static Future<HttpResponse<NullResponse>> delScript(
|
||||||
|
String name, String path) async {
|
||||||
return await Http.delete<NullResponse>(
|
return await Http.delete<NullResponse>(
|
||||||
Url.scriptDetail,
|
Url.scriptDetail,
|
||||||
{
|
{
|
||||||
@@ -321,7 +334,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<String>> scriptDetail(String name, String? path) async {
|
static Future<HttpResponse<String>> scriptDetail(
|
||||||
|
String name, String? path) async {
|
||||||
return await Http.get<String>(
|
return await Http.get<String>(
|
||||||
Url.scriptDetail + name,
|
Url.scriptDetail + name,
|
||||||
{
|
{
|
||||||
@@ -330,7 +344,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<List<DependencyBean>>> dependencies(String type) async {
|
static Future<HttpResponse<List<DependencyBean>>> dependencies(
|
||||||
|
String type) async {
|
||||||
return await Http.get<List<DependencyBean>>(
|
return await Http.get<List<DependencyBean>>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
{
|
{
|
||||||
@@ -339,7 +354,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> dependencyReinstall(String id) async {
|
static Future<HttpResponse<NullResponse>> dependencyReinstall(
|
||||||
|
String id) async {
|
||||||
return await Http.put<NullResponse>(
|
return await Http.put<NullResponse>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
[id],
|
[id],
|
||||||
@@ -353,7 +369,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addDependency(String name, int type) async {
|
static Future<HttpResponse<NullResponse>> addDependency(
|
||||||
|
String name, int type) async {
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.dependencies,
|
Url.dependencies,
|
||||||
[
|
[
|
||||||
@@ -365,7 +382,8 @@ class Api {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<HttpResponse<NullResponse>> addScript(String name, String path, String content) async {
|
static Future<HttpResponse<NullResponse>> addScript(
|
||||||
|
String name, String path, String content) async {
|
||||||
return await Http.post<NullResponse>(
|
return await Http.post<NullResponse>(
|
||||||
Url.addScript,
|
Url.addScript,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ class Http {
|
|||||||
if (!pushedLoginPage) {
|
if (!pushedLoginPage) {
|
||||||
"身份已过期,请重新登录".toast();
|
"身份已过期,请重新登录".toast();
|
||||||
pushedLoginPage = true;
|
pushedLoginPage = true;
|
||||||
navigatorState.currentState?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
|
navigatorState.currentState
|
||||||
|
?.pushNamedAndRemoveUntil(Routes.routeLogin, (route) => false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +137,15 @@ class Http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.response != null && e.response!.data != null) {
|
if (e.response != null && e.response!.data != null) {
|
||||||
return HttpResponse(success: false, message: e.response?.data["message"] ?? e.message, code: e.response?.data["code"] ?? 0);
|
return HttpResponse(
|
||||||
|
success: false,
|
||||||
|
message: e.response?.data["message"] ?? e.message,
|
||||||
|
code: e.response?.data["code"] ?? 0);
|
||||||
} else {
|
} else {
|
||||||
return HttpResponse(success: false, message: e.message, code: e.response?.statusCode ?? 0);
|
return HttpResponse(
|
||||||
|
success: false,
|
||||||
|
message: e.message,
|
||||||
|
code: e.response?.statusCode ?? 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +230,8 @@ class HttpResponse<T> {
|
|||||||
late int code;
|
late int code;
|
||||||
T? bean;
|
T? bean;
|
||||||
|
|
||||||
HttpResponse({required this.success, this.message, required this.code, this.bean});
|
HttpResponse(
|
||||||
|
{required this.success, this.message, required this.code, this.bean});
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeserializeAction<T> {
|
class DeserializeAction<T> {
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import '../userinfo_viewmodel.dart';
|
|||||||
class TokenInterceptor extends Interceptor {
|
class TokenInterceptor extends Interceptor {
|
||||||
@override
|
@override
|
||||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||||
options.headers["User-Agent"] =
|
options.headers["User-Agent"] = "qinglong_client";
|
||||||
"qinglong_client";
|
|
||||||
|
|
||||||
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
||||||
|
|
||||||
|
|||||||
@@ -14,70 +14,127 @@ class Url {
|
|||||||
|
|
||||||
static const updatePassword = "/api/user";
|
static const updatePassword = "/api/user";
|
||||||
|
|
||||||
static get tasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons" : "/api/crons";
|
static get tasks => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons"
|
||||||
|
: "/api/crons";
|
||||||
|
|
||||||
static get runTasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/run" : "/api/crons/run";
|
static get runTasks => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/run"
|
||||||
|
: "/api/crons/run";
|
||||||
|
|
||||||
static get stopTasks => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/stop" : "/api/crons/stop";
|
static get stopTasks => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/stop"
|
||||||
|
: "/api/crons/stop";
|
||||||
|
|
||||||
static get taskDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/" : "/api/crons/";
|
static get taskDetail => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/"
|
||||||
|
: "/api/crons/";
|
||||||
|
|
||||||
static get addTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons" : "/api/crons";
|
static get addTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons"
|
||||||
|
: "/api/crons";
|
||||||
|
|
||||||
static get pinTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/pin" : "/api/crons/pin";
|
static get pinTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/pin"
|
||||||
|
: "/api/crons/pin";
|
||||||
|
|
||||||
static get unpinTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/unpin" : "/api/crons/unpin";
|
static get unpinTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/unpin"
|
||||||
|
: "/api/crons/unpin";
|
||||||
|
|
||||||
static get enableTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/enable" : "/api/crons/enable";
|
static get enableTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/enable"
|
||||||
|
: "/api/crons/enable";
|
||||||
|
|
||||||
static get disableTask => getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/disable" : "/api/crons/disable";
|
static get disableTask => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/disable"
|
||||||
|
: "/api/crons/disable";
|
||||||
|
|
||||||
static get files => getIt<UserInfoViewModel>().useSecretLogined ? "/open/configs/files" : "/api/configs/files";
|
static get files => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/configs/files"
|
||||||
|
: "/api/configs/files";
|
||||||
|
|
||||||
static get configContent => getIt<UserInfoViewModel>().useSecretLogined ? "/open/configs/" : "/api/configs/";
|
static get configContent => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/configs/"
|
||||||
|
: "/api/configs/";
|
||||||
|
|
||||||
static get saveFile => getIt<UserInfoViewModel>().useSecretLogined ? "/open/configs/save" : "/api/configs/save";
|
static get saveFile => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/configs/save"
|
||||||
|
: "/api/configs/save";
|
||||||
|
|
||||||
static get envs => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
static get envs =>
|
||||||
|
getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||||
|
|
||||||
static get addEnv => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
static get addEnv =>
|
||||||
|
getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||||
|
|
||||||
static get delEnv => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
static get delEnv =>
|
||||||
|
getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs" : "/api/envs";
|
||||||
|
|
||||||
static get disableEnvs => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs/disable" : "/api/envs/disable";
|
static get disableEnvs => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/envs/disable"
|
||||||
|
: "/api/envs/disable";
|
||||||
|
|
||||||
static get enableEnvs => getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs/enable" : "/api/envs/enable";
|
static get enableEnvs => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/envs/enable"
|
||||||
|
: "/api/envs/enable";
|
||||||
|
|
||||||
static get loginLog => getIt<UserInfoViewModel>().useSecretLogined ? "/open/user/login-log" : "/api/user/login-log";
|
static get loginLog => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/user/login-log"
|
||||||
|
: "/api/user/login-log";
|
||||||
|
|
||||||
static get taskLog => getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs" : "/api/logs";
|
static get taskLog =>
|
||||||
|
getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs" : "/api/logs";
|
||||||
|
|
||||||
static get taskLogDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/logs/" : "/api/logs/";
|
static get taskLogDetail => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/logs/"
|
||||||
|
: "/api/logs/";
|
||||||
|
|
||||||
static get scripts => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts/files" : "/api/scripts/files";
|
static get scripts => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts/files"
|
||||||
|
: "/api/scripts/files";
|
||||||
|
|
||||||
static get scripts2 => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
|
static get scripts2 => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts"
|
||||||
|
: "/api/scripts";
|
||||||
|
|
||||||
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
|
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts"
|
||||||
|
: "/api/scripts";
|
||||||
|
|
||||||
static get scriptDetail => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts/" : "/api/scripts/";
|
static get scriptDetail => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts/"
|
||||||
|
: "/api/scripts/";
|
||||||
|
|
||||||
static get dependencies => getIt<UserInfoViewModel>().useSecretLogined ? "/open/dependencies" : "/api/dependencies";
|
static get dependencies => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/dependencies"
|
||||||
|
: "/api/dependencies";
|
||||||
|
|
||||||
static get addScript => getIt<UserInfoViewModel>().useSecretLogined ? "/open/scripts" : "/api/scripts";
|
static get addScript => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/scripts"
|
||||||
|
: "/api/scripts";
|
||||||
|
|
||||||
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined ? "/open/dependencies/reinstall" : "/api/dependencies/reinstall";
|
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/dependencies/reinstall"
|
||||||
|
: "/api/dependencies/reinstall";
|
||||||
|
|
||||||
static intimeLog(String cronId) {
|
static intimeLog(String cronId) {
|
||||||
return getIt<UserInfoViewModel>().useSecretLogined ? "/open/crons/$cronId/log" : "/api/crons/$cronId/log";
|
return getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/crons/$cronId/log"
|
||||||
|
: "/api/crons/$cronId/log";
|
||||||
}
|
}
|
||||||
|
|
||||||
static envMove(String envId) {
|
static envMove(String envId) {
|
||||||
return getIt<UserInfoViewModel>().useSecretLogined ? "/open/envs/$envId/move" : "/api/envs/$envId/move";
|
return getIt<UserInfoViewModel>().useSecretLogined
|
||||||
|
? "/open/envs/$envId/move"
|
||||||
|
: "/api/envs/$envId/move";
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool inWhiteList(String path) {
|
static bool inWhiteList(String path) {
|
||||||
if (path == login || path == loginByClientId || path == loginTwo || path == loginOld) {
|
if (path == login ||
|
||||||
|
path == loginByClientId ||
|
||||||
|
path == loginTwo ||
|
||||||
|
path == loginOld) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ class Routes {
|
|||||||
return MaterialPageRoute(builder: (context) => const AddTaskPage());
|
return MaterialPageRoute(builder: (context) => const AddTaskPage());
|
||||||
}
|
}
|
||||||
case routeAddDependency:
|
case routeAddDependency:
|
||||||
return MaterialPageRoute(builder: (context) => const AddDependencyPage());
|
return MaterialPageRoute(
|
||||||
|
builder: (context) => const AddDependencyPage());
|
||||||
case routeAddEnv:
|
case routeAddEnv:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:flutter/gestures.dart' show kMinFlingVelocity, kLongPressTimeout;
|
import 'package:flutter/gestures.dart'
|
||||||
|
show kMinFlingVelocity, kLongPressTimeout;
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@@ -42,7 +43,8 @@ typedef _ContextMenuPreviewBuilderChildless = Widget Function(
|
|||||||
// paintBounds in global coordinates.
|
// paintBounds in global coordinates.
|
||||||
Rect _getRect(GlobalKey globalKey) {
|
Rect _getRect(GlobalKey globalKey) {
|
||||||
assert(globalKey.currentContext != null);
|
assert(globalKey.currentContext != null);
|
||||||
final RenderBox renderBoxContainer = globalKey.currentContext!.findRenderObject()! as RenderBox;
|
final RenderBox renderBoxContainer =
|
||||||
|
globalKey.currentContext!.findRenderObject()! as RenderBox;
|
||||||
final Offset containerOffset = renderBoxContainer.localToGlobal(
|
final Offset containerOffset = renderBoxContainer.localToGlobal(
|
||||||
renderBoxContainer.paintBounds.topLeft,
|
renderBoxContainer.paintBounds.topLeft,
|
||||||
);
|
);
|
||||||
@@ -194,7 +196,8 @@ class QlCupertinoContextMenu extends StatefulWidget {
|
|||||||
State<QlCupertinoContextMenu> createState() => _QlCupertinoContextMenuState();
|
State<QlCupertinoContextMenu> createState() => _QlCupertinoContextMenuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with TickerProviderStateMixin {
|
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
final GlobalKey _childGlobalKey = GlobalKey();
|
final GlobalKey _childGlobalKey = GlobalKey();
|
||||||
bool _childHidden = false;
|
bool _childHidden = false;
|
||||||
|
|
||||||
@@ -227,7 +230,8 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
|||||||
final double screenWidth = MediaQuery.of(context).size.width;
|
final double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
final double center = screenWidth / 2;
|
final double center = screenWidth / 2;
|
||||||
final bool centerDividesChild = childRect.left < center && childRect.right > center;
|
final bool centerDividesChild =
|
||||||
|
childRect.left < center && childRect.right > center;
|
||||||
final double distanceFromCenter = (center - childRect.center.dx).abs();
|
final double distanceFromCenter = (center - childRect.center.dx).abs();
|
||||||
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
|
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
|
||||||
return _ContextMenuLocation.center;
|
return _ContextMenuLocation.center;
|
||||||
@@ -318,7 +322,8 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
|||||||
_openController.reverse();
|
_openController.reverse();
|
||||||
} else {
|
} else {
|
||||||
if (_openController.isDismissed) {
|
if (_openController.isDismissed) {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,7 +424,8 @@ class _DecoyChild extends StatefulWidget {
|
|||||||
_DecoyChildState createState() => _DecoyChildState();
|
_DecoyChildState createState() => _DecoyChildState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin {
|
class _DecoyChildState extends State<_DecoyChild>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
// TODO(justinmc): Dark mode support.
|
// TODO(justinmc): Dark mode support.
|
||||||
// See https://github.com/flutter/flutter/issues/43211.
|
// See https://github.com/flutter/flutter/issues/43211.
|
||||||
static const Color _lightModeMaskColor = Color(0xFF888888);
|
static const Color _lightModeMaskColor = Color(0xFF888888);
|
||||||
@@ -481,7 +487,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAnimation(BuildContext context, Widget? child) {
|
Widget _buildAnimation(BuildContext context, Widget? child) {
|
||||||
final Color color = widget.controller.status == AnimationStatus.reverse ? _masklessColor : _mask.value;
|
final Color color = widget.controller.status == AnimationStatus.reverse
|
||||||
|
? _masklessColor
|
||||||
|
: _mask.value;
|
||||||
return Positioned.fromRect(
|
return Positioned.fromRect(
|
||||||
rect: _rect.value!,
|
rect: _rect.value!,
|
||||||
child: ShaderMask(
|
child: ShaderMask(
|
||||||
@@ -538,7 +546,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
|
|
||||||
// The duration of the transition used when a modal popup is shown. Eyeballed
|
// The duration of the transition used when a modal popup is shown. Eyeballed
|
||||||
// from a physical device running iOS 13.1.2.
|
// from a physical device running iOS 13.1.2.
|
||||||
static const Duration _kModalPopupTransitionDuration = Duration(milliseconds: 335);
|
static const Duration _kModalPopupTransitionDuration =
|
||||||
|
Duration(milliseconds: 335);
|
||||||
|
|
||||||
final List<Widget> _actions;
|
final List<Widget> _actions;
|
||||||
final _ContextMenuPreviewBuilderChildless? _builder;
|
final _ContextMenuPreviewBuilderChildless? _builder;
|
||||||
@@ -562,7 +571,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
static final RectTween _rectTween = RectTween();
|
static final RectTween _rectTween = RectTween();
|
||||||
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
|
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
|
||||||
static final RectTween _rectTweenReverse = RectTween();
|
static final RectTween _rectTweenReverse = RectTween();
|
||||||
static final Animatable<Rect?> _rectAnimatableReverse = _rectTweenReverse.chain(
|
static final Animatable<Rect?> _rectAnimatableReverse =
|
||||||
|
_rectTweenReverse.chain(
|
||||||
_curveReverse,
|
_curveReverse,
|
||||||
);
|
);
|
||||||
static final RectTween _sheetRectTween = RectTween();
|
static final RectTween _sheetRectTween = RectTween();
|
||||||
@@ -573,10 +583,12 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
_curveReverse,
|
_curveReverse,
|
||||||
);
|
);
|
||||||
static final Tween<double> _sheetScaleTween = Tween<double>();
|
static final Tween<double> _sheetScaleTween = Tween<double>();
|
||||||
static final Animatable<double> _sheetScaleAnimatable = _sheetScaleTween.chain(
|
static final Animatable<double> _sheetScaleAnimatable =
|
||||||
|
_sheetScaleTween.chain(
|
||||||
_curve,
|
_curve,
|
||||||
);
|
);
|
||||||
static final Animatable<double> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(
|
static final Animatable<double> _sheetScaleAnimatableReverse =
|
||||||
|
_sheetScaleTween.chain(
|
||||||
_curveReverse,
|
_curveReverse,
|
||||||
);
|
);
|
||||||
final Tween<double> _opacityTween = Tween<double>(begin: 0.0, end: 1.0);
|
final Tween<double> _opacityTween = Tween<double>(begin: 0.0, end: 1.0);
|
||||||
@@ -611,7 +623,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
|
|
||||||
// Get the alignment for the _ContextMenuSheet's Transform.scale based on the
|
// Get the alignment for the _ContextMenuSheet's Transform.scale based on the
|
||||||
// contextMenuLocation.
|
// contextMenuLocation.
|
||||||
static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
|
static AlignmentDirectional getSheetAlignment(
|
||||||
|
_ContextMenuLocation contextMenuLocation) {
|
||||||
switch (contextMenuLocation) {
|
switch (contextMenuLocation) {
|
||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
return AlignmentDirectional.topCenter;
|
return AlignmentDirectional.topCenter;
|
||||||
@@ -623,17 +636,27 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The place to start the sheetRect animation from.
|
// The place to start the sheetRect animation from.
|
||||||
static Rect _getSheetRectBegin(Orientation? orientation, _ContextMenuLocation contextMenuLocation, Rect childRect, Rect sheetRect) {
|
static Rect _getSheetRectBegin(
|
||||||
|
Orientation? orientation,
|
||||||
|
_ContextMenuLocation contextMenuLocation,
|
||||||
|
Rect childRect,
|
||||||
|
Rect sheetRect) {
|
||||||
switch (contextMenuLocation) {
|
switch (contextMenuLocation) {
|
||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomCenter : childRect.topCenter;
|
final Offset target = orientation == Orientation.portrait
|
||||||
|
? childRect.bottomCenter
|
||||||
|
: childRect.topCenter;
|
||||||
final Offset centered = target - Offset(sheetRect.width / 2, 0.0);
|
final Offset centered = target - Offset(sheetRect.width / 2, 0.0);
|
||||||
return centered & sheetRect.size;
|
return centered & sheetRect.size;
|
||||||
case _ContextMenuLocation.right:
|
case _ContextMenuLocation.right:
|
||||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomRight : childRect.topRight;
|
final Offset target = orientation == Orientation.portrait
|
||||||
|
? childRect.bottomRight
|
||||||
|
: childRect.topRight;
|
||||||
return (target - Offset(sheetRect.width, 0.0)) & sheetRect.size;
|
return (target - Offset(sheetRect.width, 0.0)) & sheetRect.size;
|
||||||
case _ContextMenuLocation.left:
|
case _ContextMenuLocation.left:
|
||||||
final Offset target = orientation == Orientation.portrait ? childRect.bottomLeft : childRect.topLeft;
|
final Offset target = orientation == Orientation.portrait
|
||||||
|
? childRect.bottomLeft
|
||||||
|
: childRect.topLeft;
|
||||||
return target & sheetRect.size;
|
return target & sheetRect.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -651,7 +674,9 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
// Take measurements on the child and _ContextMenuSheet and update the
|
// Take measurements on the child and _ContextMenuSheet and update the
|
||||||
// animation tweens to match.
|
// animation tweens to match.
|
||||||
void _updateTweenRects() {
|
void _updateTweenRects() {
|
||||||
final Rect childRect = _scale == null ? _getRect(_childGlobalKey) : _getScaledRect(_childGlobalKey, _scale!);
|
final Rect childRect = _scale == null
|
||||||
|
? _getRect(_childGlobalKey)
|
||||||
|
: _getScaledRect(_childGlobalKey, _scale!);
|
||||||
_rectTween.begin = _previousChildRect;
|
_rectTween.begin = _previousChildRect;
|
||||||
_rectTween.end = childRect;
|
_rectTween.end = childRect;
|
||||||
|
|
||||||
@@ -725,7 +750,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
Widget buildPage(BuildContext context, Animation<double> animation,
|
||||||
|
Animation<double> secondaryAnimation) {
|
||||||
// This is usually used to build the "page", which is then passed to
|
// This is usually used to build the "page", which is then passed to
|
||||||
// buildTransitions as child, the idea being that buildTransitions will
|
// buildTransitions as child, the idea being that buildTransitions will
|
||||||
// animate the entire page into the scene. In the case of _ContextMenuRoute,
|
// animate the entire page into the scene. In the case of _ContextMenuRoute,
|
||||||
@@ -735,7 +761,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
|
Widget buildTransitions(BuildContext context, Animation<double> animation,
|
||||||
|
Animation<double> secondaryAnimation, Widget child) {
|
||||||
return OrientationBuilder(
|
return OrientationBuilder(
|
||||||
builder: (BuildContext context, Orientation orientation) {
|
builder: (BuildContext context, Orientation orientation) {
|
||||||
_lastOrientation = orientation;
|
_lastOrientation = orientation;
|
||||||
@@ -744,9 +771,15 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
|||||||
// they're movable.
|
// they're movable.
|
||||||
if (!animation.isCompleted) {
|
if (!animation.isCompleted) {
|
||||||
final bool reverse = animation.status == AnimationStatus.reverse;
|
final bool reverse = animation.status == AnimationStatus.reverse;
|
||||||
final Rect rect = reverse ? _rectAnimatableReverse.evaluate(animation)! : _rectAnimatable.evaluate(animation)!;
|
final Rect rect = reverse
|
||||||
final Rect sheetRect = reverse ? _sheetRectAnimatableReverse.evaluate(animation)! : _sheetRectAnimatable.evaluate(animation)!;
|
? _rectAnimatableReverse.evaluate(animation)!
|
||||||
final double sheetScale = reverse ? _sheetScaleAnimatableReverse.evaluate(animation) : _sheetScaleAnimatable.evaluate(animation);
|
: _rectAnimatable.evaluate(animation)!;
|
||||||
|
final Rect sheetRect = reverse
|
||||||
|
? _sheetRectAnimatableReverse.evaluate(animation)!
|
||||||
|
: _sheetRectAnimatable.evaluate(animation)!;
|
||||||
|
final double sheetScale = reverse
|
||||||
|
? _sheetScaleAnimatableReverse.evaluate(animation)
|
||||||
|
: _sheetScaleAnimatable.evaluate(animation);
|
||||||
return Stack(
|
return Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Positioned.fromRect(
|
Positioned.fromRect(
|
||||||
@@ -818,7 +851,8 @@ class _ContextMenuRouteStatic extends StatefulWidget {
|
|||||||
_ContextMenuRouteStaticState createState() => _ContextMenuRouteStaticState();
|
_ContextMenuRouteStaticState createState() => _ContextMenuRouteStaticState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with TickerProviderStateMixin {
|
class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
// The child is scaled down as it is dragged down until it hits this minimum
|
// The child is scaled down as it is dragged down until it hits this minimum
|
||||||
// value.
|
// value.
|
||||||
static const double _kMinScale = 0.8;
|
static const double _kMinScale = 0.8;
|
||||||
@@ -838,7 +872,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
late Animation<double> _sheetOpacityAnimation;
|
late Animation<double> _sheetOpacityAnimation;
|
||||||
|
|
||||||
// The scale of the child changes as a function of the distance it is dragged.
|
// The scale of the child changes as a function of the distance it is dragged.
|
||||||
static double _getScale(Orientation orientation, double maxDragDistance, double dy) {
|
static double _getScale(
|
||||||
|
Orientation orientation, double maxDragDistance, double dy) {
|
||||||
final double dyDirectional = dy <= 0.0 ? dy : -dy;
|
final double dyDirectional = dy <= 0.0 ? dy : -dy;
|
||||||
return math.max(
|
return math.max(
|
||||||
_kMinScale,
|
_kMinScale,
|
||||||
@@ -859,11 +894,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
// If flung, animate a bit before handling the potential dismiss.
|
// If flung, animate a bit before handling the potential dismiss.
|
||||||
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
|
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
|
||||||
final bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
|
final bool flingIsAway = details.velocity.pixelsPerSecond.dy > 0;
|
||||||
final double finalPosition = flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
|
final double finalPosition =
|
||||||
|
flingIsAway ? _moveAnimation.value.dy + 100.0 : 0.0;
|
||||||
|
|
||||||
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
|
if (flingIsAway && _sheetController.status != AnimationStatus.forward) {
|
||||||
_sheetController.forward();
|
_sheetController.forward();
|
||||||
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
|
} else if (!flingIsAway &&
|
||||||
|
_sheetController.status != AnimationStatus.reverse) {
|
||||||
_sheetController.reverse();
|
_sheetController.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -918,21 +955,30 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
|
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
Alignment _getChildAlignment(
|
||||||
|
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||||
switch (contextMenuLocation) {
|
switch (contextMenuLocation) {
|
||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
return orientation == Orientation.portrait
|
||||||
|
? Alignment.bottomCenter
|
||||||
|
: Alignment.topRight;
|
||||||
case _ContextMenuLocation.right:
|
case _ContextMenuLocation.right:
|
||||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topLeft;
|
return orientation == Orientation.portrait
|
||||||
|
? Alignment.bottomCenter
|
||||||
|
: Alignment.topLeft;
|
||||||
case _ContextMenuLocation.left:
|
case _ContextMenuLocation.left:
|
||||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
return orientation == Orientation.portrait
|
||||||
|
? Alignment.bottomCenter
|
||||||
|
: Alignment.topRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setDragOffset(Offset dragOffset) {
|
void _setDragOffset(Offset dragOffset) {
|
||||||
// Allow horizontal and negative vertical movement, but damp it.
|
// Allow horizontal and negative vertical movement, but damp it.
|
||||||
final double endX = _kPadding * dragOffset.dx / _kDamping;
|
final double endX = _kPadding * dragOffset.dx / _kDamping;
|
||||||
final double endY = dragOffset.dy >= 0.0 ? dragOffset.dy : _kPadding * dragOffset.dy / _kDamping;
|
final double endY = dragOffset.dy >= 0.0
|
||||||
|
? dragOffset.dy
|
||||||
|
: _kPadding * dragOffset.dy / _kDamping;
|
||||||
setState(() {
|
setState(() {
|
||||||
_dragOffset = dragOffset;
|
_dragOffset = dragOffset;
|
||||||
_moveAnimation = Tween<Offset>(
|
_moveAnimation = Tween<Offset>(
|
||||||
@@ -949,9 +995,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Fade the _ContextMenuSheet out or in, if needed.
|
// Fade the _ContextMenuSheet out or in, if needed.
|
||||||
if (_lastScale <= _kSheetScaleThreshold && _sheetController.status != AnimationStatus.forward && _sheetScaleAnimation.value != 0.0) {
|
if (_lastScale <= _kSheetScaleThreshold &&
|
||||||
|
_sheetController.status != AnimationStatus.forward &&
|
||||||
|
_sheetScaleAnimation.value != 0.0) {
|
||||||
_sheetController.forward();
|
_sheetController.forward();
|
||||||
} else if (_lastScale > _kSheetScaleThreshold && _sheetController.status != AnimationStatus.reverse && _sheetScaleAnimation.value != 1.0) {
|
} else if (_lastScale > _kSheetScaleThreshold &&
|
||||||
|
_sheetController.status != AnimationStatus.reverse &&
|
||||||
|
_sheetScaleAnimation.value != 1.0) {
|
||||||
_sheetController.reverse();
|
_sheetController.reverse();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -960,7 +1010,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
// The order and alignment of the _ContextMenuSheet and the child depend on
|
// The order and alignment of the _ContextMenuSheet and the child depend on
|
||||||
// both the orientation of the screen as well as the position on the screen of
|
// both the orientation of the screen as well as the position on the screen of
|
||||||
// the original child.
|
// the original child.
|
||||||
List<Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
List<Widget> _getChildren(
|
||||||
|
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||||
final Expanded child = Expanded(
|
final Expanded child = Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: _getChildAlignment(
|
alignment: _getChildAlignment(
|
||||||
@@ -995,7 +1046,9 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
case _ContextMenuLocation.center:
|
case _ContextMenuLocation.center:
|
||||||
return <Widget>[child, spacer, sheet];
|
return <Widget>[child, spacer, sheet];
|
||||||
case _ContextMenuLocation.right:
|
case _ContextMenuLocation.right:
|
||||||
return orientation == Orientation.portrait ? <Widget>[child, spacer, sheet] : <Widget>[sheet, spacer, child];
|
return orientation == Orientation.portrait
|
||||||
|
? <Widget>[child, spacer, sheet]
|
||||||
|
: <Widget>[sheet, spacer, child];
|
||||||
case _ContextMenuLocation.left:
|
case _ContextMenuLocation.left:
|
||||||
return <Widget>[child, spacer, sheet];
|
return <Widget>[child, spacer, sheet];
|
||||||
}
|
}
|
||||||
@@ -1004,7 +1057,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
|||||||
// Build the animation for the _ContextMenuSheet.
|
// Build the animation for the _ContextMenuSheet.
|
||||||
Widget _buildSheetAnimation(BuildContext context, Widget? child) {
|
Widget _buildSheetAnimation(BuildContext context, Widget? child) {
|
||||||
return Transform.scale(
|
return Transform.scale(
|
||||||
alignment: _ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
alignment:
|
||||||
|
_ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
||||||
scale: _sheetScaleAnimation.value,
|
scale: _sheetScaleAnimation.value,
|
||||||
child: FadeTransition(
|
child: FadeTransition(
|
||||||
opacity: _sheetOpacityAnimation,
|
opacity: _sheetOpacityAnimation,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class SearchCell extends ConsumerStatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SearchCellState extends ConsumerState<SearchCell> {
|
class _SearchCellState extends ConsumerState<SearchCell> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -35,9 +34,7 @@ class _SearchCellState extends ConsumerState<SearchCell> {
|
|||||||
),
|
),
|
||||||
onSuffixTap: () {
|
onSuffixTap: () {
|
||||||
widget.controller.text = "";
|
widget.controller.text = "";
|
||||||
setState(() {
|
setState(() {});
|
||||||
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
controller: widget.controller,
|
controller: widget.controller,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
|
|||||||
@@ -29,9 +29,8 @@ class SourceCodeView extends StatefulWidget {
|
|||||||
this.syntaxHighlighterStyle,
|
this.syntaxHighlighterStyle,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
String? get codeLink => codeLinkPrefix == null
|
String? get codeLink =>
|
||||||
? null
|
codeLinkPrefix == null ? null : '$codeLinkPrefix/$filePath';
|
||||||
: '$codeLinkPrefix/$filePath';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SourceCodeViewState createState() {
|
_SourceCodeViewState createState() {
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ class SyntaxHighlighterStyle {
|
|||||||
this.constantStyle});
|
this.constantStyle});
|
||||||
|
|
||||||
static SyntaxHighlighterStyle lightThemeStyle() => SyntaxHighlighterStyle(
|
static SyntaxHighlighterStyle lightThemeStyle() => SyntaxHighlighterStyle(
|
||||||
baseStyle: const TextStyle(color: const Color(0xFF000000),height: 1,),
|
baseStyle: const TextStyle(
|
||||||
|
color: const Color(0xFF000000),
|
||||||
|
height: 1,
|
||||||
|
),
|
||||||
numberStyle: const TextStyle(color: const Color(0xFF1565C0)),
|
numberStyle: const TextStyle(color: const Color(0xFF1565C0)),
|
||||||
commentStyle: const TextStyle(color: const Color(0xFF9E9E9E)),
|
commentStyle: const TextStyle(color: const Color(0xFF9E9E9E)),
|
||||||
keywordStyle: const TextStyle(color: const Color(0xFF9C27B0)),
|
keywordStyle: const TextStyle(color: const Color(0xFF9C27B0)),
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ class UserInfoViewModel {
|
|||||||
_useSecertLogined = SpUtil.getBool(spSecretLogined, defValue: false);
|
_useSecertLogined = SpUtil.getBool(spSecretLogined, defValue: false);
|
||||||
_host = SpUtil.getString(spHost, defValue: '');
|
_host = SpUtil.getString(spHost, defValue: '');
|
||||||
|
|
||||||
List<dynamic>? tempList = jsonDecode(SpUtil.getString(spLoginHistory, defValue: '[]'));
|
List<dynamic>? tempList =
|
||||||
|
jsonDecode(SpUtil.getString(spLoginHistory, defValue: '[]'));
|
||||||
|
|
||||||
if (tempList != null && tempList.isNotEmpty) {
|
if (tempList != null && tempList.isNotEmpty) {
|
||||||
for (Map<String, dynamic> value in tempList) {
|
for (Map<String, dynamic> value in tempList) {
|
||||||
@@ -40,7 +41,8 @@ class UserInfoViewModel {
|
|||||||
SpUtil.putString(spUserInfo, token);
|
SpUtil.putString(spUserInfo, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateUserName(String host, String userName, String password, bool secretLogin) {
|
void updateUserName(
|
||||||
|
String host, String userName, String password, bool secretLogin) {
|
||||||
updateHost(host);
|
updateHost(host);
|
||||||
_useSecretLogin(secretLogin);
|
_useSecretLogin(secretLogin);
|
||||||
_userName = userName;
|
_userName = userName;
|
||||||
@@ -93,7 +95,13 @@ class UserInfoViewModel {
|
|||||||
|
|
||||||
historyAccounts.removeWhere((element) => element.host == _host);
|
historyAccounts.removeWhere((element) => element.host == _host);
|
||||||
|
|
||||||
historyAccounts.insert(0, UserInfoBean(userName: _userName, password: _passWord, useSecretLogined: _useSecertLogined, host: _host));
|
historyAccounts.insert(
|
||||||
|
0,
|
||||||
|
UserInfoBean(
|
||||||
|
userName: _userName,
|
||||||
|
password: _passWord,
|
||||||
|
useSecretLogined: _useSecertLogined,
|
||||||
|
host: _host));
|
||||||
|
|
||||||
while (historyAccounts.length > 3) {
|
while (historyAccounts.length > 3) {
|
||||||
historyAccounts.removeLast();
|
historyAccounts.removeLast();
|
||||||
@@ -117,7 +125,8 @@ class UserInfoBean {
|
|||||||
bool useSecretLogined = false;
|
bool useSecretLogined = false;
|
||||||
String? host;
|
String? host;
|
||||||
|
|
||||||
UserInfoBean({this.userName, this.password, this.useSecretLogined = false, this.host});
|
UserInfoBean(
|
||||||
|
{this.userName, this.password, this.useSecretLogined = false, this.host});
|
||||||
|
|
||||||
UserInfoBean.fromJson(Map<String, dynamic> json) {
|
UserInfoBean.fromJson(Map<String, dynamic> json) {
|
||||||
userName = json['userName'];
|
userName = json['userName'];
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
|||||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
|
|
||||||
|
|
||||||
class JsonConversion$Json {
|
class JsonConversion$Json {
|
||||||
|
|
||||||
static M fromJson<M>(dynamic json) {
|
static M fromJson<M>(dynamic json) {
|
||||||
if (json is List) {
|
if (json is List) {
|
||||||
return _getListChildType<M>(json);
|
return _getListChildType<M>(json);
|
||||||
@@ -23,46 +21,45 @@ class JsonConversion$Json {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static M _fromJsonSingle<M>(dynamic json) {
|
static M _fromJsonSingle<M>(dynamic json) {
|
||||||
|
|
||||||
String type = M.toString();
|
String type = M.toString();
|
||||||
|
|
||||||
if(type == (ConfigBean).toString()){
|
if (type == (ConfigBean).toString()) {
|
||||||
return ConfigBean.jsonConversion(json) as M;
|
return ConfigBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (EnvBean).toString()){
|
if (type == (EnvBean).toString()) {
|
||||||
return EnvBean.jsonConversion(json) as M;
|
return EnvBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (SystemBean).toString()){
|
if (type == (SystemBean).toString()) {
|
||||||
return SystemBean.jsonConversion(json) as M;
|
return SystemBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (LoginBean).toString()){
|
if (type == (LoginBean).toString()) {
|
||||||
return LoginBean.jsonConversion(json) as M;
|
return LoginBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (UserBean).toString()){
|
if (type == (UserBean).toString()) {
|
||||||
return UserBean.jsonConversion(json) as M;
|
return UserBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (DependencyBean).toString()){
|
if (type == (DependencyBean).toString()) {
|
||||||
return DependencyBean.jsonConversion(json) as M;
|
return DependencyBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (LoginLogBean).toString()){
|
if (type == (LoginLogBean).toString()) {
|
||||||
return LoginLogBean.jsonConversion(json) as M;
|
return LoginLogBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (ScriptBean).toString()){
|
if (type == (ScriptBean).toString()) {
|
||||||
return ScriptBean.jsonConversion(json) as M;
|
return ScriptBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (TaskLogBean).toString()){
|
if (type == (TaskLogBean).toString()) {
|
||||||
return TaskLogBean.jsonConversion(json) as M;
|
return TaskLogBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(type == (TaskBean).toString()){
|
if (type == (TaskBean).toString()) {
|
||||||
return TaskBean.jsonConversion(json) as M;
|
return TaskBean.jsonConversion(json) as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,44 +67,56 @@ class JsonConversion$Json {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static M _getListChildType<M>(List<dynamic> data) {
|
static M _getListChildType<M>(List<dynamic> data) {
|
||||||
if(<ConfigBean>[] is M){
|
if (<ConfigBean>[] is M) {
|
||||||
return data.map<ConfigBean>((e) => ConfigBean.jsonConversion(e)).toList() as M;
|
return data.map<ConfigBean>((e) => ConfigBean.jsonConversion(e)).toList()
|
||||||
|
as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<EnvBean>[] is M){
|
if (<EnvBean>[] is M) {
|
||||||
return data.map<EnvBean>((e) => EnvBean.jsonConversion(e)).toList() as M;
|
return data.map<EnvBean>((e) => EnvBean.jsonConversion(e)).toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<SystemBean>[] is M){
|
if (<SystemBean>[] is M) {
|
||||||
return data.map<SystemBean>((e) => SystemBean.jsonConversion(e)).toList() as M;
|
return data.map<SystemBean>((e) => SystemBean.jsonConversion(e)).toList()
|
||||||
|
as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<LoginBean>[] is M){
|
if (<LoginBean>[] is M) {
|
||||||
return data.map<LoginBean>((e) => LoginBean.jsonConversion(e)).toList() as M;
|
return data.map<LoginBean>((e) => LoginBean.jsonConversion(e)).toList()
|
||||||
|
as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<UserBean>[] is M){
|
if (<UserBean>[] is M) {
|
||||||
return data.map<UserBean>((e) => UserBean.jsonConversion(e)).toList() as M;
|
return data.map<UserBean>((e) => UserBean.jsonConversion(e)).toList()
|
||||||
|
as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<DependencyBean>[] is M){
|
if (<DependencyBean>[] is M) {
|
||||||
return data.map<DependencyBean>((e) => DependencyBean.jsonConversion(e)).toList() as M;
|
return data
|
||||||
|
.map<DependencyBean>((e) => DependencyBean.jsonConversion(e))
|
||||||
|
.toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<LoginLogBean>[] is M){
|
if (<LoginLogBean>[] is M) {
|
||||||
return data.map<LoginLogBean>((e) => LoginLogBean.jsonConversion(e)).toList() as M;
|
return data
|
||||||
|
.map<LoginLogBean>((e) => LoginLogBean.jsonConversion(e))
|
||||||
|
.toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<ScriptBean>[] is M){
|
if (<ScriptBean>[] is M) {
|
||||||
return data.map<ScriptBean>((e) => ScriptBean.jsonConversion(e)).toList() as M;
|
return data.map<ScriptBean>((e) => ScriptBean.jsonConversion(e)).toList()
|
||||||
|
as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<TaskLogBean>[] is M){
|
if (<TaskLogBean>[] is M) {
|
||||||
return data.map<TaskLogBean>((e) => TaskLogBean.jsonConversion(e)).toList() as M;
|
return data
|
||||||
|
.map<TaskLogBean>((e) => TaskLogBean.jsonConversion(e))
|
||||||
|
.toList() as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(<TaskBean>[] is M){
|
if (<TaskBean>[] is M) {
|
||||||
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList() as M;
|
return data.map<TaskBean>((e) => TaskBean.jsonConversion(e)).toList()
|
||||||
|
as M;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Exception("not found");
|
throw Exception("not found");
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ void main() async {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
SystemUiOverlayStyle style = const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
SystemUiOverlayStyle style =
|
||||||
|
const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
|
||||||
SystemChrome.setSystemUIOverlayStyle(style);
|
SystemChrome.setSystemUIOverlayStyle(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,8 @@ class QlAppState extends ConsumerState<QlApp> {
|
|||||||
FocusScope.of(context).requestFocus(FocusNode());
|
FocusScope.of(context).requestFocus(FocusNode());
|
||||||
},
|
},
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window).copyWith(
|
data:
|
||||||
|
MediaQueryData.fromWindow(WidgetsBinding.instance.window).copyWith(
|
||||||
textScaleFactor: 1,
|
textScaleFactor: 1,
|
||||||
),
|
),
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
@@ -87,7 +89,9 @@ class QlAppState extends ConsumerState<QlApp> {
|
|||||||
if (!kReleaseMode) {
|
if (!kReleaseMode) {
|
||||||
showDebugBtn(context);
|
showDebugBtn(context);
|
||||||
}
|
}
|
||||||
return getIt<UserInfoViewModel>().isLogined() ? const HomePage() : const LoginPage();
|
return getIt<UserInfoViewModel>().isLogined()
|
||||||
|
? const HomePage()
|
||||||
|
: const LoginPage();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// home: LoginPage(),
|
// home: LoginPage(),
|
||||||
|
|||||||
@@ -64,13 +64,17 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == getIt<UserInfoViewModel>().historyAccounts.length) {
|
if (index ==
|
||||||
|
getIt<UserInfoViewModel>().historyAccounts.length) {
|
||||||
return addAccount();
|
return addAccount();
|
||||||
}
|
}
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.settingBordorColor(),
|
||||||
child: buildCell(index),
|
child: buildCell(index),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -80,7 +84,8 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
|||||||
height: 10,
|
height: 10,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemCount: getIt<UserInfoViewModel>().historyAccounts.length + 1),
|
itemCount:
|
||||||
|
getIt<UserInfoViewModel>().historyAccounts.length + 1),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -113,11 +118,13 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
|||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
border: Border.all(color: ref.watch(themeProvider).primaryColor, width: 1),
|
border: Border.all(
|
||||||
|
color: ref.watch(themeProvider).primaryColor, width: 1),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"已登录",
|
"已登录",
|
||||||
style: TextStyle(color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: (isLoginingHost.isNotEmpty
|
: (isLoginingHost.isNotEmpty
|
||||||
@@ -132,7 +139,8 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
|||||||
: const SizedBox.shrink()),
|
: const SizedBox.shrink()),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getIt<UserInfoViewModel>().historyAccounts[index].host == getIt<UserInfoViewModel>().host) {
|
if (getIt<UserInfoViewModel>().historyAccounts[index].host ==
|
||||||
|
getIt<UserInfoViewModel>().host) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +154,8 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
|||||||
backgroundColor: Colors.red,
|
backgroundColor: Colors.red,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
getIt<UserInfoViewModel>().removeHistoryAccount(getIt<UserInfoViewModel>().historyAccounts[index].host);
|
getIt<UserInfoViewModel>().removeHistoryAccount(
|
||||||
|
getIt<UserInfoViewModel>().historyAccounts[index].host);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
@@ -181,7 +190,8 @@ class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
|||||||
|
|
||||||
void dealLoginResponse(int response) {
|
void dealLoginResponse(int response) {
|
||||||
if (response == LoginHelper.success) {
|
if (response == LoginHelper.success) {
|
||||||
Navigator.of(context).pushNamedAndRemoveUntil(Routes.routeHomePage, (_) => false);
|
Navigator.of(context)
|
||||||
|
.pushNamedAndRemoveUntil(Routes.routeHomePage, (_) => false);
|
||||||
} else if (response == LoginHelper.failed) {
|
} else if (response == LoginHelper.failed) {
|
||||||
loginFailed();
|
loginFailed();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> notifyICloud(BuildContext context, String? title, String? content) async {
|
Future<void> notifyICloud(
|
||||||
}
|
BuildContext context, String? title, String? content) async {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -60,7 +60,8 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
|
|||||||
},
|
},
|
||||||
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||||
stringMap: {
|
stringMap: {
|
||||||
"export": const TextStyle(fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
"export": const TextStyle(
|
||||||
|
fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -137,7 +138,8 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
|
|||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
HttpResponse<NullResponse> response = await Api.saveFile(widget.title, result);
|
HttpResponse<NullResponse> response =
|
||||||
|
await Api.saveFile(widget.title, result);
|
||||||
await notifyICloud(context, widget.title, result);
|
await notifyICloud(context, widget.title, result);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
"提交成功".toast();
|
"提交成功".toast();
|
||||||
@@ -226,7 +228,8 @@ class _ConfigEditPageState extends ConsumerState<ConfigEditPage> {
|
|||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
TextEditingController controller = TextEditingController(text: defaultValue.replaceAll("\"", "").replaceAll("'", ""));
|
TextEditingController controller = TextEditingController(
|
||||||
|
text: defaultValue.replaceAll("\"", "").replaceAll("'", ""));
|
||||||
showCupertinoDialog(
|
showCupertinoDialog(
|
||||||
useRootNavigator: false,
|
useRootNavigator: false,
|
||||||
context: context,
|
context: context,
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class ConfigPage extends StatefulWidget {
|
|||||||
ConfigPageState createState() => ConfigPageState();
|
ConfigPageState createState() => ConfigPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
class ConfigPageState extends State<ConfigPage>
|
||||||
|
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||||
int _initIndex = 0;
|
int _initIndex = 0;
|
||||||
BuildContext? childContext;
|
BuildContext? childContext;
|
||||||
|
|
||||||
@@ -89,8 +90,14 @@ class ConfigPageState extends State<ConfigPage> with SingleTickerProviderStateMi
|
|||||||
void editMe(WidgetRef ref) {
|
void editMe(WidgetRef ref) {
|
||||||
if (childContext == null) return;
|
if (childContext == null) return;
|
||||||
navigatorState.currentState?.pushNamed(Routes.routeConfigEdit, arguments: {
|
navigatorState.currentState?.pushNamed(Routes.routeConfigEdit, arguments: {
|
||||||
"title": ref.read(configProvider).list[DefaultTabController.of(childContext!)?.index ?? 0].title,
|
"title": ref
|
||||||
"content": ref.read(configProvider).content[ref.read(configProvider).list[DefaultTabController.of(childContext!)?.index ?? 0].title]
|
.read(configProvider)
|
||||||
|
.list[DefaultTabController.of(childContext!)?.index ?? 0]
|
||||||
|
.title,
|
||||||
|
"content": ref.read(configProvider).content[ref
|
||||||
|
.read(configProvider)
|
||||||
|
.list[DefaultTabController.of(childContext!)?.index ?? 0]
|
||||||
|
.title]
|
||||||
}).then((value) async {
|
}).then((value) async {
|
||||||
if (value != null && (value as String).isNotEmpty) {
|
if (value != null && (value as String).isNotEmpty) {
|
||||||
await ref.read(configProvider).loadContent(value);
|
await ref.read(configProvider).loadContent(value);
|
||||||
@@ -115,7 +122,8 @@ class CodeWidget extends ConsumerStatefulWidget {
|
|||||||
ConsumerState<CodeWidget> createState() => _CodeWidgetState();
|
ConsumerState<CodeWidget> createState() => _CodeWidgetState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CodeWidgetState extends ConsumerState<CodeWidget> with AutomaticKeepAliveClientMixin {
|
class _CodeWidgetState extends ConsumerState<CodeWidget>
|
||||||
|
with AutomaticKeepAliveClientMixin {
|
||||||
CodeController? _codeController;
|
CodeController? _codeController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -143,7 +151,8 @@ class _CodeWidgetState extends ConsumerState<CodeWidget> with AutomaticKeepAlive
|
|||||||
},
|
},
|
||||||
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||||
stringMap: {
|
stringMap: {
|
||||||
"export": const TextStyle(fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
"export": const TextStyle(
|
||||||
|
fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
|
|||||||
8
lib/module/env/add_env_page.dart
vendored
@@ -186,8 +186,12 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
|
|||||||
envBean.value = _valueController.text;
|
envBean.value = _valueController.text;
|
||||||
envBean.remarks = _remarkController.text;
|
envBean.remarks = _remarkController.text;
|
||||||
HttpResponse<NullResponse> response = await Api.addEnv(
|
HttpResponse<NullResponse> response = await Api.addEnv(
|
||||||
_nameController.text, _valueController.text, _remarkController.text,
|
_nameController.text,
|
||||||
id: envBean.id,nId: envBean.nId,);
|
_valueController.text,
|
||||||
|
_remarkController.text,
|
||||||
|
id: envBean.id,
|
||||||
|
nId: envBean.nId,
|
||||||
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
(envBean.sId == null) ? "新增成功" : "修改成功".toast();
|
(envBean.sId == null) ? "新增成功" : "修改成功".toast();
|
||||||
|
|||||||
13
lib/module/env/env_bean.dart
vendored
@@ -12,7 +12,14 @@ class EnvBean {
|
|||||||
String? name;
|
String? name;
|
||||||
String? remarks;
|
String? remarks;
|
||||||
|
|
||||||
EnvBean({this.value, this.sId, this.created, this.status, this.timestamp, this.name, this.remarks});
|
EnvBean(
|
||||||
|
{this.value,
|
||||||
|
this.sId,
|
||||||
|
this.created,
|
||||||
|
this.status,
|
||||||
|
this.timestamp,
|
||||||
|
this.name,
|
||||||
|
this.remarks});
|
||||||
|
|
||||||
get nId => _id;
|
get nId => _id;
|
||||||
|
|
||||||
@@ -20,7 +27,9 @@ class EnvBean {
|
|||||||
value = json['value'];
|
value = json['value'];
|
||||||
id = json['id'];
|
id = json['id'];
|
||||||
_id = json['_id'];
|
_id = json['_id'];
|
||||||
sId = json.containsKey('_id') ? json['_id'].toString() : (json.containsKey('id') ? json['id'].toString() : "");
|
sId = json.containsKey('_id')
|
||||||
|
? json['_id'].toString()
|
||||||
|
: (json.containsKey('id') ? json['id'].toString() : "");
|
||||||
created = int.tryParse(json['created'].toString());
|
created = int.tryParse(json['created'].toString());
|
||||||
status = json['status'];
|
status = json['status'];
|
||||||
timestamp = json['timestamp'];
|
timestamp = json['timestamp'];
|
||||||
|
|||||||
13
lib/module/env/env_detail_page.dart
vendored
@@ -36,7 +36,8 @@ class _TaskDetailPageState extends ConsumerState<EnvDetailPage> {
|
|||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: widget.envBean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeAddEnv, arguments: widget.envBean);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -225,7 +226,9 @@ class _TaskDetailPageState extends ConsumerState<EnvDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enableTask() async {
|
void enableTask() async {
|
||||||
await ref.read(envProvider).enableEnv(widget.envBean.sId!, widget.envBean.status!);
|
await ref
|
||||||
|
.read(envProvider)
|
||||||
|
.enableEnv(widget.envBean.sId!, widget.envBean.status!);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,14 +325,16 @@ class EnvDetailCell extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color:
|
||||||
|
ref.watch(themeProvider).themeColor.descColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Expanded(
|
: Expanded(
|
||||||
child: Align(alignment: Alignment.centerRight, child: icon!),
|
child:
|
||||||
|
Align(alignment: Alignment.centerRight, child: icon!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
71
lib/module/env/env_page.dart
vendored
@@ -83,7 +83,8 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: ReorderableListView(
|
: ReorderableListView(
|
||||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
keyboardDismissBehavior:
|
||||||
|
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
header: searchCell(context, ref),
|
header: searchCell(context, ref),
|
||||||
onReorder: (int oldIndex, int newIndex) {
|
onReorder: (int oldIndex, int newIndex) {
|
||||||
if (list.length != model.list.length) {
|
if (list.length != model.list.length) {
|
||||||
@@ -97,9 +98,11 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
if (newIndex > oldIndex) {
|
if (newIndex > oldIndex) {
|
||||||
newIndex -= 1;
|
newIndex -= 1;
|
||||||
}
|
}
|
||||||
final EnvBean item = model.list.removeAt(oldIndex);
|
final EnvBean item =
|
||||||
|
model.list.removeAt(oldIndex);
|
||||||
model.list.insert(newIndex, item);
|
model.list.insert(newIndex, item);
|
||||||
model.update(item.sId ?? "", newIndex, oldIndex);
|
model.update(
|
||||||
|
item.sId ?? "", newIndex, oldIndex);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -145,7 +148,9 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
EnvViewModel.allStr,
|
EnvViewModel.allStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: currentState == EnvViewModel.allStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
color: currentState == EnvViewModel.allStr
|
||||||
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -155,7 +160,9 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
EnvViewModel.enabledStr,
|
EnvViewModel.enabledStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: currentState == EnvViewModel.enabledStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
color: currentState == EnvViewModel.enabledStr
|
||||||
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -165,8 +172,9 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
EnvViewModel.disabledStr,
|
EnvViewModel.disabledStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: currentState == EnvViewModel.disabledStr
|
||||||
currentState == EnvViewModel.disabledStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -199,7 +207,8 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
final int index;
|
final int index;
|
||||||
final WidgetRef ref;
|
final WidgetRef ref;
|
||||||
|
|
||||||
const EnvItemCell(this.bean, this.index, this.ref, {Key? key}) : super(key: key);
|
const EnvItemCell(this.bean, this.index, this.ref, {Key? key})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -212,7 +221,8 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xff5D5E70),
|
backgroundColor: const Color(0xff5D5E70),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: bean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeAddEnv, arguments: bean);
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: CupertinoIcons.pencil_outline,
|
icon: CupertinoIcons.pencil_outline,
|
||||||
@@ -223,7 +233,9 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
enableEnv(context);
|
enableEnv(context);
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
icon: bean.status == 0
|
||||||
|
? Icons.dnd_forwardslash
|
||||||
|
: Icons.check_circle_outline_sharp,
|
||||||
),
|
),
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffEA4D3E),
|
backgroundColor: const Color(0xffEA4D3E),
|
||||||
@@ -245,7 +257,8 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeEnvDetail, arguments: bean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeEnvDetail, arguments: bean);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -272,13 +285,22 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
horizontal: 5,
|
horizontal: 5,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(3),
|
borderRadius:
|
||||||
border: Border.all(color: ref.watch(themeProvider).themeColor.descColor(), width: 1),
|
BorderRadius.circular(3),
|
||||||
|
border: Border.all(
|
||||||
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
|
width: 1),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"${getIndexByIndex(context, index)}",
|
"${getIndexByIndex(context, index)}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -299,7 +321,10 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -315,7 +340,8 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Visibility(
|
child: Visibility(
|
||||||
visible: bean.remarks != null && bean.remarks!.isNotEmpty,
|
visible: bean.remarks != null &&
|
||||||
|
bean.remarks!.isNotEmpty,
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -324,7 +350,10 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
height: 1,
|
height: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -358,7 +387,10 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -375,7 +407,8 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
5
lib/module/env/env_viewmodel.dart
vendored
@@ -15,7 +15,6 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
List<EnvBean> disabledList = [];
|
List<EnvBean> disabledList = [];
|
||||||
List<EnvBean> enabledList = [];
|
List<EnvBean> enabledList = [];
|
||||||
|
|
||||||
|
|
||||||
Future<void> loadData([isLoading = true]) async {
|
Future<void> loadData([isLoading = true]) async {
|
||||||
if (isLoading && list.isEmpty) {
|
if (isLoading && list.isEmpty) {
|
||||||
loading(notify: true);
|
loading(notify: true);
|
||||||
@@ -23,12 +22,12 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
HttpResponse<List<EnvBean>> result = await Api.envs("");
|
HttpResponse<List<EnvBean>> result = await Api.envs("");
|
||||||
|
|
||||||
|
|
||||||
if (result.success && result.bean != null) {
|
if (result.success && result.bean != null) {
|
||||||
list.clear();
|
list.clear();
|
||||||
list.addAll(result.bean!);
|
list.addAll(result.bean!);
|
||||||
disabledList.clear();
|
disabledList.clear();
|
||||||
disabledList.addAll(list.where((element) => element.status == 1).toList());
|
disabledList
|
||||||
|
.addAll(list.where((element) => element.status == 1).toList());
|
||||||
enabledList.clear();
|
enabledList.clear();
|
||||||
enabledList.addAll(list.where((element) => element.status == 0).toList());
|
enabledList.addAll(list.where((element) => element.status == 0).toList());
|
||||||
success();
|
success();
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
if (!widget.doNotLoadLocalData) {
|
if (!widget.doNotLoadLocalData) {
|
||||||
_hostController.text = getIt<UserInfoViewModel>().host ?? "";
|
_hostController.text = getIt<UserInfoViewModel>().host ?? "";
|
||||||
useSecretLogin = getIt<UserInfoViewModel>().useSecretLogined;
|
useSecretLogin = getIt<UserInfoViewModel>().useSecretLogined;
|
||||||
if (getIt<UserInfoViewModel>().userName != null && getIt<UserInfoViewModel>().userName!.isNotEmpty) {
|
if (getIt<UserInfoViewModel>().userName != null &&
|
||||||
|
getIt<UserInfoViewModel>().userName!.isNotEmpty) {
|
||||||
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
||||||
_cIdController.text = getIt<UserInfoViewModel>().userName!;
|
_cIdController.text = getIt<UserInfoViewModel>().userName!;
|
||||||
} else {
|
} else {
|
||||||
@@ -54,7 +55,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
} else {
|
} else {
|
||||||
rememberPassword = false;
|
rememberPassword = false;
|
||||||
}
|
}
|
||||||
if (getIt<UserInfoViewModel>().passWord != null && getIt<UserInfoViewModel>().passWord!.isNotEmpty) {
|
if (getIt<UserInfoViewModel>().passWord != null &&
|
||||||
|
getIt<UserInfoViewModel>().passWord!.isNotEmpty) {
|
||||||
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
||||||
_cSecretController.text = getIt<UserInfoViewModel>().passWord!;
|
_cSecretController.text = getIt<UserInfoViewModel>().passWord!;
|
||||||
} else {
|
} else {
|
||||||
@@ -76,7 +78,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: AnnotatedRegion<SystemUiOverlayStyle>(
|
body: AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
value: ref.watch(themeProvider).darkMode == true ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
|
value: ref.watch(themeProvider).darkMode == true
|
||||||
|
? SystemUiOverlayStyle.light
|
||||||
|
: SystemUiOverlayStyle.dark,
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
@@ -105,7 +109,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 26,
|
fontSize: 26,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -115,7 +122,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
if (debugBtnIsShow()) {
|
if (debugBtnIsShow()) {
|
||||||
dismissDebugBtn();
|
dismissDebugBtn();
|
||||||
} else {
|
} else {
|
||||||
showDebugBtn(context, btnColor: ref.watch(themeProvider).primaryColor);
|
showDebugBtn(context,
|
||||||
|
btnColor:
|
||||||
|
ref.watch(themeProvider).primaryColor);
|
||||||
}
|
}
|
||||||
WidgetsBinding.instance.endOfFrame;
|
WidgetsBinding.instance.endOfFrame;
|
||||||
},
|
},
|
||||||
@@ -158,7 +167,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
hintText: "http://1.1.1.1:5700",
|
hintText: "http://1.1.1.1:5700",
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
@@ -216,7 +228,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
hintText: "请输入账户",
|
hintText: "请输入账户",
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
@@ -260,7 +275,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
hintText: "请输入密码",
|
hintText: "请输入密码",
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
@@ -310,7 +328,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
hintText: "请输入client_id",
|
hintText: "请输入client_id",
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
@@ -354,7 +375,10 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
hintText: "请输入client_secret",
|
hintText: "请输入client_secret",
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
@@ -399,7 +423,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
cardKey.currentState?.toggleCard();
|
cardKey.currentState?.toggleCard();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance
|
||||||
|
.addPostFrameCallback((timeStamp) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -421,7 +446,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
height: 30,
|
height: 30,
|
||||||
),
|
),
|
||||||
Shake(
|
Shake(
|
||||||
preferences: const AnimationPreferences(autoPlay: AnimationPlayStates.None),
|
preferences: const AnimationPreferences(
|
||||||
|
autoPlay: AnimationPlayStates.None),
|
||||||
key: loginKey,
|
key: loginKey,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -469,9 +495,11 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
Http.pushedLoginPage = false;
|
Http.pushedLoginPage = false;
|
||||||
Utils.hideKeyBoard(context);
|
Utils.hideKeyBoard(context);
|
||||||
if (loginByUserName()) {
|
if (loginByUserName()) {
|
||||||
login(_userNameController.text, _passwordController.text);
|
login(_userNameController.text,
|
||||||
|
_passwordController.text);
|
||||||
} else {
|
} else {
|
||||||
login(_cIdController.text, _cSecretController.text);
|
login(_cIdController.text,
|
||||||
|
_cSecretController.text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -498,7 +526,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
onSelected: (UserInfoBean result) {
|
onSelected: (UserInfoBean result) {
|
||||||
selected(result);
|
selected(result);
|
||||||
},
|
},
|
||||||
itemBuilder: (BuildContext context) => <PopupMenuEntry<UserInfoBean>>[
|
itemBuilder: (BuildContext context) =>
|
||||||
|
<PopupMenuEntry<UserInfoBean>>[
|
||||||
...getIt<UserInfoViewModel>()
|
...getIt<UserInfoViewModel>()
|
||||||
.historyAccounts
|
.historyAccounts
|
||||||
.map(
|
.map(
|
||||||
@@ -554,7 +583,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
isLoading = true;
|
isLoading = true;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
helper = LoginHelper(useSecretLogin, _hostController.text, userName, password, rememberPassword);
|
helper = LoginHelper(useSecretLogin, _hostController.text, userName,
|
||||||
|
password, rememberPassword);
|
||||||
var response = await helper!.login();
|
var response = await helper!.login();
|
||||||
dealLoginResponse(response);
|
dealLoginResponse(response);
|
||||||
}
|
}
|
||||||
@@ -581,9 +611,11 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
|
|
||||||
if (_hostController.text.isEmpty) return false;
|
if (_hostController.text.isEmpty) return false;
|
||||||
if (!loginByUserName()) {
|
if (!loginByUserName()) {
|
||||||
return _cIdController.text.isNotEmpty && _cSecretController.text.isNotEmpty;
|
return _cIdController.text.isNotEmpty &&
|
||||||
|
_cSecretController.text.isNotEmpty;
|
||||||
} else {
|
} else {
|
||||||
return _userNameController.text.isNotEmpty && _passwordController.text.isNotEmpty;
|
return _userNameController.text.isNotEmpty &&
|
||||||
|
_passwordController.text.isNotEmpty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class UserBean {
|
|||||||
data['twoFactorActivated'] = this.twoFactorActivated;
|
data['twoFactorActivated'] = this.twoFactorActivated;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UserBean jsonConversion(Map<String, dynamic> json) {
|
static UserBean jsonConversion(Map<String, dynamic> json) {
|
||||||
return UserBean.fromJson(json);
|
return UserBean.fromJson(json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class _AboutPageState extends ConsumerState<AboutPage> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
getInfo();
|
getInfo();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -88,7 +87,8 @@ class _AboutPageState extends ConsumerState<AboutPage> {
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_launchURL("https://github.com/qinglong-app/qinglong_app/releases");
|
_launchURL(
|
||||||
|
"https://github.com/qinglong-app/qinglong_app/releases");
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"版本更新",
|
"版本更新",
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class DependencyPage extends StatefulWidget {
|
|||||||
_DependcyPageState createState() => _DependcyPageState();
|
_DependcyPageState createState() => _DependcyPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DependcyPageState extends State<DependencyPage> with TickerProviderStateMixin {
|
class _DependcyPageState extends State<DependencyPage>
|
||||||
|
with TickerProviderStateMixin {
|
||||||
List<DepedencyEnum> types = [];
|
List<DepedencyEnum> types = [];
|
||||||
|
|
||||||
TabController? _tabController;
|
TabController? _tabController;
|
||||||
@@ -125,7 +126,9 @@ class _DependcyPageState extends State<DependencyPage> with TickerProviderStateM
|
|||||||
itemCount: list.length,
|
itemCount: list.length,
|
||||||
),
|
),
|
||||||
onRefresh: () {
|
onRefresh: () {
|
||||||
return model.loadData(types[_tabController!.index].name.toLowerCase(), false);
|
return model.loadData(
|
||||||
|
types[_tabController!.index].name.toLowerCase(),
|
||||||
|
false);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -222,7 +225,10 @@ class DependencyCell extends ConsumerWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -255,11 +261,16 @@ class DependencyCell extends ConsumerWidget {
|
|||||||
child: Material(
|
child: Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
(bean.created == null || bean.created == 0) ? "-" : Utils.formatMessageTime(bean.created!),
|
(bean.created == null || bean.created == 0)
|
||||||
|
? "-"
|
||||||
|
: Utils.formatMessageTime(bean.created!),
|
||||||
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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -357,7 +368,9 @@ class DependencyCell extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
ref.read(dependencyProvider).del(type.name.toLowerCase(), sId ?? "");
|
ref
|
||||||
|
.read(dependencyProvider)
|
||||||
|
.del(type.name.toLowerCase(), sId ?? "");
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ class DependencyViewModel extends BaseViewModel {
|
|||||||
List<DependencyBean> linuxList = [];
|
List<DependencyBean> linuxList = [];
|
||||||
|
|
||||||
Future<void> loadData(String type, [bool showLoading = true]) async {
|
Future<void> loadData(String type, [bool showLoading = true]) async {
|
||||||
if (showLoading && ((type == "nodejs" && nodeJsList.isEmpty) || (type == "python3" && python3List.isEmpty) || (type == "linux" && linuxList.isEmpty))) {
|
if (showLoading &&
|
||||||
|
((type == "nodejs" && nodeJsList.isEmpty) ||
|
||||||
|
(type == "python3" && python3List.isEmpty) ||
|
||||||
|
(type == "linux" && linuxList.isEmpty))) {
|
||||||
loading(notify: true);
|
loading(notify: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,8 +128,7 @@ class _LoginLogPageState extends ConsumerState<LoginLogPage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadData() async {
|
Future<void> loadData() async {
|
||||||
HttpResponse<List<LoginLogBean>> response =
|
HttpResponse<List<LoginLogBean>> response = await Api.loginLog();
|
||||||
await Api.loginLog();
|
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
if (response.bean == null || response.bean!.isEmpty) {
|
if (response.bean == null || response.bean!.isEmpty) {
|
||||||
|
|||||||
@@ -53,7 +53,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"脚本管理",
|
"脚本管理",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -86,7 +89,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"依赖管理",
|
"依赖管理",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -121,7 +127,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"任务日志",
|
"任务日志",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -161,7 +170,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"登录日志",
|
"登录日志",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -177,7 +189,6 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
const Divider(
|
const Divider(
|
||||||
indent: 15,
|
indent: 15,
|
||||||
),
|
),
|
||||||
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
if (getIt<UserInfoViewModel>().useSecretLogined) {
|
||||||
@@ -203,7 +214,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"修改密码",
|
"修改密码",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -240,7 +254,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"夜间模式",
|
"夜间模式",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color:
|
||||||
|
ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -270,7 +285,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"查看代码是否显示行号",
|
"查看代码是否显示行号",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color:
|
||||||
|
ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -309,7 +325,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"主题设置",
|
"主题设置",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -344,7 +363,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"切换账号",
|
"切换账号",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -381,7 +403,10 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
Text(
|
Text(
|
||||||
"关于",
|
"关于",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -440,7 +465,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
getIt<UserInfoViewModel>().updateToken("");
|
getIt<UserInfoViewModel>().updateToken("");
|
||||||
Navigator.of(context).pushReplacementNamed(Routes.routeLogin);
|
Navigator.of(context)
|
||||||
|
.pushReplacementNamed(Routes.routeLogin);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
154
lib/module/others/scripts/script_code_detail_page.dart
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
import 'package:code_text_field/code_text_field.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:highlight/languages/javascript.dart';
|
||||||
|
import 'package:highlight/languages/json.dart';
|
||||||
|
import 'package:highlight/languages/powershell.dart';
|
||||||
|
import 'package:highlight/languages/python.dart';
|
||||||
|
import 'package:highlight/languages/vbscript-html.dart';
|
||||||
|
import 'package:highlight/languages/yaml.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
import 'package:qinglong_app/base/sp_const.dart';
|
||||||
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/utils/sp_utils.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
class ScriptCodeDetailPage extends ConsumerStatefulWidget {
|
||||||
|
final String title;
|
||||||
|
final String content;
|
||||||
|
|
||||||
|
const ScriptCodeDetailPage({
|
||||||
|
Key? key,
|
||||||
|
required this.title,
|
||||||
|
required this.content,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ScriptCodeDetailPageState createState() => ScriptCodeDetailPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScriptCodeDetailPageState extends ConsumerState<ScriptCodeDetailPage> {
|
||||||
|
CodeController? _codeController;
|
||||||
|
GlobalKey<CodeFieldState> codeFieldKey = GlobalKey();
|
||||||
|
|
||||||
|
bool buttonshow = false;
|
||||||
|
|
||||||
|
void scrollToTop() {
|
||||||
|
codeFieldKey.currentState?.getCodeScroll()?.animateTo(0,
|
||||||
|
duration: const Duration(milliseconds: 200), curve: Curves.linear);
|
||||||
|
}
|
||||||
|
|
||||||
|
void floatingButtonVisibility() {
|
||||||
|
double y = codeFieldKey.currentState?.getCodeScroll()?.offset ?? 0;
|
||||||
|
if (y > MediaQuery.of(context).size.height / 2) {
|
||||||
|
if (buttonshow == true) return;
|
||||||
|
setState(() {
|
||||||
|
buttonshow = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (buttonshow == false) return;
|
||||||
|
setState(() {
|
||||||
|
buttonshow = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String suffix = "\n\n\n";
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_codeController?.dispose();
|
||||||
|
_codeController = null;
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
getLanguageType(String title) {
|
||||||
|
if (title.endsWith(".js")) {
|
||||||
|
return javascript;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title.endsWith(".sh")) {
|
||||||
|
return powershell;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title.endsWith(".py")) {
|
||||||
|
return python;
|
||||||
|
}
|
||||||
|
if (title.endsWith(".json")) {
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
if (title.endsWith(".yaml")) {
|
||||||
|
return yaml;
|
||||||
|
}
|
||||||
|
return vbscriptHtml;
|
||||||
|
}
|
||||||
|
|
||||||
|
late String content;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
content = widget.content;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
_codeController ??= CodeController(
|
||||||
|
text: (content) + suffix,
|
||||||
|
language: getLanguageType(widget.title),
|
||||||
|
onChange: (value) {
|
||||||
|
content = value + suffix;
|
||||||
|
},
|
||||||
|
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||||
|
stringMap: {
|
||||||
|
"export": const TextStyle(
|
||||||
|
fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return Scaffold(
|
||||||
|
floatingActionButton: Visibility(
|
||||||
|
visible: buttonshow,
|
||||||
|
child: FloatingActionButton(
|
||||||
|
mini: true,
|
||||||
|
onPressed: () {
|
||||||
|
scrollToTop();
|
||||||
|
},
|
||||||
|
elevation: 2,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
child: const Icon(CupertinoIcons.up_arrow),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
backCall: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
title: widget.title,
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
top: false,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: SpUtil.getBool(spShowLine, defValue: false) ? 0 : 10,
|
||||||
|
),
|
||||||
|
child: CodeField(
|
||||||
|
key: codeFieldKey,
|
||||||
|
controller: _codeController!,
|
||||||
|
expands: true,
|
||||||
|
readOnly: true,
|
||||||
|
wrap: SpUtil.getBool(spShowLine, defValue: false) ? false : true,
|
||||||
|
hideColumn: !SpUtil.getBool(spShowLine, defValue: false),
|
||||||
|
lineNumberStyle: LineNumberStyle(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
background: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,8 @@ class ScriptDetailPage extends ConsumerStatefulWidget {
|
|||||||
_ScriptDetailPageState createState() => _ScriptDetailPageState();
|
_ScriptDetailPageState createState() => _ScriptDetailPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLoadState<ScriptDetailPage> {
|
class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage>
|
||||||
|
with LazyLoadState<ScriptDetailPage> {
|
||||||
String? content;
|
String? content;
|
||||||
CodeController? _codeController;
|
CodeController? _codeController;
|
||||||
GlobalKey<CodeFieldState> codeFieldKey = GlobalKey();
|
GlobalKey<CodeFieldState> codeFieldKey = GlobalKey();
|
||||||
@@ -42,7 +43,8 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLo
|
|||||||
bool buttonshow = false;
|
bool buttonshow = false;
|
||||||
|
|
||||||
void scrollToTop() {
|
void scrollToTop() {
|
||||||
codeFieldKey.currentState?.getCodeScroll()?.animateTo(0, duration: const Duration(milliseconds: 200), curve: Curves.linear);
|
codeFieldKey.currentState?.getCodeScroll()?.animateTo(0,
|
||||||
|
duration: const Duration(milliseconds: 200), curve: Curves.linear);
|
||||||
}
|
}
|
||||||
|
|
||||||
void floatingButtonVisibility() {
|
void floatingButtonVisibility() {
|
||||||
@@ -164,7 +166,8 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLo
|
|||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
HttpResponse<NullResponse> result = await Api.delScript(widget.title, widget.path ?? "");
|
HttpResponse<NullResponse> result =
|
||||||
|
await Api.delScript(widget.title, widget.path ?? "");
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
"删除成功".toast();
|
"删除成功".toast();
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(true);
|
||||||
@@ -209,7 +212,8 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLo
|
|||||||
},
|
},
|
||||||
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||||
stringMap: {
|
stringMap: {
|
||||||
"export": const TextStyle(fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
"export": const TextStyle(
|
||||||
|
fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -302,14 +306,17 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLo
|
|||||||
top: false,
|
top: false,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: SpUtil.getBool(spShowLine, defValue: false) ? 0 : 10,
|
horizontal:
|
||||||
|
SpUtil.getBool(spShowLine, defValue: false) ? 0 : 10,
|
||||||
),
|
),
|
||||||
child: CodeField(
|
child: CodeField(
|
||||||
key: codeFieldKey,
|
key: codeFieldKey,
|
||||||
controller: _codeController!,
|
controller: _codeController!,
|
||||||
expands: true,
|
expands: true,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
wrap: SpUtil.getBool(spShowLine, defValue: false) ? false : true,
|
wrap: SpUtil.getBool(spShowLine, defValue: false)
|
||||||
|
? false
|
||||||
|
: true,
|
||||||
hideColumn: !SpUtil.getBool(spShowLine, defValue: false),
|
hideColumn: !SpUtil.getBool(spShowLine, defValue: false),
|
||||||
lineNumberStyle: LineNumberStyle(
|
lineNumberStyle: LineNumberStyle(
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
@@ -338,7 +345,9 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLo
|
|||||||
seconds: 1,
|
seconds: 1,
|
||||||
),
|
),
|
||||||
() {
|
() {
|
||||||
codeFieldKey.currentState?.getCodeScroll()?.addListener(floatingButtonVisibility);
|
codeFieldKey.currentState
|
||||||
|
?.getCodeScroll()
|
||||||
|
?.addListener(floatingButtonVisibility);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class ScriptEditPage extends ConsumerStatefulWidget {
|
|||||||
final String title;
|
final String title;
|
||||||
final String path;
|
final String path;
|
||||||
|
|
||||||
const ScriptEditPage(this.title, this.path, this.content, {Key? key}) : super(key: key);
|
const ScriptEditPage(this.title, this.path, this.content, {Key? key})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ScriptEditPageState createState() => _ScriptEditPageState();
|
_ScriptEditPageState createState() => _ScriptEditPageState();
|
||||||
@@ -81,7 +82,8 @@ class _ScriptEditPageState extends ConsumerState<ScriptEditPage> {
|
|||||||
},
|
},
|
||||||
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
theme: ref.watch(themeProvider).themeColor.codeEditorTheme(),
|
||||||
stringMap: {
|
stringMap: {
|
||||||
"export": const TextStyle(fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
"export": const TextStyle(
|
||||||
|
fontWeight: FontWeight.normal, color: Color(0xff6B2375)),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -132,7 +134,8 @@ class _ScriptEditPageState extends ConsumerState<ScriptEditPage> {
|
|||||||
actions: [
|
actions: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
HttpResponse<NullResponse> response = await Api.updateScript(widget.title, widget.path, result);
|
HttpResponse<NullResponse> response =
|
||||||
|
await Api.updateScript(widget.title, widget.path, result);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
"提交成功".toast();
|
"提交成功".toast();
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(true);
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import 'package:qinglong_app/base/ui/search_cell.dart';
|
|||||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||||
import 'package:qinglong_app/utils/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
|
import 'script_upload_page.dart';
|
||||||
|
|
||||||
/// @author NewTab
|
/// @author NewTab
|
||||||
class ScriptPage extends ConsumerStatefulWidget {
|
class ScriptPage extends ConsumerStatefulWidget {
|
||||||
const ScriptPage({Key? key}) : super(key: key);
|
const ScriptPage({Key? key}) : super(key: key);
|
||||||
@@ -19,7 +21,8 @@ class ScriptPage extends ConsumerStatefulWidget {
|
|||||||
_ScriptPageState createState() => _ScriptPageState();
|
_ScriptPageState createState() => _ScriptPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<ScriptPage> {
|
class _ScriptPageState extends ConsumerState<ScriptPage>
|
||||||
|
with LazyLoadState<ScriptPage> {
|
||||||
List<ScriptBean> list = [];
|
List<ScriptBean> list = [];
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
@@ -75,7 +78,8 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
},
|
},
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
keyboardDismissBehavior:
|
||||||
|
ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return searchCell(ref);
|
return searchCell(ref);
|
||||||
@@ -87,19 +91,30 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
(item.title?.contains(_searchController.text) ?? false) ||
|
(item.title?.contains(_searchController.text) ?? false) ||
|
||||||
(item.value?.contains(_searchController.text) ?? false) ||
|
(item.value?.contains(_searchController.text) ?? false) ||
|
||||||
((item.children?.where((e) {
|
((item.children?.where((e) {
|
||||||
return (e.title?.contains(_searchController.text) ?? false) || (e.value?.contains(_searchController.text) ?? false);
|
return (e.title?.contains(_searchController.text) ??
|
||||||
|
false) ||
|
||||||
|
(e.value?.contains(_searchController.text) ??
|
||||||
|
false);
|
||||||
}).isNotEmpty ??
|
}).isNotEmpty ??
|
||||||
false))) {
|
false))) {
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color:
|
||||||
child: (item.children != null && item.children!.isNotEmpty)
|
ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
|
child:
|
||||||
|
(item.children != null && item.children!.isNotEmpty)
|
||||||
? ExpansionTile(
|
? ExpansionTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
item.title ?? "",
|
item.title ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: (item.disabled ?? false)
|
color: (item.disabled ?? false)
|
||||||
? ref.watch(themeProvider).themeColor.descColor()
|
? ref
|
||||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor()
|
||||||
|
: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -108,8 +123,12 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
if (_searchController.text.isEmpty) {
|
if (_searchController.text.isEmpty) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (element.title?.contains(_searchController.text) ?? false) ||
|
return (element.title?.contains(
|
||||||
(element.value?.contains(_searchController.text) ?? false);
|
_searchController.text) ??
|
||||||
|
false) ||
|
||||||
|
(element.value?.contains(
|
||||||
|
_searchController.text) ??
|
||||||
|
false);
|
||||||
})
|
})
|
||||||
.map((e) => ListTile(
|
.map((e) => ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -120,7 +139,8 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
"path": e.parent,
|
"path": e.parent,
|
||||||
},
|
},
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null && value == true) {
|
if (value != null &&
|
||||||
|
value == true) {
|
||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -129,8 +149,14 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
e.title ?? "",
|
e.title ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: (item.disabled ?? false)
|
color: (item.disabled ?? false)
|
||||||
? ref.watch(themeProvider).themeColor.descColor()
|
? ref
|
||||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor()
|
||||||
|
: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -157,8 +183,14 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
item.title ?? "",
|
item.title ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: (item.disabled ?? false)
|
color: (item.disabled ?? false)
|
||||||
? ref.watch(themeProvider).themeColor.descColor()
|
? ref
|
||||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.descColor()
|
||||||
|
: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -209,144 +241,12 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
String scriptPath = "";
|
String scriptPath = "";
|
||||||
|
|
||||||
void addScript() {
|
void addScript() {
|
||||||
showCupertinoDialog(
|
List<String?> paths = list
|
||||||
useRootNavigator: false,
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoAlertDialog(
|
|
||||||
title: const Text("新增脚本"),
|
|
||||||
content: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"脚本名称:",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
child: Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: TextField(
|
|
||||||
controller: _nameController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
isDense: true,
|
|
||||||
contentPadding: EdgeInsets.all(4),
|
|
||||||
hintText: "请输入脚本名称",
|
|
||||||
hintStyle: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
autofocus: false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
const Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
|
||||||
"脚本所属文件夹:",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: DropdownButtonFormField<String>(
|
|
||||||
items: list
|
|
||||||
.where((element) => element.children?.isNotEmpty ?? false)
|
.where((element) => element.children?.isNotEmpty ?? false)
|
||||||
.map((e) => DropdownMenuItem(
|
.map((e) => e.title)
|
||||||
value: e.value,
|
.toList();
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width / 2,
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
child: Text(
|
builder: (context) => ScriptUploadPage(paths: paths)));
|
||||||
e.value ?? "",
|
|
||||||
maxLines: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
))
|
|
||||||
.toList()
|
|
||||||
..insert(
|
|
||||||
0,
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: "",
|
|
||||||
child: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width / 2,
|
|
||||||
child: const Text(
|
|
||||||
"根目录",
|
|
||||||
maxLines: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
value: scriptPath,
|
|
||||||
onChanged: (value) {
|
|
||||||
scriptPath = value ?? "";
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: const Text(
|
|
||||||
"取消",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Color(0xff999999),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoDialogAction(
|
|
||||||
child: Text(
|
|
||||||
"确定",
|
|
||||||
style: TextStyle(
|
|
||||||
color: ref.watch(themeProvider).primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () async {
|
|
||||||
"提交中...".toast();
|
|
||||||
HttpResponse<NullResponse> response = await Api.addScript(
|
|
||||||
_nameController.text,
|
|
||||||
scriptPath,
|
|
||||||
"## created by 青龙客户端 ${DateTime.now()}\n\n",
|
|
||||||
);
|
|
||||||
if (response.success) {
|
|
||||||
"提交成功".toast();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
Routes.routeScriptUpdate,
|
|
||||||
arguments: {
|
|
||||||
"title": _nameController.text,
|
|
||||||
"path": scriptPath,
|
|
||||||
"content": "## created by 青龙客户端 ${DateTime.now()}\n\n",
|
|
||||||
},
|
|
||||||
).then((value) {
|
|
||||||
if (value != null && value == true) {
|
|
||||||
_nameController.text = "";
|
|
||||||
loadData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
(response.message ?? "").toast();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
425
lib/module/others/scripts/script_upload_page.dart
Normal file
@@ -0,0 +1,425 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.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/base/routes.dart';
|
||||||
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:qinglong_app/module/others/scripts/script_code_detail_page.dart';
|
||||||
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
|
/// @author NewTab
|
||||||
|
|
||||||
|
class ScriptUploadPage extends ConsumerStatefulWidget {
|
||||||
|
final List<String?> paths;
|
||||||
|
|
||||||
|
const ScriptUploadPage({
|
||||||
|
Key? key,
|
||||||
|
required this.paths,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<ScriptUploadPage> createState() => ScriptUploadPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScriptUploadPageState extends ConsumerState<ScriptUploadPage> {
|
||||||
|
List<String> list = [];
|
||||||
|
|
||||||
|
final TextEditingController _nameController = TextEditingController();
|
||||||
|
String scriptPath = "";
|
||||||
|
File? file;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
title: "新增脚本",
|
||||||
|
actions: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
submit(context);
|
||||||
|
},
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
"提交",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: 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: 30,
|
||||||
|
),
|
||||||
|
const TitleWidget(
|
||||||
|
"脚本名称",
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _nameController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||||
|
hintText: "请输入脚本名称",
|
||||||
|
hintStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
autofocus: false,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
const TitleWidget(
|
||||||
|
"脚本目录",
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
DropdownButtonFormField<String>(
|
||||||
|
items: widget.paths
|
||||||
|
.map((e) => DropdownMenuItem(
|
||||||
|
value: e,
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width / 2,
|
||||||
|
child: Text(
|
||||||
|
e ?? "",
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.toList()
|
||||||
|
..insert(
|
||||||
|
0,
|
||||||
|
DropdownMenuItem(
|
||||||
|
value: "",
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width / 2,
|
||||||
|
child: const Text(
|
||||||
|
"根目录",
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
contentPadding: EdgeInsets.symmetric(
|
||||||
|
vertical: 15,
|
||||||
|
),
|
||||||
|
enabledBorder: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Color(0xfff5f5f5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
border: UnderlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Color(0xfff5f5f5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
value: scriptPath,
|
||||||
|
onChanged: (value) {
|
||||||
|
scriptPath = value ?? "";
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
const TitleWidget(
|
||||||
|
"上传脚本",
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 80,
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: file == null ? addWidget() : addedWidget(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 50,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget addWidget() {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
FilePickerResult? result = await FilePicker.platform.pickFiles();
|
||||||
|
if (result != null &&
|
||||||
|
result.files.isNotEmpty &&
|
||||||
|
result.files.single.path != null) {
|
||||||
|
file = File(result.files.single.path!);
|
||||||
|
|
||||||
|
if (file == null) return;
|
||||||
|
if (file!.lengthSync() > 5242880) {
|
||||||
|
file = null;
|
||||||
|
"最大支持上传5M的文件".toast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_nameController.text = getFileName();
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(
|
||||||
|
top: 10,
|
||||||
|
),
|
||||||
|
width: 70,
|
||||||
|
height: 70,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xfff3f5f7),
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset(
|
||||||
|
"assets/images/icon_add_file.png",
|
||||||
|
width: 50,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget addedWidget(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
try {
|
||||||
|
String content = await file!.readAsString();
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => ScriptCodeDetailPage(
|
||||||
|
title: getFileName(),
|
||||||
|
content: content,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
e.toString().toast();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
child: Container(
|
||||||
|
height: 80,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
getIconBySuffix(),
|
||||||
|
width: 50,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
getFileName(),
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 5,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
getFileSize(file!.path, 1),
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
file = null;
|
||||||
|
_nameController.text = "";
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.clear,
|
||||||
|
size: 20,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getFileSize(String filepath, int decimals) {
|
||||||
|
var file = File(filepath);
|
||||||
|
int bytes = file.lengthSync();
|
||||||
|
if (bytes <= 0) return "0 B";
|
||||||
|
const suffixes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
|
var i = (log(bytes) / log(1024)).floor();
|
||||||
|
return '${(bytes / pow(1024, i)).toStringAsFixed(decimals)} ${suffixes[i]}';
|
||||||
|
}
|
||||||
|
|
||||||
|
String getFileName() {
|
||||||
|
return basename(file!.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getIconBySuffix() {
|
||||||
|
String end = file!.path;
|
||||||
|
|
||||||
|
if (end.endsWith(".py")) {
|
||||||
|
return "assets/images/py.png";
|
||||||
|
}
|
||||||
|
if (end.endsWith(".js")) {
|
||||||
|
return "assets/images/js.png";
|
||||||
|
}
|
||||||
|
if (end.endsWith(".ts")) {
|
||||||
|
return "assets/images/ts.png";
|
||||||
|
}
|
||||||
|
if (end.endsWith(".json")) {
|
||||||
|
return "assets/images/json.png";
|
||||||
|
}
|
||||||
|
if (end.endsWith(".sh")) {
|
||||||
|
return "assets/images/shell.png";
|
||||||
|
}
|
||||||
|
return "assets/images/other.png";
|
||||||
|
}
|
||||||
|
|
||||||
|
void submit(BuildContext context) async {
|
||||||
|
try {
|
||||||
|
if (_nameController.text.isEmpty) {
|
||||||
|
"请输入文件名称".toast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file == null) {
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
Routes.routeScriptAdd,
|
||||||
|
arguments: {
|
||||||
|
"title": _nameController.text,
|
||||||
|
"path": scriptPath,
|
||||||
|
},
|
||||||
|
).then((value) {
|
||||||
|
if (value != null && value == true) {
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
String content = await file!.readAsString();
|
||||||
|
HttpResponse<NullResponse> response = await Api.addScript(
|
||||||
|
_nameController.text,
|
||||||
|
scriptPath,
|
||||||
|
content,
|
||||||
|
);
|
||||||
|
if (response.success) {
|
||||||
|
"提交成功".toast();
|
||||||
|
|
||||||
|
String command =
|
||||||
|
"task $scriptPath${(scriptPath.isNotEmpty) ? separator : ""}${getFileName()} ";
|
||||||
|
|
||||||
|
String? cron = getCronString(content, getFileName());
|
||||||
|
Navigator.of(context).popAndPushNamed(
|
||||||
|
Routes.routeAddTask,
|
||||||
|
arguments: TaskBean(
|
||||||
|
name: _nameController.text,
|
||||||
|
command: command,
|
||||||
|
schedule: cron,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
(response.message ?? "").toast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
e.toString().toast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static String? getCronString(String pre, String fileName) {
|
||||||
|
String reg =
|
||||||
|
"([\\d\\*]*[\\*-\\/,\\d]*[\\d\\*] ){4,5}[\\d\\*]*[\\*-\\/,\\d]*[\\d\\*]( |,|\").*$fileName";
|
||||||
|
RegExp regExp = RegExp(reg);
|
||||||
|
RegExpMatch? result = regExp.firstMatch(pre);
|
||||||
|
return result?[0]?.replaceAll(fileName, "").trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TitleWidget extends ConsumerWidget {
|
||||||
|
final String title;
|
||||||
|
final bool required;
|
||||||
|
|
||||||
|
const TitleWidget(
|
||||||
|
this.title, {
|
||||||
|
Key? key,
|
||||||
|
this.required = false,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, ref) {
|
||||||
|
return RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
text: !required ? "" : "* ",
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Color(0xFFF02D2D),
|
||||||
|
),
|
||||||
|
children: <TextSpan>[
|
||||||
|
TextSpan(
|
||||||
|
text: title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,8 @@ class TaskLogDetailPage extends ConsumerStatefulWidget {
|
|||||||
_TaskLogDetailPageState createState() => _TaskLogDetailPageState();
|
_TaskLogDetailPageState createState() => _TaskLogDetailPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TaskLogDetailPageState extends ConsumerState<TaskLogDetailPage> with LazyLoadState<TaskLogDetailPage> {
|
class _TaskLogDetailPageState extends ConsumerState<TaskLogDetailPage>
|
||||||
|
with LazyLoadState<TaskLogDetailPage> {
|
||||||
String? content;
|
String? content;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ class TaskLogPage extends ConsumerStatefulWidget {
|
|||||||
_TaskLogPageState createState() => _TaskLogPageState();
|
_TaskLogPageState createState() => _TaskLogPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<TaskLogPage> {
|
class _TaskLogPageState extends ConsumerState<TaskLogPage>
|
||||||
|
with LazyLoadState<TaskLogPage> {
|
||||||
List<TaskLogBean> list = [];
|
List<TaskLogBean> list = [];
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
@@ -63,7 +64,8 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
return searchCell(ref);
|
return searchCell(ref);
|
||||||
}
|
}
|
||||||
TaskLogBean item = list[index - 1];
|
TaskLogBean item = list[index - 1];
|
||||||
if (_searchController.text.isNotEmpty && !(item.name?.contains(_searchController.text) ?? false)) {
|
if (_searchController.text.isNotEmpty &&
|
||||||
|
!(item.name?.contains(_searchController.text) ?? false)) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
@@ -73,7 +75,10 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
title: Text(
|
title: Text(
|
||||||
item.name ?? "",
|
item.name ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -81,7 +86,9 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
? item.files!
|
? item.files!
|
||||||
.map((e) => ListTile(
|
.map((e) => ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
Navigator.of(context).pushNamed(
|
||||||
|
Routes.routeTaskLogDetail,
|
||||||
|
arguments: {
|
||||||
"path": item.name,
|
"path": item.name,
|
||||||
"title": e,
|
"title": e,
|
||||||
});
|
});
|
||||||
@@ -89,7 +96,10 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
title: Text(
|
title: Text(
|
||||||
e,
|
e,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -98,7 +108,9 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
: (item.children ?? [])
|
: (item.children ?? [])
|
||||||
.map((e) => ListTile(
|
.map((e) => ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
Navigator.of(context).pushNamed(
|
||||||
|
Routes.routeTaskLogDetail,
|
||||||
|
arguments: {
|
||||||
"path": item.name,
|
"path": item.name,
|
||||||
"title": e.title,
|
"title": e.title,
|
||||||
});
|
});
|
||||||
@@ -106,7 +118,10 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
title: Text(
|
title: Text(
|
||||||
e.title ?? "",
|
e.title ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -119,7 +134,9 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
"该文件夹为空".toast();
|
"该文件夹为空".toast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
Navigator.of(context).pushNamed(
|
||||||
|
Routes.routeTaskLogDetail,
|
||||||
|
arguments: {
|
||||||
"path": "",
|
"path": "",
|
||||||
"title": item.name,
|
"title": item.name,
|
||||||
});
|
});
|
||||||
@@ -127,7 +144,10 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
title: Text(
|
title: Text(
|
||||||
item.name ?? "",
|
item.name ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ class _ThemePageState extends ConsumerState<ThemePage> {
|
|||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.start,
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -144,7 +145,8 @@ class _ThemePageState extends ConsumerState<ThemePage> {
|
|||||||
child:
|
child:
|
||||||
CircularProgressIndicator(
|
CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
color: _primaryColor,
|
color:
|
||||||
|
_primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -158,8 +160,8 @@ class _ThemePageState extends ConsumerState<ThemePage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
"示例名称",
|
"示例名称",
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow:
|
overflow: TextOverflow
|
||||||
TextOverflow.ellipsis,
|
.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow
|
overflow: TextOverflow
|
||||||
.ellipsis,
|
.ellipsis,
|
||||||
@@ -182,7 +184,8 @@ class _ThemePageState extends ConsumerState<ThemePage> {
|
|||||||
"上午10:00",
|
"上午10:00",
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow:
|
||||||
|
TextOverflow.ellipsis,
|
||||||
color: ref
|
color: ref
|
||||||
.watch(themeProvider)
|
.watch(themeProvider)
|
||||||
.themeColor
|
.themeColor
|
||||||
@@ -216,7 +219,8 @@ class _ThemePageState extends ConsumerState<ThemePage> {
|
|||||||
"10 1-12/2 * * *",
|
"10 1-12/2 * * *",
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow:
|
||||||
|
TextOverflow.ellipsis,
|
||||||
color: ref
|
color: ref
|
||||||
.watch(themeProvider)
|
.watch(themeProvider)
|
||||||
.themeColor
|
.themeColor
|
||||||
|
|||||||
@@ -207,8 +207,11 @@ class _AddTaskPageState extends ConsumerState<AddTaskPage> {
|
|||||||
taskBean.command = _commandController.text;
|
taskBean.command = _commandController.text;
|
||||||
taskBean.schedule = _cronController.text;
|
taskBean.schedule = _cronController.text;
|
||||||
HttpResponse<NullResponse> response = await Api.addTask(
|
HttpResponse<NullResponse> response = await Api.addTask(
|
||||||
_nameController.text, _commandController.text, _cronController.text,
|
_nameController.text,
|
||||||
id: taskBean.id,);
|
_commandController.text,
|
||||||
|
_cronController.text,
|
||||||
|
id: taskBean.id,
|
||||||
|
);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
(widget.taskBean?.sId == null) ? "新增成功" : "修改成功".toast();
|
(widget.taskBean?.sId == null) ? "新增成功" : "修改成功".toast();
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ class _InTimeLogPageState extends State<InTimeLogPage>
|
|||||||
if (!canRequest) return;
|
if (!canRequest) return;
|
||||||
if (isRequest) return;
|
if (isRequest) return;
|
||||||
isRequest = true;
|
isRequest = true;
|
||||||
HttpResponse<String> response =
|
HttpResponse<String> response = await Api.inTimeLog(widget.cronId);
|
||||||
await Api.inTimeLog(widget.cronId);
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
content = response.bean;
|
content = response.bean;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ class TaskBean {
|
|||||||
saved = json['saved'];
|
saved = json['saved'];
|
||||||
id = json['id'];
|
id = json['id'];
|
||||||
_id = json['_id'];
|
_id = json['_id'];
|
||||||
sId = json.containsKey('_id') ? json['_id'].toString() : (json.containsKey('id') ? json['id'].toString() : "");
|
sId = json.containsKey('_id')
|
||||||
|
? json['_id'].toString()
|
||||||
|
: (json.containsKey('id') ? json['id'].toString() : "");
|
||||||
created = int.tryParse(json['created'].toString());
|
created = int.tryParse(json['created'].toString());
|
||||||
status = json['status'];
|
status = json['status'];
|
||||||
timestamp = json['timestamp'].toString();
|
timestamp = json['timestamp'].toString();
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ class TaskDetailPage extends ConsumerStatefulWidget {
|
|||||||
final TaskBean taskBean;
|
final TaskBean taskBean;
|
||||||
final bool hideAppbar;
|
final bool hideAppbar;
|
||||||
|
|
||||||
const TaskDetailPage(this.taskBean, {Key? key, this.hideAppbar = false}) : super(key: key);
|
const TaskDetailPage(this.taskBean, {Key? key, this.hideAppbar = false})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_TaskDetailPageState createState() => _TaskDetailPageState();
|
_TaskDetailPageState createState() => _TaskDetailPageState();
|
||||||
@@ -71,11 +72,13 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
|
|||||||
),
|
),
|
||||||
TaskDetailCell(
|
TaskDetailCell(
|
||||||
title: "创建时间",
|
title: "创建时间",
|
||||||
desc: Utils.formatMessageTime(widget.taskBean.created ?? 0),
|
desc:
|
||||||
|
Utils.formatMessageTime(widget.taskBean.created ?? 0),
|
||||||
),
|
),
|
||||||
TaskDetailCell(
|
TaskDetailCell(
|
||||||
title: "更新时间",
|
title: "更新时间",
|
||||||
desc: Utils.formatGMTTime(widget.taskBean.timestamp ?? ""),
|
desc:
|
||||||
|
Utils.formatGMTTime(widget.taskBean.timestamp ?? ""),
|
||||||
),
|
),
|
||||||
TaskDetailCell(
|
TaskDetailCell(
|
||||||
title: "任务定时",
|
title: "任务定时",
|
||||||
@@ -83,11 +86,14 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
|
|||||||
),
|
),
|
||||||
TaskDetailCell(
|
TaskDetailCell(
|
||||||
title: "最后运行时间",
|
title: "最后运行时间",
|
||||||
desc: Utils.formatMessageTime(widget.taskBean.lastExecutionTime ?? 0),
|
desc: Utils.formatMessageTime(
|
||||||
|
widget.taskBean.lastExecutionTime ?? 0),
|
||||||
),
|
),
|
||||||
TaskDetailCell(
|
TaskDetailCell(
|
||||||
title: "最后运行时长",
|
title: "最后运行时长",
|
||||||
desc: widget.taskBean.lastRunningTime == null ? "-" : "${widget.taskBean.lastRunningTime ?? "-"}秒",
|
desc: widget.taskBean.lastRunningTime == null
|
||||||
|
? "-"
|
||||||
|
: "${widget.taskBean.lastRunningTime ?? "-"}秒",
|
||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
@@ -205,7 +211,8 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
|
|||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: widget.taskBean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeAddTask, arguments: widget.taskBean);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -357,12 +364,16 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enableTask() async {
|
void enableTask() async {
|
||||||
await ref.read(taskProvider).enableTask(widget.taskBean.sId!, widget.taskBean.isDisabled!);
|
await ref
|
||||||
|
.read(taskProvider)
|
||||||
|
.enableTask(widget.taskBean.sId!, widget.taskBean.isDisabled!);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void pinTask() async {
|
void pinTask() async {
|
||||||
await ref.read(taskProvider).pinTask(widget.taskBean.sId!, widget.taskBean.isPinned!);
|
await ref
|
||||||
|
.read(taskProvider)
|
||||||
|
.pinTask(widget.taskBean.sId!, widget.taskBean.isPinned!);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,14 +483,16 @@ class TaskDetailCell extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
color:
|
||||||
|
ref.watch(themeProvider).themeColor.descColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Expanded(
|
: Expanded(
|
||||||
child: Align(alignment: Alignment.centerRight, child: icon!),
|
child:
|
||||||
|
Align(alignment: Alignment.centerRight, child: icon!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -67,9 +67,17 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
}
|
}
|
||||||
TaskBean item = list[index - 1];
|
TaskBean item = list[index - 1];
|
||||||
if (_searchController.text.isEmpty ||
|
if (_searchController.text.isEmpty ||
|
||||||
(item.name?.toLowerCase().contains(_searchController.text.toLowerCase()) ?? false) ||
|
(item.name
|
||||||
(item.command?.toLowerCase().contains(_searchController.text.toLowerCase()) ?? false) ||
|
?.toLowerCase()
|
||||||
(item.schedule?.contains(_searchController.text.toLowerCase()) ?? false)) {
|
.contains(_searchController.text.toLowerCase()) ??
|
||||||
|
false) ||
|
||||||
|
(item.command
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(_searchController.text.toLowerCase()) ??
|
||||||
|
false) ||
|
||||||
|
(item.schedule
|
||||||
|
?.contains(_searchController.text.toLowerCase()) ??
|
||||||
|
false)) {
|
||||||
return TaskItemCell(item, ref);
|
return TaskItemCell(item, ref);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@@ -80,9 +88,17 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
if (index == 0) return const SizedBox.shrink();
|
if (index == 0) return const SizedBox.shrink();
|
||||||
TaskBean item = list[index - 1];
|
TaskBean item = list[index - 1];
|
||||||
if (_searchController.text.isEmpty ||
|
if (_searchController.text.isEmpty ||
|
||||||
(item.name?.toLowerCase().contains(_searchController.text.toLowerCase()) ?? false) ||
|
(item.name
|
||||||
(item.command?.toLowerCase().contains(_searchController.text.toLowerCase()) ?? false) ||
|
?.toLowerCase()
|
||||||
(item.schedule?.contains(_searchController.text.toLowerCase()) ?? false)) {
|
.contains(_searchController.text.toLowerCase()) ??
|
||||||
|
false) ||
|
||||||
|
(item.command
|
||||||
|
?.toLowerCase()
|
||||||
|
.contains(_searchController.text.toLowerCase()) ??
|
||||||
|
false) ||
|
||||||
|
(item.schedule
|
||||||
|
?.contains(_searchController.text.toLowerCase()) ??
|
||||||
|
false)) {
|
||||||
return Container(
|
return Container(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: const Divider(
|
child: const Divider(
|
||||||
@@ -130,7 +146,9 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
TaskViewModel.allStr,
|
TaskViewModel.allStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: currentState == TaskViewModel.allStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
color: currentState == TaskViewModel.allStr
|
||||||
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -140,8 +158,9 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
TaskViewModel.runningStr,
|
TaskViewModel.runningStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: currentState == TaskViewModel.runningStr
|
||||||
currentState == TaskViewModel.runningStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -151,7 +170,9 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
TaskViewModel.neverStr,
|
TaskViewModel.neverStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: currentState == TaskViewModel.neverStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
color: currentState == TaskViewModel.neverStr
|
||||||
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -165,7 +186,10 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: currentState == TaskViewModel.notScriptStr
|
color: currentState == TaskViewModel.notScriptStr
|
||||||
? ref.watch(themeProvider).primaryColor
|
? ref.watch(themeProvider).primaryColor
|
||||||
: ref.watch(themeProvider).themeColor.titleColor(),
|
: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -178,8 +202,9 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
TaskViewModel.disableStr,
|
TaskViewModel.disableStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color:
|
color: currentState == TaskViewModel.disableStr
|
||||||
currentState == TaskViewModel.disableStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
? ref.watch(themeProvider).primaryColor
|
||||||
|
: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
value: TaskViewModel.disableStr,
|
value: TaskViewModel.disableStr,
|
||||||
@@ -236,7 +261,9 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: bean.isPinned == 1
|
||||||
|
? ref.watch(themeProvider).themeColor.pinColor()
|
||||||
|
: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: Slidable(
|
child: Slidable(
|
||||||
key: ValueKey(bean.sId),
|
key: ValueKey(bean.sId),
|
||||||
endActionPane: ActionPane(
|
endActionPane: ActionPane(
|
||||||
@@ -247,7 +274,8 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
backgroundColor: const Color(0xff5D5E70),
|
backgroundColor: const Color(0xff5D5E70),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance.endOfFrame.then((timeStamp) {
|
WidgetsBinding.instance.endOfFrame.then((timeStamp) {
|
||||||
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeAddTask, arguments: bean);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
@@ -259,7 +287,9 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
pinTask(context);
|
pinTask(context);
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: (bean.isPinned ?? 0) == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
icon: (bean.isPinned ?? 0) == 0
|
||||||
|
? CupertinoIcons.pin
|
||||||
|
: CupertinoIcons.pin_slash,
|
||||||
),
|
),
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffA356D6),
|
backgroundColor: const Color(0xffA356D6),
|
||||||
@@ -267,7 +297,9 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
enableTask(context);
|
enableTask(context);
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
icon: bean.isDisabled! == 0
|
||||||
|
? Icons.dnd_forwardslash
|
||||||
|
: Icons.check_circle_outline_sharp,
|
||||||
),
|
),
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffEA4D3E),
|
backgroundColor: const Color(0xffEA4D3E),
|
||||||
@@ -299,7 +331,9 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
icon: bean.status! == 1
|
||||||
|
? CupertinoIcons.memories
|
||||||
|
: CupertinoIcons.stop_circle,
|
||||||
),
|
),
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xff606467),
|
backgroundColor: const Color(0xff606467),
|
||||||
@@ -317,10 +351,13 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Material(
|
child: Material(
|
||||||
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: bean.isPinned == 1
|
||||||
|
? ref.watch(themeProvider).themeColor.pinColor()
|
||||||
|
: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: bean);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.routeTaskDetail, arguments: bean);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
@@ -356,7 +393,10 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -392,11 +432,16 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
Material(
|
Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
(bean.lastExecutionTime == null || bean.lastExecutionTime == 0) ? "-" : Utils.formatMessageTime(bean.lastExecutionTime!),
|
(bean.lastExecutionTime == null ||
|
||||||
|
bean.lastExecutionTime == 0)
|
||||||
|
? "-"
|
||||||
|
: Utils.formatMessageTime(
|
||||||
|
bean.lastExecutionTime!),
|
||||||
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,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.sort((TaskBean a, TaskBean b) {
|
p.sort((TaskBean a, TaskBean b) {
|
||||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0)
|
||||||
|
.isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||||
if (c == true) {
|
if (c == true) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -75,7 +76,8 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
p.sort((a, b) {
|
p.sort((a, b) {
|
||||||
if (a.status == 0 && b.status == 0) {
|
if (a.status == 0 && b.status == 0) {
|
||||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0)
|
||||||
|
.isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||||
if (c == true) {
|
if (c == true) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -86,7 +88,8 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
r.sort((a, b) {
|
r.sort((a, b) {
|
||||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0)
|
||||||
|
.isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||||
if (c == true) {
|
if (c == true) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -94,7 +97,8 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
d.sort((a, b) {
|
d.sort((a, b) {
|
||||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0)
|
||||||
|
.isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||||
if (c == true) {
|
if (c == true) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -102,7 +106,8 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
list.sort((a, b) {
|
list.sort((a, b) {
|
||||||
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0).isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
bool c = DateTime.fromMillisecondsSinceEpoch(a.created ?? 0)
|
||||||
|
.isBefore(DateTime.fromMillisecondsSinceEpoch(b.created ?? 0));
|
||||||
if (c == true) {
|
if (c == true) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -116,9 +121,12 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
running.clear();
|
running.clear();
|
||||||
running.addAll(list.where((element) => element.status == 0));
|
running.addAll(list.where((element) => element.status == 0));
|
||||||
neverRunning.clear();
|
neverRunning.clear();
|
||||||
neverRunning.addAll(list.where((element) => element.lastRunningTime == null));
|
neverRunning
|
||||||
|
.addAll(list.where((element) => element.lastRunningTime == null));
|
||||||
notScripts.clear();
|
notScripts.clear();
|
||||||
notScripts.addAll(list.where((element) => (element.command != null && (element.command!.startsWith("ql repo") || element.command!.startsWith("ql raw")))));
|
notScripts.addAll(list.where((element) => (element.command != null &&
|
||||||
|
(element.command!.startsWith("ql repo") ||
|
||||||
|
element.command!.startsWith("ql raw")))));
|
||||||
disabled.clear();
|
disabled.clear();
|
||||||
disabled.addAll(list.where((element) => element.isDisabled == 1));
|
disabled.addAll(list.where((element) => element.isDisabled == 1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Utils {
|
|||||||
static bool isUpperVersion() {
|
static bool isUpperVersion() {
|
||||||
return systemBean.isUpperVersion();
|
return systemBean.isUpperVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isUpperVersion2_12_2() {
|
static bool isUpperVersion2_12_2() {
|
||||||
return systemBean.isUpperVersion2_12_2();
|
return systemBean.isUpperVersion2_12_2();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,10 @@
|
|||||||
// recursive implementation
|
// recursive implementation
|
||||||
int fibonacci(int n) {
|
int fibonacci(int n) {
|
||||||
if (n <= 1) return n;
|
if (n <= 1) return n;
|
||||||
return fibonacci(n - 1)
|
return fibonacci(n - 1) + fibonacci(n - 2);
|
||||||
+ fibonacci(n - 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
print("Fibonacci sequence:");
|
print("Fibonacci sequence:");
|
||||||
for (var n = 0; n < 10; n++)
|
for (var n = 0; n < 10; n++) print(fibonacci(n));
|
||||||
print(fibonacci(n));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ class CodeController extends TextEditingController {
|
|||||||
this.onChange,
|
this.onChange,
|
||||||
}) : super(text: text) {
|
}) : super(text: text) {
|
||||||
// PatternMap
|
// PatternMap
|
||||||
if (language != null && theme == null) throw Exception("A theme must be provided for language parsing");
|
if (language != null && theme == null)
|
||||||
|
throw Exception("A theme must be provided for language parsing");
|
||||||
// Register language
|
// Register language
|
||||||
if (language != null) {
|
if (language != null) {
|
||||||
highlight.registerLanguage(languageId, language!);
|
highlight.registerLanguage(languageId, language!);
|
||||||
@@ -152,7 +153,8 @@ class CodeController extends TextEditingController {
|
|||||||
const _chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
|
const _chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
|
||||||
final _rnd = Random();
|
final _rnd = Random();
|
||||||
return String.fromCharCodes(
|
return String.fromCharCodes(
|
||||||
Iterable.generate(10, (_) => _chars.codeUnitAt(_rnd.nextInt(_chars.length))),
|
Iterable.generate(
|
||||||
|
10, (_) => _chars.codeUnitAt(_rnd.nextInt(_chars.length))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +180,11 @@ class CodeController extends TextEditingController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now fix the textfield for web
|
// Now fix the textfield for web
|
||||||
if (_webSpaceFix) newValue = newValue.copyWith(text: _spacesToMiddleDots(newValue.text));
|
if (_webSpaceFix)
|
||||||
if (onChange != null) onChange!(_webSpaceFix ? _middleDotsToSpaces(newValue.text) : newValue.text);
|
newValue = newValue.copyWith(text: _spacesToMiddleDots(newValue.text));
|
||||||
|
if (onChange != null)
|
||||||
|
onChange!(
|
||||||
|
_webSpaceFix ? _middleDotsToSpaces(newValue.text) : newValue.text);
|
||||||
super.value = newValue;
|
super.value = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +195,11 @@ class CodeController extends TextEditingController {
|
|||||||
onMatch: (Match m) {
|
onMatch: (Match m) {
|
||||||
if (styleList.isEmpty) return '';
|
if (styleList.isEmpty) return '';
|
||||||
int idx;
|
int idx;
|
||||||
for (idx = 1; idx < m.groupCount && idx <= styleList.length && m.group(idx) == null; idx++) {}
|
for (idx = 1;
|
||||||
|
idx < m.groupCount &&
|
||||||
|
idx <= styleList.length &&
|
||||||
|
m.group(idx) == null;
|
||||||
|
idx++) {}
|
||||||
children.add(TextSpan(
|
children.add(TextSpan(
|
||||||
text: m[0],
|
text: m[0],
|
||||||
style: styleList[idx - 1],
|
style: styleList[idx - 1],
|
||||||
@@ -221,7 +230,8 @@ class CodeController extends TextEditingController {
|
|||||||
if (val != null) {
|
if (val != null) {
|
||||||
if (_webSpaceFix) val = _spacesToMiddleDots(val);
|
if (_webSpaceFix) val = _spacesToMiddleDots(val);
|
||||||
var child = TextSpan(text: val, style: theme?[node.className]);
|
var child = TextSpan(text: val, style: theme?[node.className]);
|
||||||
if (styleRegExp != null) child = _processPatterns(val, theme?[node.className]);
|
if (styleRegExp != null)
|
||||||
|
child = _processPatterns(val, theme?[node.className]);
|
||||||
currentSpans.add(child);
|
currentSpans.add(child);
|
||||||
} else if (nodeChildren != null) {
|
} else if (nodeChildren != null) {
|
||||||
List<TextSpan> tmp = [];
|
List<TextSpan> tmp = [];
|
||||||
@@ -245,7 +255,8 @@ class CodeController extends TextEditingController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextSpan buildTextSpan({required BuildContext context, TextStyle? style, bool? withComposing}) {
|
TextSpan buildTextSpan(
|
||||||
|
{required BuildContext context, TextStyle? style, bool? withComposing}) {
|
||||||
// Retrieve pattern regexp
|
// Retrieve pattern regexp
|
||||||
final patternList = <String>[];
|
final patternList = <String>[];
|
||||||
if (_webSpaceFix) {
|
if (_webSpaceFix) {
|
||||||
|
|||||||
@@ -12,14 +12,16 @@ class LineNumberController extends TextEditingController {
|
|||||||
LineNumberController(this.lineNumberBuilder);
|
LineNumberController(this.lineNumberBuilder);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextSpan buildTextSpan({required BuildContext context, TextStyle? style, bool? withComposing}) {
|
TextSpan buildTextSpan(
|
||||||
|
{required BuildContext context, TextStyle? style, bool? withComposing}) {
|
||||||
final children = <TextSpan>[];
|
final children = <TextSpan>[];
|
||||||
final list = text.split("\n");
|
final list = text.split("\n");
|
||||||
for (int k = 0; k < list.length; k++) {
|
for (int k = 0; k < list.length; k++) {
|
||||||
final el = list[k];
|
final el = list[k];
|
||||||
final number = int.parse(el);
|
final number = int.parse(el);
|
||||||
var textSpan = TextSpan(text: el, style: style);
|
var textSpan = TextSpan(text: el, style: style);
|
||||||
if (lineNumberBuilder != null) textSpan = lineNumberBuilder!(number, style);
|
if (lineNumberBuilder != null)
|
||||||
|
textSpan = lineNumberBuilder!(number, style);
|
||||||
children.add(textSpan);
|
children.add(textSpan);
|
||||||
if (k < list.length - 1) children.add(TextSpan(text: "\n"));
|
if (k < list.length - 1) children.add(TextSpan(text: "\n"));
|
||||||
}
|
}
|
||||||
@@ -199,7 +201,8 @@ class CodeFieldState extends State<CodeField> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wrap the codeField in a horizontal scrollView
|
// Wrap the codeField in a horizontal scrollView
|
||||||
Widget _wrapInScrollView(Widget codeField, TextStyle textStyle, double minWidth) {
|
Widget _wrapInScrollView(
|
||||||
|
Widget codeField, TextStyle textStyle, double minWidth) {
|
||||||
final leftPad = widget.lineNumberStyle.margin / 2;
|
final leftPad = widget.lineNumberStyle.margin / 2;
|
||||||
final intrinsic = IntrinsicWidth(
|
final intrinsic = IntrinsicWidth(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -239,7 +242,8 @@ class CodeFieldState extends State<CodeField> {
|
|||||||
final defaultText = Colors.grey.shade200;
|
final defaultText = Colors.grey.shade200;
|
||||||
|
|
||||||
final theme = widget.controller.theme;
|
final theme = widget.controller.theme;
|
||||||
Color? backgroundCol = widget.background ?? theme?[ROOT_KEY]?.backgroundColor ?? defaultBg;
|
Color? backgroundCol =
|
||||||
|
widget.background ?? theme?[ROOT_KEY]?.backgroundColor ?? defaultBg;
|
||||||
if (widget.decoration != null) {
|
if (widget.decoration != null) {
|
||||||
backgroundCol = null;
|
backgroundCol = null;
|
||||||
}
|
}
|
||||||
@@ -249,14 +253,16 @@ class CodeFieldState extends State<CodeField> {
|
|||||||
fontSize: textStyle.fontSize ?? 16.0,
|
fontSize: textStyle.fontSize ?? 16.0,
|
||||||
);
|
);
|
||||||
TextStyle numberTextStyle = widget.lineNumberStyle.textStyle ?? TextStyle();
|
TextStyle numberTextStyle = widget.lineNumberStyle.textStyle ?? TextStyle();
|
||||||
final numberColor = (theme?[ROOT_KEY]?.color ?? defaultText).withOpacity(0.7);
|
final numberColor =
|
||||||
|
(theme?[ROOT_KEY]?.color ?? defaultText).withOpacity(0.7);
|
||||||
// Copy important attributes
|
// Copy important attributes
|
||||||
numberTextStyle = numberTextStyle.copyWith(
|
numberTextStyle = numberTextStyle.copyWith(
|
||||||
color: numberTextStyle.color ?? numberColor,
|
color: numberTextStyle.color ?? numberColor,
|
||||||
fontSize: textStyle.fontSize,
|
fontSize: textStyle.fontSize,
|
||||||
fontFamily: textStyle.fontFamily,
|
fontFamily: textStyle.fontFamily,
|
||||||
);
|
);
|
||||||
final cursorColor = widget.cursorColor ?? theme?[ROOT_KEY]?.color ?? defaultText;
|
final cursorColor =
|
||||||
|
widget.cursorColor ?? theme?[ROOT_KEY]?.color ?? defaultText;
|
||||||
|
|
||||||
final lineNumberCol = TextField(
|
final lineNumberCol = TextField(
|
||||||
smartQuotesType: widget.smartQuotesType,
|
smartQuotesType: widget.smartQuotesType,
|
||||||
@@ -315,7 +321,9 @@ class CodeFieldState extends State<CodeField> {
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
// Control horizontal scrolling
|
// Control horizontal scrolling
|
||||||
return widget.wrap ? codeField : _wrapInScrollView(codeField, textStyle, constraints.maxWidth);
|
return widget.wrap
|
||||||
|
? codeField
|
||||||
|
: _wrapInScrollView(codeField, textStyle, constraints.maxWidth);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ abstract class CodeModifier {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditingValue? updateString(String text, TextSelection sel, EditorParams params);
|
TextEditingValue? updateString(
|
||||||
|
String text, TextSelection sel, EditorParams params);
|
||||||
}
|
}
|
||||||
|
|
||||||
class IntendModifier extends CodeModifier {
|
class IntendModifier extends CodeModifier {
|
||||||
@@ -30,7 +31,8 @@ class IntendModifier extends CodeModifier {
|
|||||||
}) : super('\n');
|
}) : super('\n');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextEditingValue? updateString(String text, TextSelection sel, EditorParams params) {
|
TextEditingValue? updateString(
|
||||||
|
String text, TextSelection sel, EditorParams params) {
|
||||||
var spacesCount = 0;
|
var spacesCount = 0;
|
||||||
var braceCount = 0;
|
var braceCount = 0;
|
||||||
for (var k = min(sel.start, text.length) - 1; k >= 0; k--) {
|
for (var k = min(sel.start, text.length) - 1; k >= 0; k--) {
|
||||||
@@ -53,7 +55,8 @@ class CloseBlockModifier extends CodeModifier {
|
|||||||
const CloseBlockModifier() : super('}');
|
const CloseBlockModifier() : super('}');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextEditingValue? updateString(String text, TextSelection sel, EditorParams params) {
|
TextEditingValue? updateString(
|
||||||
|
String text, TextSelection sel, EditorParams params) {
|
||||||
int spaceCount = 0;
|
int spaceCount = 0;
|
||||||
for (var k = min(sel.start, text.length) - 1; k >= 0; k--) {
|
for (var k = min(sel.start, text.length) - 1; k >= 0; k--) {
|
||||||
if (text[k] == "\n") break;
|
if (text[k] == "\n") break;
|
||||||
@@ -63,7 +66,8 @@ class CloseBlockModifier extends CodeModifier {
|
|||||||
}
|
}
|
||||||
spaceCount += 1;
|
spaceCount += 1;
|
||||||
}
|
}
|
||||||
if (spaceCount >= params.tabSpaces) return replace(text, sel.start - params.tabSpaces, sel.end, "}");
|
if (spaceCount >= params.tabSpaces)
|
||||||
|
return replace(text, sel.start - params.tabSpaces, sel.end, "}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +76,8 @@ class TabModifier extends CodeModifier {
|
|||||||
const TabModifier() : super('\t');
|
const TabModifier() : super('\t');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TextEditingValue? updateString(String text, TextSelection sel, EditorParams params) {
|
TextEditingValue? updateString(
|
||||||
|
String text, TextSelection sel, EditorParams params) {
|
||||||
final tmp = replace(text, sel.start, sel.end, " " * params.tabSpaces);
|
final tmp = replace(text, sel.start, sel.end, " " * params.tabSpaces);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
14
pubspec.lock
@@ -239,6 +239,13 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.2"
|
version: "6.1.2"
|
||||||
|
file_picker:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: file_picker
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "4.6.1"
|
||||||
fixnum:
|
fixnum:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -312,6 +319,13 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.6"
|
version: "2.1.6"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.6"
|
||||||
flutter_riverpod:
|
flutter_riverpod:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ dependencies:
|
|||||||
share_plus: ^4.0.7
|
share_plus: ^4.0.7
|
||||||
flutter_animator: ^3.2.1
|
flutter_animator: ^3.2.1
|
||||||
modal_bottom_sheet: ^2.0.1
|
modal_bottom_sheet: ^2.0.1
|
||||||
|
file_picker: ^4.6.1
|
||||||
code_text_field:
|
code_text_field:
|
||||||
path: ./pub/code_field-master
|
path: ./pub/code_field-master
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,4 @@
|
|||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
// tree, read text, and verify that the values of widget properties are correct.
|
||||||
|
|
||||||
void main() {
|
void main() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||