mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
支持上传脚本
This commit is contained in:
@@ -24,7 +24,9 @@ class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
||||
_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
|
||||
Widget build(BuildContext context) {
|
||||
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>(
|
||||
Url.runTasks,
|
||||
crons,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
||||
static Future<HttpResponse<NullResponse>> stopTasks(
|
||||
List<String> crons) async {
|
||||
return await Http.put<NullResponse>(
|
||||
Url.stopTasks,
|
||||
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>(
|
||||
Url.updatePassword,
|
||||
{
|
||||
@@ -127,7 +130,11 @@ class Api {
|
||||
int? id,
|
||||
String? nId,
|
||||
}) 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) {
|
||||
@@ -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>(
|
||||
Url.saveFile,
|
||||
{"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>(
|
||||
Url.envMove(id),
|
||||
{"fromIndex": fromIndex, "toIndex": toIndex},
|
||||
@@ -275,10 +284,12 @@ class Api {
|
||||
}
|
||||
|
||||
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()) {
|
||||
return await Http.get<String>(
|
||||
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>(
|
||||
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>(
|
||||
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>(
|
||||
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>>(
|
||||
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>(
|
||||
Url.dependencies,
|
||||
[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>(
|
||||
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>(
|
||||
Url.addScript,
|
||||
{
|
||||
|
||||
@@ -122,7 +122,8 @@ class Http {
|
||||
if (!pushedLoginPage) {
|
||||
"身份已过期,请重新登录".toast();
|
||||
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) {
|
||||
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 {
|
||||
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;
|
||||
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> {
|
||||
|
||||
@@ -7,8 +7,7 @@ import '../userinfo_viewmodel.dart';
|
||||
class TokenInterceptor extends Interceptor {
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
options.headers["User-Agent"] =
|
||||
"qinglong_client";
|
||||
options.headers["User-Agent"] = "qinglong_client";
|
||||
|
||||
options.headers["Content-Type"] = "application/json;charset=UTF-8";
|
||||
|
||||
|
||||
@@ -14,70 +14,127 @@ class Url {
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
if (path == login || path == loginByClientId || path == loginTwo || path == loginOld) {
|
||||
if (path == login ||
|
||||
path == loginByClientId ||
|
||||
path == loginTwo ||
|
||||
path == loginOld) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -71,7 +71,8 @@ class Routes {
|
||||
return MaterialPageRoute(builder: (context) => const AddTaskPage());
|
||||
}
|
||||
case routeAddDependency:
|
||||
return MaterialPageRoute(builder: (context) => const AddDependencyPage());
|
||||
return MaterialPageRoute(
|
||||
builder: (context) => const AddDependencyPage());
|
||||
case routeAddEnv:
|
||||
if (settings.arguments != null) {
|
||||
return MaterialPageRoute(
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
import 'dart:math' as math;
|
||||
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/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -42,7 +43,8 @@ typedef _ContextMenuPreviewBuilderChildless = Widget Function(
|
||||
// paintBounds in global coordinates.
|
||||
Rect _getRect(GlobalKey globalKey) {
|
||||
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(
|
||||
renderBoxContainer.paintBounds.topLeft,
|
||||
);
|
||||
@@ -194,7 +196,8 @@ class QlCupertinoContextMenu extends StatefulWidget {
|
||||
State<QlCupertinoContextMenu> createState() => _QlCupertinoContextMenuState();
|
||||
}
|
||||
|
||||
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with TickerProviderStateMixin {
|
||||
class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu>
|
||||
with TickerProviderStateMixin {
|
||||
final GlobalKey _childGlobalKey = GlobalKey();
|
||||
bool _childHidden = false;
|
||||
|
||||
@@ -227,7 +230,8 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
||||
final double screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
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();
|
||||
if (centerDividesChild && distanceFromCenter <= childRect.width / 4) {
|
||||
return _ContextMenuLocation.center;
|
||||
@@ -318,7 +322,8 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
|
||||
_openController.reverse();
|
||||
} else {
|
||||
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();
|
||||
}
|
||||
|
||||
class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin {
|
||||
class _DecoyChildState extends State<_DecoyChild>
|
||||
with TickerProviderStateMixin {
|
||||
// TODO(justinmc): Dark mode support.
|
||||
// See https://github.com/flutter/flutter/issues/43211.
|
||||
static const Color _lightModeMaskColor = Color(0xFF888888);
|
||||
@@ -481,7 +487,9 @@ class _DecoyChildState extends State<_DecoyChild> with TickerProviderStateMixin
|
||||
}
|
||||
|
||||
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(
|
||||
rect: _rect.value!,
|
||||
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
|
||||
// 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 _ContextMenuPreviewBuilderChildless? _builder;
|
||||
@@ -562,7 +571,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
static final RectTween _rectTween = RectTween();
|
||||
static final Animatable<Rect?> _rectAnimatable = _rectTween.chain(_curve);
|
||||
static final RectTween _rectTweenReverse = RectTween();
|
||||
static final Animatable<Rect?> _rectAnimatableReverse = _rectTweenReverse.chain(
|
||||
static final Animatable<Rect?> _rectAnimatableReverse =
|
||||
_rectTweenReverse.chain(
|
||||
_curveReverse,
|
||||
);
|
||||
static final RectTween _sheetRectTween = RectTween();
|
||||
@@ -573,10 +583,12 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
_curveReverse,
|
||||
);
|
||||
static final Tween<double> _sheetScaleTween = Tween<double>();
|
||||
static final Animatable<double> _sheetScaleAnimatable = _sheetScaleTween.chain(
|
||||
static final Animatable<double> _sheetScaleAnimatable =
|
||||
_sheetScaleTween.chain(
|
||||
_curve,
|
||||
);
|
||||
static final Animatable<double> _sheetScaleAnimatableReverse = _sheetScaleTween.chain(
|
||||
static final Animatable<double> _sheetScaleAnimatableReverse =
|
||||
_sheetScaleTween.chain(
|
||||
_curveReverse,
|
||||
);
|
||||
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
|
||||
// contextMenuLocation.
|
||||
static AlignmentDirectional getSheetAlignment(_ContextMenuLocation contextMenuLocation) {
|
||||
static AlignmentDirectional getSheetAlignment(
|
||||
_ContextMenuLocation contextMenuLocation) {
|
||||
switch (contextMenuLocation) {
|
||||
case _ContextMenuLocation.center:
|
||||
return AlignmentDirectional.topCenter;
|
||||
@@ -623,17 +636,27 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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);
|
||||
return centered & sheetRect.size;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -651,7 +674,9 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
// Take measurements on the child and _ContextMenuSheet and update the
|
||||
// animation tweens to match.
|
||||
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.end = childRect;
|
||||
|
||||
@@ -725,7 +750,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
|
||||
@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
|
||||
// buildTransitions as child, the idea being that buildTransitions will
|
||||
// animate the entire page into the scene. In the case of _ContextMenuRoute,
|
||||
@@ -735,7 +761,8 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
|
||||
@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(
|
||||
builder: (BuildContext context, Orientation orientation) {
|
||||
_lastOrientation = orientation;
|
||||
@@ -744,9 +771,15 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
|
||||
// they're movable.
|
||||
if (!animation.isCompleted) {
|
||||
final bool reverse = animation.status == AnimationStatus.reverse;
|
||||
final Rect rect = reverse ? _rectAnimatableReverse.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);
|
||||
final Rect rect = reverse
|
||||
? _rectAnimatableReverse.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(
|
||||
children: <Widget>[
|
||||
Positioned.fromRect(
|
||||
@@ -818,7 +851,8 @@ class _ContextMenuRouteStatic extends StatefulWidget {
|
||||
_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
|
||||
// value.
|
||||
static const double _kMinScale = 0.8;
|
||||
@@ -838,7 +872,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
late Animation<double> _sheetOpacityAnimation;
|
||||
|
||||
// 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;
|
||||
return math.max(
|
||||
_kMinScale,
|
||||
@@ -859,11 +894,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
// If flung, animate a bit before handling the potential dismiss.
|
||||
if (details.velocity.pixelsPerSecond.dy.abs() >= kMinFlingVelocity) {
|
||||
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) {
|
||||
_sheetController.forward();
|
||||
} else if (!flingIsAway && _sheetController.status != AnimationStatus.reverse) {
|
||||
} else if (!flingIsAway &&
|
||||
_sheetController.status != AnimationStatus.reverse) {
|
||||
_sheetController.reverse();
|
||||
}
|
||||
|
||||
@@ -918,21 +955,30 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
widget.onDismiss!(context, _lastScale, _sheetOpacityAnimation.value);
|
||||
}
|
||||
|
||||
Alignment _getChildAlignment(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
Alignment _getChildAlignment(
|
||||
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
switch (contextMenuLocation) {
|
||||
case _ContextMenuLocation.center:
|
||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
||||
return orientation == Orientation.portrait
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.topRight;
|
||||
case _ContextMenuLocation.right:
|
||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topLeft;
|
||||
return orientation == Orientation.portrait
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.topLeft;
|
||||
case _ContextMenuLocation.left:
|
||||
return orientation == Orientation.portrait ? Alignment.bottomCenter : Alignment.topRight;
|
||||
return orientation == Orientation.portrait
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.topRight;
|
||||
}
|
||||
}
|
||||
|
||||
void _setDragOffset(Offset dragOffset) {
|
||||
// Allow horizontal and negative vertical movement, but damp it.
|
||||
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(() {
|
||||
_dragOffset = dragOffset;
|
||||
_moveAnimation = Tween<Offset>(
|
||||
@@ -949,9 +995,13 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
);
|
||||
|
||||
// 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();
|
||||
} 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();
|
||||
}
|
||||
});
|
||||
@@ -960,7 +1010,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
// 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
|
||||
// the original child.
|
||||
List<Widget> _getChildren(Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
List<Widget> _getChildren(
|
||||
Orientation orientation, _ContextMenuLocation contextMenuLocation) {
|
||||
final Expanded child = Expanded(
|
||||
child: Align(
|
||||
alignment: _getChildAlignment(
|
||||
@@ -995,7 +1046,9 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
case _ContextMenuLocation.center:
|
||||
return <Widget>[child, spacer, sheet];
|
||||
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:
|
||||
return <Widget>[child, spacer, sheet];
|
||||
}
|
||||
@@ -1004,7 +1057,8 @@ class _ContextMenuRouteStaticState extends State<_ContextMenuRouteStatic> with T
|
||||
// Build the animation for the _ContextMenuSheet.
|
||||
Widget _buildSheetAnimation(BuildContext context, Widget? child) {
|
||||
return Transform.scale(
|
||||
alignment: _ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
||||
alignment:
|
||||
_ContextMenuRoute.getSheetAlignment(widget.contextMenuLocation),
|
||||
scale: _sheetScaleAnimation.value,
|
||||
child: FadeTransition(
|
||||
opacity: _sheetOpacityAnimation,
|
||||
|
||||
@@ -17,7 +17,6 @@ class SearchCell extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _SearchCellState extends ConsumerState<SearchCell> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -35,9 +34,7 @@ class _SearchCellState extends ConsumerState<SearchCell> {
|
||||
),
|
||||
onSuffixTap: () {
|
||||
widget.controller.text = "";
|
||||
setState(() {
|
||||
|
||||
});
|
||||
setState(() {});
|
||||
},
|
||||
controller: widget.controller,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@@ -29,9 +29,8 @@ class SourceCodeView extends StatefulWidget {
|
||||
this.syntaxHighlighterStyle,
|
||||
}) : super(key: key);
|
||||
|
||||
String? get codeLink => codeLinkPrefix == null
|
||||
? null
|
||||
: '$codeLinkPrefix/$filePath';
|
||||
String? get codeLink =>
|
||||
codeLinkPrefix == null ? null : '$codeLinkPrefix/$filePath';
|
||||
|
||||
@override
|
||||
_SourceCodeViewState createState() {
|
||||
|
||||
@@ -17,7 +17,10 @@ class SyntaxHighlighterStyle {
|
||||
this.constantStyle});
|
||||
|
||||
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)),
|
||||
commentStyle: const TextStyle(color: const Color(0xFF9E9E9E)),
|
||||
keywordStyle: const TextStyle(color: const Color(0xFF9C27B0)),
|
||||
|
||||
@@ -26,7 +26,8 @@ class UserInfoViewModel {
|
||||
_useSecertLogined = SpUtil.getBool(spSecretLogined, defValue: false);
|
||||
_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) {
|
||||
for (Map<String, dynamic> value in tempList) {
|
||||
@@ -40,7 +41,8 @@ class UserInfoViewModel {
|
||||
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);
|
||||
_useSecretLogin(secretLogin);
|
||||
_userName = userName;
|
||||
@@ -93,7 +95,13 @@ class UserInfoViewModel {
|
||||
|
||||
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) {
|
||||
historyAccounts.removeLast();
|
||||
@@ -117,7 +125,8 @@ class UserInfoBean {
|
||||
bool useSecretLogined = false;
|
||||
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) {
|
||||
userName = json['userName'];
|
||||
|
||||
Reference in New Issue
Block a user