33 Commits

Author SHA1 Message Date
484e1eeee3 fix bug 2022-06-23 18:55:11 +08:00
e2a2ae55ec 支持高刷 2022-06-23 17:16:04 +08:00
558b780235 Merge pull request #4 from huoxue1/main
新增订阅管理,新增环境变量备份和导入导出
2022-06-23 16:43:12 +08:00
1cd3724805 新增订阅管理
新增环境变量导入和导出
2022-06-23 16:30:39 +08:00
7e3a63169e 依赖管理支持批量添加 2022-06-16 15:54:19 +08:00
1298dba590 支持上传脚本 2022-06-16 14:37:47 +08:00
2005083d2e 新增代码文件支持行号显示 2022-06-15 11:05:49 +08:00
4e3f8a0df9 1.1.0 release 2022-06-08 10:42:26 +08:00
5698277301 1.1.0 release 2022-06-08 10:18:24 +08:00
02be737264 1.1.0 release 2022-06-08 10:11:49 +08:00
9558f3d235 1.1.0 release 2022-06-08 10:11:32 +08:00
14c3b1a965 优化使用体验 2022-06-08 10:06:54 +08:00
b89de1414a 优化使用体验 2022-06-07 19:32:39 +08:00
9759caf9b8 优化搜索框样式,优化任务列表,环境变量等相关页面使用体验 2022-06-07 18:28:38 +08:00
c7824c920b 优化使用体验 2022-06-02 08:37:54 +08:00
817ad978e2 修改logo 2022-05-30 16:41:47 +08:00
1d59128e47 修改logo 2022-05-30 14:25:32 +08:00
62537f5814 强制横屏 2022-05-30 14:22:09 +08:00
5f91160d9a 强制横屏 2022-05-30 14:20:20 +08:00
64ee8189b1 更新app name 2022-05-30 14:16:37 +08:00
665a51f962 同步ios的功能 2022-05-30 14:14:49 +08:00
bd77beb60a 同步ios的功能 2022-05-30 14:02:14 +08:00
578bb926fa 优化任务列表,环境变量 2022-05-30 13:04:33 +08:00
2c64038fda 任务列表优化 2022-05-30 10:41:09 +08:00
9a27ae8e69 任务列表排序 2022-05-27 09:59:15 +08:00
6716456b04 优化脚本编辑样式 2022-05-27 08:40:48 +08:00
ec3440a0fb 优化脚本编辑样式 2022-05-27 08:40:13 +08:00
598c0cbde4 add xcode config 2022-04-25 10:12:50 +08:00
bce68681ac Merge remote-tracking branch 'origin/main' 2022-04-24 14:22:49 +08:00
85bc4635bc Update AndroidManifest.xml 2022-04-24 14:22:20 +08:00
c94abdb3c5 Add files via upload 2022-04-24 14:02:45 +08:00
4ed9c029ca Delete app-release-v1.0.8.apk 2022-04-24 14:01:19 +08:00
ba7352d26e Add files via upload 2022-04-24 13:29:31 +08:00
262 changed files with 9723 additions and 2428 deletions

1
.gitignore vendored
View File

@ -44,3 +44,4 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
.fvm/

View File

@ -1,10 +1,36 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.
version:
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
channel: stable
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: linux
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: macos
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: windows
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

View File

@ -44,3 +44,20 @@ iOS端暂无上架打算用户自行下载main分支源码编译安装
### 不支持的功能
>* 应用设置
>* 通知设置
版本更新通知 https://t.me/qinglongapp
用于生成app的图标
flutter pub run flutter_launcher_icons:main
生成原生的启动页面
flutter pub run flutter_native_splash:create
修改app名称
flutter pub run flutter_app_name
生成json.jc.dart文件
flutter pub run build_runner build --delete-conflicting-outputs

View File

@ -1,9 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="work.master.qinglongapp">
<application
android:label="青龙"
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label="青龙客户端"
android:name="${applicationName}"
android:icon="@mipmap/img">
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"

View File

@ -0,0 +1,6 @@
package work.master.qinglong_app
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

BIN
apk/app-release-v1.0.8.apk Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

BIN
assets/images/dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

BIN
assets/images/faceid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/images/figure.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
assets/images/icon_a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/images/icon_b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/images/icon_cron.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
assets/images/icon_d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/images/icon_env.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
assets/images/icon_fail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
assets/images/icon_file.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/images/icon_idle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
assets/images/icon_s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
assets/images/js.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
assets/images/json.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

BIN
assets/images/light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

BIN
assets/images/normal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
assets/images/other.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
assets/images/py.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/images/ql_splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/images/shell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/images/svip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
assets/images/svip_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
assets/images/ts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/images/vip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
assets/images/vip_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,52 +0,0 @@
{
"images" : [
{
"filename" : "background.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "darkbackground.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Qinglong App</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>qinglong_app</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<false/>
</dict>
</plist>

View File

@ -24,12 +24,14 @@ 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);
if (viewModel.failedToast != null) {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
(viewModel.failedToast ?? "").toast();
viewModel.clearToast();
});
@ -72,7 +74,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
@override
void initState() {
super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (widget.onReady != null && !widget.lazyLoad) {
widget.onReady!(ref.read<T>(widget.model));
}

View File

@ -1,4 +1,6 @@
import 'package:qinglong_app/base/http/http.dart';
import 'package:qinglong_app/base/http/url.dart';
import 'package:qinglong_app/main.dart';
import 'package:qinglong_app/module/config/config_bean.dart';
import 'package:qinglong_app/module/env/env_bean.dart';
import 'package:qinglong_app/module/home/system_bean.dart';
@ -7,11 +9,10 @@ import 'package:qinglong_app/module/login/user_bean.dart';
import 'package:qinglong_app/module/others/dependencies/dependency_bean.dart';
import 'package:qinglong_app/module/others/login_log/login_log_bean.dart';
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
import 'package:qinglong_app/module/task/task_bean.dart';
import '../../utils/utils.dart';
import 'url.dart';
import 'package:qinglong_app/utils/utils.dart';
class Api {
static Future<HttpResponse<SystemBean>> system() async {
@ -89,24 +90,21 @@ 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,
{
@ -124,15 +122,19 @@ class Api {
}
static Future<HttpResponse<NullResponse>> addTask(
String name, String command, String cron,
{String? id}) async {
var data = {"name": name, "command": command, "schedule": cron};
String name,
String command,
String cron, {
int? id,
String? nId,
}) async {
var data = <String, dynamic>{"name": name, "command": command, "schedule": cron};
if (id != null) {
if (Utils.isUpperVersion()) {
if (id != null || nId != null) {
if (id != null) {
data["id"] = id;
} else {
data["_id"] = id;
} else if (nId != null) {
data["_id"] = nId;
}
return await Http.put<NullResponse>(
Url.addTask,
@ -194,8 +196,7 @@ 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},
@ -231,21 +232,24 @@ class Api {
}
static Future<HttpResponse<NullResponse>> addEnv(
String name, String value, String remarks,
{String? id}) async {
var data = {
String name,
String value,
String remarks, {
int? id,
String? nId,
}) async {
var data = <String, dynamic>{
"value": value,
"remarks": remarks,
"name": name,
};
if (id != null) {
if (Utils.isUpperVersion()) {
if (id != null || nId != null) {
if (id != null) {
data["id"] = id;
} else {
data["_id"] = id;
} else if (nId != null) {
data["_id"] = nId;
}
return await Http.put<NullResponse>(
Url.addEnv,
data,
@ -257,8 +261,7 @@ 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},
@ -273,26 +276,32 @@ class Api {
}
static Future<HttpResponse<List<TaskLogBean>>> taskLog() async {
return await Http.get<List<TaskLogBean>>(Url.taskLog, null,
serializationName: "dirs");
return await Http.get<List<TaskLogBean>>(Url.taskLog, null, serializationName: Utils.isUpperVersion2_12_2() ? "data" : "dirs");
}
static Future<HttpResponse<String>> taskLogDetail(String name) async {
return await Http.get<String>(
Url.taskLogDetail + name,
null,
);
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,
null,
);
} else {
return await Http.get<String>(
Url.taskLogDetail + path + "/" + name,
null,
);
}
}
static Future<HttpResponse<List<ScriptBean>>> scripts() async {
//2.12.2以及以上版本,脚本路径url做了修改
return await Http.get<List<ScriptBean>>(
Url.scripts,
Utils.isUpperVersion2_13_0() ? Url.scripts2 : Url.scripts,
null,
);
}
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,
{
@ -303,8 +312,7 @@ 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,
{
@ -314,8 +322,7 @@ 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,
{
@ -324,8 +331,7 @@ 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,
{
@ -334,8 +340,7 @@ 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],
@ -349,16 +354,21 @@ class Api {
);
}
static Future<HttpResponse<NullResponse>> addDependency(
String name, int type) async {
static Future<HttpResponse<NullResponse>> addDependency(List<Map<String, dynamic>> list) async {
return await Http.post<NullResponse>(
Url.dependencies,
[
{
"name": name,
"type": type,
}
],
list,
);
}
static Future<HttpResponse<NullResponse>> addScript(String name, String path, String content) async {
return await Http.post<NullResponse>(
Url.addScript,
{
"filename": name,
"path": path,
"content": content,
},
);
}
@ -368,4 +378,89 @@ class Api {
[id],
);
}
// 获取订阅
static Future<HttpResponse<List<Subscription>>> getSubscription()async{
return await Http.get<List<Subscription>>(
Url.subscriptions,
{}
);
}
// 新增订阅
static Future<HttpResponse<Subscription>> postSubscription(Subscription subscription)async{
var data = subscription.toJson();
data.remove("id");
data.remove("status");
data.remove("pid");
data.remove("log_path");
data.remove("is_disabled");
data.remove("createdAt");
data.remove("updatedAt");
data.remove("pullType");
data.remove("pullOption");
return await Http.post<Subscription>(
Url.subscriptions,
data
);
}
// 修改订阅
static Future<HttpResponse<Subscription>> putSubscription(Subscription subscription)async{
return await Http.put<Subscription>(
Url.subscriptions,
subscription.toJson()
);
}
// 删除订阅 参数未一个id数组
static Future<HttpResponse<NullResponse>> deleteSubscription(List<int> ids)async{
return await Http.delete<NullResponse>(
Url.subscriptions,
ids
);
}
// 删除订阅 参数未一个id数组
static Future<HttpResponse<NullResponse>> disableSubscription(List<int> ids)async{
return await Http.put<NullResponse>(
Url.disableSubscriptions,
ids
);
}
// 删除订阅 参数未一个id数组
static Future<HttpResponse<NullResponse>> enableSubscription(List<int> ids)async{
return await Http.put<NullResponse>(
Url.enableSubscriptions,
ids
);
}
// 开始执行订阅
static Future<HttpResponse<NullResponse>> startSubscription(
List<int> subscriptions) async {
return await Http.put<NullResponse>(
Url.runSubscriptions,
subscriptions,
);
}
// 暂停订阅执行
static Future<HttpResponse<NullResponse>> stopSubscription(
List<int> subscriptions) async {
return await Http.put<NullResponse>(
Url.stopSubscriptions,
subscriptions,
);
}
// 获取订阅的日志
static Future<HttpResponse<String>> subTimeLog(int subId) async {
return await Http.get<String>(
Url.subtimeLog(subId),
null,
);
}
}

View File

@ -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> {

View File

@ -7,8 +7,7 @@ import '../userinfo_viewmodel.dart';
class TokenInterceptor extends Interceptor {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
options.headers["User-Agent"] =
"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
options.headers["User-Agent"] = "qinglong_client";
options.headers["Content-Type"] = "application/json;charset=UTF-8";

View File

@ -1,11 +1,11 @@
import '../../main.dart';
import '../userinfo_viewmodel.dart';
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
import 'package:qinglong_app/main.dart';
class Url {
static get system => "/api/system";
static get login => "/api/user/login";
static get system => "/api/system";
static get loginOld => "/api/login";
static get loginTwo => "/api/user/two-factor/login";
@ -94,6 +94,10 @@ class Url {
? "/open/scripts/files"
: "/api/scripts/files";
static get scripts2 => getIt<UserInfoViewModel>().useSecretLogined
? "/open/scripts"
: "/api/scripts";
static get scriptUpdate => getIt<UserInfoViewModel>().useSecretLogined
? "/open/scripts"
: "/api/scripts";
@ -106,6 +110,10 @@ class Url {
? "/open/dependencies"
: "/api/dependencies";
static get addScript => getIt<UserInfoViewModel>().useSecretLogined
? "/open/scripts"
: "/api/scripts";
static get dependencyReinstall => getIt<UserInfoViewModel>().useSecretLogined
? "/open/dependencies/reinstall"
: "/api/dependencies/reinstall";
@ -122,6 +130,38 @@ class Url {
: "/api/envs/$envId/move";
}
// 运行订阅
static get runSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
? "/open/subscriptions/run"
: "/api/subscriptions/run";
// 停止订阅
static get stopSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
? "/open/subscriptions/stop"
: "/api/subscriptions/stop";
// 启用订阅
static get enableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
? "/open/subscriptions/enable"
: "/api/subscriptions/enable";
// 禁用订阅
static get disableSubscriptions => getIt<UserInfoViewModel>().useSecretLogined
? "/open/subscriptions/disable"
: "/api/subscriptions/disable";
// GET 获取订阅 POST 提交订阅 PUT 修改订阅 DELETE 删除订阅
static get subscriptions => getIt<UserInfoViewModel>().useSecretLogined
? "/open/subscriptions"
: "/api/subscriptions";
// 获取订阅日志
static subtimeLog(int cronId) {
return getIt<UserInfoViewModel>().useSecretLogined
? "/open/subscriptions/$cronId/log"
: "/api/subscriptions/$cronId/log";
}
static bool inWhiteList(String path) {
if (path == login ||
path == loginByClientId ||
@ -138,7 +178,4 @@ class Url {
}
return false;
}
static String checkUpdateUrl =
"https://raw.githubusercontent.com/qinglong-app/qinglong_app/main/version";
}

View File

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:qinglong_app/module/change_account_page.dart';
import 'package:qinglong_app/module/config/config_edit_page.dart';
import 'package:qinglong_app/module/env/add_env_page.dart';
import 'package:qinglong_app/module/env/env_bean.dart';
@ -7,13 +8,17 @@ import 'package:qinglong_app/module/env/env_detail_page.dart';
import 'package:qinglong_app/module/home/home_page.dart';
import 'package:qinglong_app/module/login/login_page.dart';
import 'package:qinglong_app/module/others/about_page.dart';
import 'package:qinglong_app/module/others/change_account_page.dart';
import 'package:qinglong_app/module/others/backup/backup_page.dart';
import 'package:qinglong_app/module/others/dependencies/add_dependency_page.dart';
import 'package:qinglong_app/module/others/dependencies/dependency_page.dart';
import 'package:qinglong_app/module/others/login_log/login_log_page.dart';
import 'package:qinglong_app/module/others/scripts/script_detail_page.dart';
import 'package:qinglong_app/module/others/scripts/script_edit_page.dart';
import 'package:qinglong_app/module/others/scripts/script_page.dart';
import 'package:qinglong_app/module/others/subscription/subscription_add_page.dart';
import 'package:qinglong_app/module/others/subscription/subscription_bean.dart';
import 'package:qinglong_app/module/others/subscription/subscription_detail_page.dart';
import 'package:qinglong_app/module/others/subscription/subscription_page.dart';
import 'package:qinglong_app/module/others/task_log/task_log_detail_page.dart';
import 'package:qinglong_app/module/others/task_log/task_log_page.dart';
import 'package:qinglong_app/module/others/theme_page.dart';
@ -22,6 +27,8 @@ import 'package:qinglong_app/module/task/add_task_page.dart';
import 'package:qinglong_app/module/task/task_bean.dart';
import 'package:qinglong_app/module/task/task_detail/task_detail_page.dart';
import '../module/others/scripts/script_add_page.dart';
class Routes {
static const String routeHomePage = "/home/homepage";
static const String routeLogin = "/login";
@ -43,6 +50,12 @@ class Routes {
static const String routeAbout = "/about";
static const String routeTheme = "/theme";
static const String routeChangeAccount = "/changeAccount";
static const String routerAddScript = "/script/add";
static const String routerSubscription = "/subscription";
static const String routerSubscriptionDetail = "/subscription/detail";
static const String routerSubscriptionAdd = "/subscription/add";
static const String routerBackup = "/backup";
static Route<dynamic>? generateRoute(RouteSettings settings) {
switch (settings.name) {
@ -57,100 +70,130 @@ class Routes {
} else {
return MaterialPageRoute(builder: (context) => const LoginPage());
}
case routeChangeAccount:
return MaterialPageRoute(
builder: (context) => const ChangeAccountPage(),
);
case routeAddTask:
if (settings.arguments != null) {
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => AddTaskPage(
taskBean: settings.arguments as TaskBean,
));
} else {
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
return MaterialPageRoute(builder: (context) => const AddTaskPage());
}
case routeAddDependency:
return CupertinoPageRoute(
builder: (context) => const AddDependencyPage());
return MaterialPageRoute(builder: (context) => const AddDependencyPage());
case routeAddEnv:
if (settings.arguments != null) {
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => AddEnvPage(
envBean: settings.arguments as EnvBean,
));
} else {
return CupertinoPageRoute(builder: (context) => const AddEnvPage());
return MaterialPageRoute(builder: (context) => const AddEnvPage());
}
case routeConfigEdit:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => ConfigEditPage(
(settings.arguments as Map)["title"],
(settings.arguments as Map)["content"],
),
);
case routeLoginLog:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const LoginLogPage(),
);
case routeTaskLog:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const TaskLogPage(),
);
case routeScript:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const ScriptPage(),
);
case routeDependency:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const DependencyPage(),
);
case routeTaskLogDetail:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => TaskLogDetailPage(
title: settings.arguments as String,
title: (settings.arguments as Map)['title'],
path: (settings.arguments as Map)['path'],
),
);
case routeScriptDetail:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => ScriptDetailPage(
title: (settings.arguments as Map)["title"],
path: (settings.arguments as Map)["path"],
),
);
case routeTaskDetail:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => TaskDetailPage(
settings.arguments as TaskBean,
),
);
case routeEnvDetail:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => EnvDetailPage(
settings.arguments as EnvBean,
),
);
case routeUpdatePassword:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const UpdatePasswordPage(),
);
case routeAbout:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const AboutPage(),
);
case routeTheme:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => const ThemePage(),
);
case routeChangeAccount:
return CupertinoPageRoute(
builder: (context) => const ChangeAccountPage(),
);
case routeScriptUpdate:
return CupertinoPageRoute(
return MaterialPageRoute(
builder: (context) => ScriptEditPage(
(settings.arguments as Map)["title"],
(settings.arguments as Map)["path"],
(settings.arguments as Map)["content"],
),
);
case routeScriptAdd:
return MaterialPageRoute(
builder: (context) => ScriptAddPage(
(settings.arguments as Map)["title"],
(settings.arguments as Map)["path"],
),
);
case routerSubscription:
//部分低端手机用Cupertino滑动时掉帧,左侧会出现白色空白
return MaterialPageRoute(
builder: (context) => const SubscriptionPage(),
);
case routerSubscriptionDetail:
return MaterialPageRoute(
builder: (context) => SubscriptionDetailPage(
settings.arguments as Subscription,
),
);
case routerSubscriptionAdd:
if (settings.arguments != null) {
return MaterialPageRoute(
builder: (context) => SubscriptionAddPage(
settings.arguments as Subscription,
));
} else {
return MaterialPageRoute(builder: (context) => const SubscriptionAddPage(null));
}
case routerBackup:
return MaterialPageRoute(
builder: (context) => const BackUpPage(),
);
}
return null;

View File

@ -6,3 +6,4 @@ String spTheme = "dart_mode";
String spSecretLogined = "secret_logined";
String spCustomColor = "customColor";
String spLoginHistory = "loginHistory";
String spShowLine = "spShowLine";

View File

@ -10,7 +10,7 @@ import 'package:qinglong_app/utils/sp_utils.dart';
var themeProvider = ChangeNotifierProvider((ref) => ThemeViewModel());
const commonColor = Color(0xFF299343);
Color commonColor = const Color(0xFF299343);
Color _primaryColor = commonColor;
class ThemeViewModel extends ChangeNotifier {
@ -24,7 +24,7 @@ class ThemeViewModel extends ChangeNotifier {
ThemeViewModel() {
_primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
primaryColor = Color(getIt<UserInfoViewModel>().primaryColor);
var brightness = SchedulerBinding.instance!.window.platformBrightness;
var brightness = SchedulerBinding.instance.window.platformBrightness;
_isInDarkMode = brightness == Brightness.dark;
changeThemeReal(_isInDarkMode, false);
}
@ -69,9 +69,12 @@ class ThemeViewModel extends ChangeNotifier {
secondary: _primaryColor,
primary: _primaryColor,
),
scaffoldBackgroundColor: const Color(0xfff5f5f5),
scaffoldBackgroundColor: const Color(0xffffffff),
inputDecorationTheme: InputDecorationTheme(
labelStyle: TextStyle(color: _primaryColor),
labelStyle: TextStyle(
color: _primaryColor,
fontSize: 14,
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: _primaryColor,
@ -152,7 +155,10 @@ class ThemeViewModel extends ChangeNotifier {
),
),
inputDecorationTheme: InputDecorationTheme(
labelStyle: TextStyle(color: _primaryColor),
labelStyle: TextStyle(
color: _primaryColor,
fontSize: 14,
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: _primaryColor,
@ -208,12 +214,17 @@ class ThemeViewModel extends ChangeNotifier {
abstract class ThemeColors {
Color settingBgColor();
Color settingBordorColor();
Color titleColor();
Color descColor();
Color tabBarColor();
Color blackAndWhite();
Color pinColor();
Color buttonBgColor();
@ -232,6 +243,11 @@ class LightThemeColors extends ThemeColors {
return const Color(0xffF7F7F7);
}
@override
Color blackAndWhite() {
return Colors.white;
}
@override
Map<String, TextStyle> codeEditorTheme() {
return qinglongLightTheme;
@ -256,6 +272,11 @@ class LightThemeColors extends ThemeColors {
Color settingBordorColor() {
return Colors.white;
}
@override
Color tabBarColor() {
return const Color(0xffF7F7F7);
}
}
class DartThemeColors extends ThemeColors {
@ -274,6 +295,11 @@ class DartThemeColors extends ThemeColors {
return qinglongDarkTheme;
}
@override
Color blackAndWhite() {
return Colors.black;
}
@override
Color descColor() {
return const Color(0xff999999);
@ -293,4 +319,9 @@ class DartThemeColors extends ThemeColors {
Color settingBordorColor() {
return Color(0xff333333);
}
@override
Color tabBarColor() {
return Colors.black;
}
}

View File

@ -6,7 +6,7 @@ mixin LazyLoadState<T extends StatefulWidget> on State<T> {
@override
void initState() {
super.initState();
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var route = ModalRoute.of(context);
void handler(status) {
if (status == AnimationStatus.completed) {

View File

@ -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,
);
@ -87,7 +89,7 @@ enum _ContextMenuLocation {
/// See also:
///
/// * [Apple's HIG for Context Menus](https://developer.apple.com/design/human-interface-guidelines/ios/controls/context-menus/)
class QlCupertinoContextMenu extends StatefulWidget {
class QlCupertinoContextMenu<T> extends StatefulWidget {
/// Create a context menu.
///
/// [actions] is required and cannot be null or empty.
@ -103,7 +105,7 @@ class QlCupertinoContextMenu extends StatefulWidget {
assert(child != null),
super(key: key);
final TaskBean bean;
final T bean;
/// The widget that can be "opened" with the [QlCupertinoContextMenu].
///
@ -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,14 @@ class _QlCupertinoContextMenuState extends State<QlCupertinoContextMenu> with Ti
_openController.reverse();
} else {
if (_openController.isDismissed) {
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
if (widget.bean is TaskBean){
Navigator.of(context)
.pushNamed(Routes.routeTaskDetail, arguments: widget.bean);
}else{
Navigator.of(context)
.pushNamed(Routes.routerSubscriptionDetail, arguments: widget.bean);
}
}
}
}
@ -419,7 +430,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 +493,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 +552,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 +577,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 +589,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 +629,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 +642,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 +680,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 +756,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 +767,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 +777,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 +857,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 +878,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 +900,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 +961,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 +1001,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 +1016,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 +1052,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 +1063,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,

View File

@ -0,0 +1,66 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../theme.dart';
class SearchCell extends ConsumerStatefulWidget {
final TextEditingController controller;
const SearchCell({
Key? key,
required this.controller,
}) : super(key: key);
@override
ConsumerState createState() => _SearchCellState();
}
class _SearchCellState extends ConsumerState<SearchCell> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return CupertinoSearchTextField(
decoration: BoxDecoration(
color: ref.watch(themeProvider).themeColor.blackAndWhite(),
border: Border.all(width: 1, color: const Color(0xffC0C4CC)),
borderRadius: BorderRadius.circular(
7,
),
),
onSuffixTap: () {
widget.controller.text = "";
setState(() {});
},
controller: widget.controller,
padding: const EdgeInsets.symmetric(
horizontal: 5,
vertical: 5,
),
suffixInsets: const EdgeInsets.only(
right: 15,
),
prefixIcon: Image.asset(
"assets/images/icon_search.png",
width: 18,
fit: BoxFit.cover,
),
prefixInsets: const EdgeInsets.only(
left: 10,
top: 2,
),
placeholderStyle: TextStyle(
fontSize: 14,
color: ref.watch(themeProvider).themeColor.descColor(),
),
style: const TextStyle(
fontSize: 16,
),
placeholder: "请输入内容",
);
}
}

Some files were not shown because too many files have changed in this diff Show More